tomo's blog

Should you use Kotlin?

I spent some time looking at a relatively unknown programming language called Kotlin today. Kotlin was designed by a company rather than by academics in a computer science department. The company happens to make and sell an IDE so perhaps they are hoping that as the language becomes more popular and programmers need an IDE to use it they will become customers of JetBrains, the company behind Kotlin.

The basic description of the language goes like this: Kotlin is a statically-typed programming language that runs on the Java Virtual Machine

Kotlin is yet another language that...

Testing Bitcoin with Testnet wallets and coins

Bitcoin is, among many things, a software system with many participants running Bitcoin software and who all connect to each other over the internet forming a Bitcoin network. It's a live system yet the software that runs it is continuously under development. This is what the Bitcoin Core dev team does, and sometimes they allow other people to participate in development like an open source project. There are other developers who also develop other Bitcoin code which fulfills the same purposes. Then all of the various Bitcoin nodes run a version of the software.

Of course, any...

@mixin and other CSS @at-rules in Sass/SCSS

You've probably seen CSS rules which start with the at-sign such as @font-face for custom fonts or @media used for responsive styling based on screen size. Maybe you've even used @keyframes for CSS animations. These so-called at-rules can go around normal CSS rules (normally a rule would simply be one or more selectors followed by lines of rules within curly braces).

But the @-rules are rarely sprinkled throughout a stylesheet.

In preprocessed CSS like Sass, many new at-rules are possible. Here we're using Sass/SCSS.

What's SCSS? It's...

How to read a SPF record and allow Google Apps Gmail to send for your custom domain

An SPF record is a hack. It's a way of using the DNS protocol to say who is allowed to authoritatively send email as a domain name. It does this by using a DNS TXT record (as opposed to an A or MX record). TXT can contain any text. An SPF record is a specially encoded TXT record like this:

"v=spf1 ip4:198.51.100.26 -all"

The v=spf1 indicates that this is an SPF record, considered version 1 of the spf standard.

After the version, there are any number of 'directives'. In this example, there's only 1...

Import multi-line cells in CSV format into Google Sheets

In Google Sheets (and Excel or Mac Numbers should be similar for most of this), you normally enter a cell's value by hitting enter which moves to the next cell. But if you need multiple lines in a single cell, you need to know the trick of holding command/Apple-key when pressing enter.

If you want to import a CSV file into Google Sheets but get the same effect, then you need to escape the new-line markers.

First, a cell which contains more than one line (instead of each line being on a new row) needs to be "escaped" with double quotes at the start and end of the cell's...

JavaScript Namespaces and Closures instead of Global Variables

Have you heard? Global variables are bad, mmkay? So what should we do if we want to create a variable in our script and be able to refer to it elsewhere, globally?

What's in a Namespace?

A JavaScript namespace is just an idea or practice rather than an explicit feature of JavaScript. That is, you don't create a "namespace object" or declare a namespace. Instead, you would implement a namespace by creating and using an object which would contain sub-variables within it, so that those variables didn't pollute the namespace of the global scope (i.e. everything under the...

Cross-platform node scripts: better-npm-run to the rescue

We know that Node.js is awesome and JavaScript is the ultimate cross-platform language. Node has support for Windows despite the node command being a command line program. Windows users can use the command line shell for node. But the Windows shell environment isn't completely compatible with what Unix/Linux/Mac users are used to (i.e. Bash). The npm package Better-npm-run helps deal with running tasks with node across platforms including Windows.

Get it here: https://www.npmjs.com/package/better-npm-run

This...

Web viewports for mobile responsive websites

What is a viewport? You may have seen the meta-tag named "viewport" on newer mobile-friendly websites. The mobile (iOS) version of Safari introduced the "viewport meta tag" and "scale" on the viewport for mobile (scale optionally being one of the special values minimum-scale, maximum-scale, and user-scalable).

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

A viewport is like a logical window. You are on one side of the window looking through to the...

Embed a YouTube video player and control it via JavaScript

YouTube has long made it easy to share and embed videos into websites by giving you the HTML code to just copy and paste wherever you like. Over the years, different technologies have been used to play videos on the web, from Flash object elements to pure HTML5. YouTube's newest API for adding videos to web pages takes care of the technology, automatically choosing the best delivery method on a user by user basis.

YT did have something called the "YouTube JavaScript Player API" but this is out of date so don't use it. Instead use the new...

How to detect a swipe touch event on mobile browsers with JavaScript

Browsers have supported various mouse-based events like clicks, down to the detection of when the mouse button is down and when it's released. You can know the coordinates of the mouse cursor, all in JavaScript. Mobile interfaces have brought some new gestures beyond what desktops provided. One big set of such UI events is from the smartphone's screen allowing touch and even multi-touch. Multitouch allows more types of UI events.

Many mobile apps support swiping, not just as a way to move a visible object around thescreen but applied for the whole screen. Tinder uses left swipe and...

tomo's blog | TECH.SAIGONIST.COM

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /home/tomo/web/tech.saigonist.com/drupal7/php/includes/common.inc:2776) in drupal_send_headers() (line 1486 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/bootstrap.inc).
  • Error: Class 'CToolsCssCache' not found in _cache_get_object() (line 32 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/cache.inc).
The website encountered an unexpected error. Please try again later.