Skip to content

Instantly share code, notes, and snippets.

@Kreijstal
Kreijstal / promises.m
Last active July 8, 2020 21:38
Promises in Mathematica
(* ::Package:: *)
(*Import like Import["https://gist.githubusercontent.com/Kreijstal/\
2a34158a1cf159b4ddc5ab3460f6efd0/raw/\
6bfc3328d9538844fabbbce9691fb3c63824ed9f/promises.m"]*)
Promise::usage="Promise[Function[{accept,reject},CustomLogic[accept[\"Success!\"],reject[\"Oh no! Error!\"]]]]"
Promise :=
Module[{local, success, failure, listen, counter = 0, Promise},
success[x_] := (local["s"] = x;(*Print[{"I've been executed",x,
local}];*)Through[local["t"][local["s"]]]; local["t"] = {};
local["resolved"] = True);
@avoidik
avoidik / README.md
Last active April 24, 2023 13:08
Build openssl and M2Crypto on Windows
@kpy3
kpy3 / setupdb.md
Created March 30, 2018 22:16 — forked from danisfermi/setupdb.md
Setup gdb on Mac OS Sierra/High Sierra

Here are the steps to installing and setting up GDB on Mac OS Sierra/High Sierra. Run brew install gdb. On starting gdb, you will get the following error:

Unable to find Mach task port for process-id 2133: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

To fix this error, follow the following steps:

@aderaaij
aderaaij / es6-spread-operator.js
Last active July 25, 2018 09:27
The spread operator can expand(spread) any iterable like an array or a string.
const avengers = ['Thor', 'The Hulk', 'Captain America'];
let guardians = ['Star Lord', 'Gamorra', 'Drax', 'Rocket', 'Groot'];
// Spread out arrays in a new array and put a new value in between them
const heroes = [...avengers, 'Loki', ...guardians];
// Adding new stuff to an array just got easier too
guardians = [...guardians, 'Mantis', 'Yondu', 'Nebula'];
// Or simply making a TRUE copy of an array
const avengersCopy = [...avengers];
@geraldvillorente
geraldvillorente / import.md
Created June 14, 2017 05:03
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p.

@rmoff
rmoff / foo.md
Last active January 5, 2024 17:17
cx_Oracle install on MacOS
  1. Download Instant Client:
  • instantclient-basic-macos.x64-11.2.0.4.0.zip
  • instantclient-sdk-macos.x64-11.2.0.4.0.zip
  • instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
  1. Unzip and move to /opt

  2. Create symlink

@mpj
mpj / classless.md
Last active November 13, 2023 16:34

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@gousiosg
gousiosg / stackoverflow.sql
Last active December 6, 2023 22:12
Script to import the stackexchange dumps into MySQL
# Copyright (c) 2013 Georgios Gousios
# MIT-licensed
create database stackoverflow DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
use stackoverflow;
create table badges (
Id INT NOT NULL PRIMARY KEY,
UserId INT,
@jboner
jboner / latency.txt
Last active April 25, 2024 01:18
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD