Skip to content

Instantly share code, notes, and snippets.

@lakshin
lakshin / multirequire.js
Last active Nov 24, 2017
Use multiple package versions in one node project
View multirequire.js
//server.js
const http = require('http');
//const niv = require('npm-install-version');
const chalkv2 = require('chalk');
const multiRequire = require('./multiRequire');
const chalkv1 = multiRequire().multiRequire('chalk','1.0.0');
console.log('chalk v1'+chalkv1.blue(chalkv1.version));
console.log('chalk v2'+chalkv2.blue(chalkv2.version));
const hostname = '127.0.0.1';
@contra
contra / aoe2hd.md
Last active Jun 10, 2021
Age of Empires II HD - For Mac OSX
View aoe2hd.md

AOE2HD - For Mac OSX

Estimated time: 10 minutes

!!! NOTICE - PLEASE READ !!!

PlayOnMac does not work on macOS Catalina at all - and on older versions of macOS issues have been reported with the latest version of Steam. Updating is in progress, read more here.

When the updates are released this guide will be updated. Please do not blow up my inbox by leaving comments "WHY DOESNT IT WORK".

View redux-simple-store.js
// reducer.js
let initialState = 0;
function reducer (state=initialState, action) {
switch(action.type){
case 'INCREMENT_COUNT':
return state + 1;
default:
return state
}
View snakecoin.py
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
View follow-the-dirty-money.md

Follow the dirty money

A shady Internet business has been discovered.

The website has been made public by a whistle blower. We have enough evidence about the dirty deals they did. But to charge them we need to get hands on precise numbers about the transactions that happened on their platform.

Unfortunately no record of the transactions could be seized so far. The only hint we have is this one transaction:

@jaredhowland
jaredhowland / clear-font-cache.md
Last active Feb 9, 2021
Clear Mac OS X Font Caches
View clear-font-cache.md
@adam-p
adam-p / Local PR test and merge.md
Last active Jun 8, 2021
Testing a pull request, then merging locally; and avoiding TOCTOU
View Local PR test and merge.md

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: https://github.com/Psiphon-Labs/psiphon-tunnel-core/pull/37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@allenwb
allenwb / 0Option2ConstructorSummary.md
Last active May 26, 2021
New ES6 constructor features and semantics: Alternative 2 manual super in derived classes
View 0Option2ConstructorSummary.md

New ES6 Constructor Semantics and Usage Examples

Manual super: Alternative Design where subclass constructors do not automatically call superclass constructors

This Gist presents a new design of class-based object construction in ES6 that does not require use of the two-phase @@create protocol.

One of the characteristics of this proposal is that subclass constructors must explicitly super invoke their superclass's constructor if they wish to use the base class' object allocation and initialization logic.

An alternative version of this design automatically invokes the base constructor in most situations.

@subfuzion
subfuzion / mongo-autostart-osx.md
Last active Apr 26, 2021
mongo auto start on OS X
View mongo-autostart-osx.md

Install with Homebrew

brew install mongodb

Set up launchctl to auto start mongod

$ ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

/usr/local/opt/mongodb/ is a symlink to /usr/local/Cellar/mongodb/x.y.z (e.g., 2.4.9)

@lttlrck
lttlrck / gist:9628955
Created Mar 18, 2014
rename git branch locally and remotely
View gist:9628955
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote