tomo's blog

Creating forms with callbacks in React+Redux

In React, you have some simple/dumb components which are just html and other components and maybe render some values which are passed in. It becomes a little trickier when you want to add some functionality to the component, such as form elements - inputs and buttons and submit actions. What I mean by "forms with callbacks" is that you want to execute some JavaScript and also change state in your React app, but do so without giving direct access to state to the component. Instead here's one way to do it.

  1. Draw out the HTML (don't worry about using React components yet) in JSX
  2. ...

Quick explanation of JavaScript Promises

"JavaScript Promises: reason about async events, serially chain them, reduce them. General replacement for XHR"

What is a promise? Conceptually and outside the context of code, a promise is either a willful intention of achieving a result or a promise is considered the actual result itself. EcmaScript 6 (ES6) introduces the Promises API which is currently implemented by most browsers (and Edge but not IE according to - but there's a polyfill for that). So a JavaScript Promise is simply an object of some callback...

Assembly language vs Bytecode vs WebAssembly vs Asm.js


In the beginning there was a CPU. And the CPU could be loaded with data which were numbers and these magical numbers would cause the CPU to process those numbers and produce new numbers. This data which the CPU was running, the numbers fed into the computer, was machine code. And all programming of computers that's still done today ultimately ends up turning into machine code for the CPU, binary machine code being the only thing a computer can understand.

But long series of numbers, where each 256 or more unique numbers has special meaning which changes depending...

Top 5 Programming Languages to Learn in 2016

It's a new year in a world that's moving faster than ever. This means it's important to keep up to date on technology, and young people who would have not been programmers before need to learn to code. There are various lists of programming languages by popularity of demand but they are too broad to read at face value. I've seen many people fail to learn a programming language when they had nothing to apply it to and were simply learning how a language works. It's a bit like learning a foreign language by reading a dictionary. The following list are my choices (not necessarily in order)...

Why Tcl sucks as a programming language

Tcl is a dying language. In the free marketplace of ideas, tcl lacks the community of fans as well as corporate support (see the languages invented at Microsoft, or the huge push in JavaScript from Google's optimization of V8 and thus Node.js as well as Go from Google, or all the large web companies who help PHP dominate most of the software running the web, whereas Tcl's was once sponsored by Sun who then spawned Java and then died/got swallowed by Oracle). Also, tcl sucks.

There was a time (in the 90s) that Unix graphical programs were all universally ugly and many used the Tk...

Developer interview: What is AngularJS and What about Angular 2?

My friend Chau is a long-time Microsoft / .Net developer who has recently switched his company's focus to single-page apps (SPAs), especially web apps built using Angular. He's preparing to use Angular 2.0 now. I asked him to explain Angular a bit.

What is Angular?

A popular (frontend web) UI framework for single page applications (SPA) from Google.

What does it replace? There are a lot of JavaScript frameworks out there nowadays, so why this one?

We started out using Knockout for 2-way binding mostly but it didn't take care of anything outside of that....

What is a pseudo-random number generator (PRNG) and why do they matter?

Recently, a problem was discovered in the pseudo-random number generator which Google Chrome and Node.js's V8 JavaScript engine uses and depends on. The problem was that a pattern was discovered in the series of numbers which the RNG algorithm produced, meaning you could guess the "random" outcome at a probability higher than chance, giving you an advantage - whether the application is breaking encryption or passwords or beating games of chance.

Edward Snowden, who had worked for the CIA, warned of problems or backdoors in hardware random number generators which many computers...

How to login to any website using Curl from the command line or shell script

There are times you need to scrape/crawl some field on a page but the page requires authentication (logging in). Unless the site is using Basic Auth, where you can have the username and password in the url like http://username:[email protected]/ then you'll need to curl with more sophistication. Besides curl, there are other web tools which you can use on the command line such as links/elinks (elinks is an enhanced version of links which also supports JavaScript to a very limited extent). Links and curl will not execute JavaScript though, so if that's necessary to get...

JavaScript's Symbol Type (ECMAScript 6)

JavaScript is not a strongly-typed language like many classic compiled languages. Instead, like many scripting languages, it is loosely typed and has just a few basic types: number, string, object, boolean. There are also two types which are used as values (rather than to hold varying values like numbers and strings) which are null (no value) and undefined (the initial or undefined value of a variable). JavaScript is aware of Arrays as a type of object, but is still an object and not a separate type. Objects in JavaScript take prototypical inheritence. A literal object looks like a Python...

Use an external USB drive across Windows and Mac OSX: exFAT, NTFS, HFS+

Since the beginning of time, Macs and PCs (IBM-compatible / Intel-chip / Microsoft DOS or Windows OS) used the same or similar hardware, including for external storage, but had differences in software which made sharing of hardware between them incompatible. Even as each operating system (from Mac OS up to OSX, DOS to Windows 3.1 to Windows NT) upgraded and used new disk formats, they remained different and incompatible. Other OSs like Linux and the BSDs had their own quirks, although they also sought to be able to work with DOS disks from the beginning, and can mount disks from other...

tomo's blog | TECH.SAIGONIST.COM



Error message

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