Skip to content

Instantly share code, notes, and snippets.

gyzerok / base64ArrayBuffer.js
Last active Jan 5, 2021 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
View base64ArrayBuffer.js
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
gyzerok /
Created Sep 30, 2020 — forked from amake/
Inno Setup on Linux and macOS

Inno Setup on Linux and macOS

Inno Setup is a popular installer builder for Windows. Of course it is made to run on Windows only, by default. But what if you want to build Windows installers off Windows, i.e. on Linux or macOS?

You’re in luck: It’s possible to run Inno Setup anywhere that Docker runs (including Linux and macOS), and even have a passable experience writing your setup script.

View One Liner to Download the Latest Release from Github
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
gyzerok / QueryBuilder.js
Last active Feb 4, 2020
RxJS MongoDB Query Builder
View QueryBuilder.js
/* @flow */
import { Observable, Disposable, ReplaySubject } from 'rx';
import mongo from 'mongodb';
import { dbUrl } from './config';
import { assign } from 'lodash';
class QueryBuilder {
_db$: Observable;
_selectors: Object;
gyzerok /
Last active Aug 14, 2018 — forked from jinjor/
elm-make one by one
# make sure every time only one file is re-compiled
echo "time\t\tlines\timports\tfile"
for f in `find src -name *.elm`
elm-make $f --output=/dev/null > /dev/null
sleep 1
touch $f
a=`wc -l $f | awk '{print $1}'`

Only have one outgoing port, and only one incoming port

If you have many ports, they could be all over your project, and therefore hard to manage and easy for forget about. Keep track of all of them by representing your outgoing ports in a union type like..

type JsMsg
    = Download
    | Login Login.Payload
    | Logout
    | Track Tracking.Payload
gyzerok /
Created Jan 4, 2018 — forked from evancz/
Cron job to remind myself to stretch

Type crontab -l to see your cron jobs. Type crontab -e to edit them. You have to use Vim apparently.

Add a line like this:

0,30	*	*	*	*	/Users/YOURNAME/Documents/scripts/

That is on every 0th and 30th minute of the hour. Make sure all the separators in there are tabs!


Standardized Ladder of Functional Programming

The LambdaConf Ladder of Functional Programming (LOFP) is a standardized progression of different concepts and skills that developers must master on their journey to becoming expert-level functional programmers. LOFP can be used to rank workshops, talks, presentations, books, and courseware, so that aspiring functional programmers have a better understanding of what material is appropriate for them given their current experience.



  • Immutable Data
  • Second-order Functions
View io-ts-reporter.ts
function decode<T>(value: any, type: t.Type<T>): Promise<T> {
const validation = t.validate(value, type);
return validation.fold(
([e, ..._unused]) => {
const actualErr = _.last(e.context);
const errPath = e.context
.map(c => c.key)
.filter(key => key.length)
gyzerok /
Last active Nov 28, 2016
Thoughts on implementing GraphQL in Elm

GraphQL in Elm

Before going down to some problem statement and requirement I'd like to tell you what makes Elm for me a better choice upon JavaScript and why I moving towards adopting it for productions usage.

I can make some changes in my codebase, run elm-make and see all the places where I should do subsequent changes. Statically. Ave compiler and static types!

The goal of this paper is to describe why proposition of using different types for different queries would result in almost the same pitfalls I have in JavaScript with GraphQL.