Skip to content

Instantly share code, notes, and snippets.

@m-radzikowski
m-radzikowski / script-template.sh
Last active April 8, 2024 03:04
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Rank Type Prefix/Suffix Length
1 Prefix my+ 2
2 Suffix +online 6
3 Prefix the+ 3
4 Suffix +web 3
5 Suffix +media 5
6 Prefix web+ 3
7 Suffix +world 5
8 Suffix +net 3
9 Prefix go+ 2
// This is universal, works with Infura -- set provider accordingly
const ethers = require('ethers')
//const provider = ethers.getDefaultProvider('rinkeby')
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL)
function hex_to_ascii(str1) {
var hex = str1.toString();
var str = '';
for (var n = 0; n < hex.length; n += 2) {

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@mck-
mck- / routific-local-motion.js
Created March 22, 2016 23:30
Routific solution to Local Motion challenge
var drivingSchedule = {};
var turnNumber = 0;
var MIN_VISITS_PER_VEHICLE = 1; // to keep everyone busy
var OPTIMIZE_EVERY_X_TURNS = 5;
var turn = function(vehicles, people, buildings) {
'use strict';
if(turnNumber % OPTIMIZE_EVERY_X_TURNS === 0 && turnNumber < 1000) {
// Parse data to be suitable for Routific's API
@kangax
kangax / quicksort.hs
Last active September 5, 2021 19:44
Haskell-inspired quick sort in ES6
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort (filter (<=x) xs)
biggerSorted = quicksort (filter (>x) xs)
in smallerSorted ++ [x] ++ biggerSorted
@quellish
quellish / FBClasses.txt
Created August 15, 2015 01:50
Facebook iOS App Class List
headers:
_ASAsyncTransaction.h
_ASAsyncTransactionGroup.h
_ASDisabledPanUITextView.h
_ASDisplayLayer.h
_ASDisplayLayerDelegate-Protocol.h
_ASDisplayView.h
_ASImageNodeDrawParameters.h
_ASPendingState.h
_ASTextNodeCachedMetrics.h
@paulirish
paulirish / bling.js
Last active February 20, 2024 14:11
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@alexmingoia
alexmingoia / gist:4db967e5aeb31d84847c
Last active August 3, 2018 22:48
Beyond Angular and Backbone with Undirectional apps

Beyond Angular and Backbone with Unidirectional apps

What is a unidirectional app?

Unidirectional is a term coined by React engineers to describe the data flow of an application. Unidirectional apps employ functional reactive programming techniques such as immutability, purity, and most importantly unidirectional (as opposed to bidirectional) data flow.

A unidirectional app is defined by no mutable references no two-way references between concerns.

Unidirectional app flowchart

@staltz
staltz / introrx.md
Last active April 19, 2024 09:27
The introduction to Reactive Programming you've been missing