Skip to content

Instantly share code, notes, and snippets.

🛠
Promise.all( [ hack(), huntJob() ] )

Mike McGranahan mcgwiz

🛠
Promise.all( [ hack(), huntJob() ] )
Block or report user

Report or block mcgwiz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Gericop
Gericop / semaphore.js
Last active Dec 3, 2019
A simple implementation of a semaphore in JS
View semaphore.js
function Semaphore(max) {
var counter = 0;
var waiting = [];
var take = function() {
if (waiting.length > 0 && counter < max){
counter++;
let promise = waiting.shift();
promise.resolve();
}
View lightclient-peers-mainnet-latest.txt
admin.addPeer("enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303");
admin.addPeer("enode://43bb4daa1d8ccabb439f460444ece1567c17fdb9da6d43d6b978576dc2dd4354cc2402c19b37a6354795459729d574c6f6ce83182abd2f2ce05ed6e39f5973b2@213.239.220.183:30303");
@rfikki
rfikki / rinkeby-peers-latest.txt
Last active Dec 7, 2019
Updated DECEMBER 07, 2019 - IMPORTANT RUN THE LATEST RELEASE OF THE CLIENT - https://geth.ethereum.org/downloads/
View rinkeby-peers-latest.txt
admin.addPeer("enode://492f6daf9df6840d3812ad55bec13f81092e165f654cd0da5de6afdcab2739177cb7fadadc1154333ccba8998424a61d20cae672666bc73dfa1f974318af1a8f@80.83.124.106:30303");
admin.addPeer("enode://d085b4d5eaf882f0290980835003323524ac9b9c09be04bffb71265fd9a53eae31f04c6668cb8a9ab23adfb754dfeecde36e9dff77178c1399e0f8895cc66687@185.109.168.48:30303");
admin.addPeer("enode://23f6f9b987e5bc0a05011d41448ec612293e96a19b6493eab5cfc2729e106957e4a1fbb37a67a9799b75d93427eed67cf1aedab2c596e5cb65724f0bffe2e783@139.180.160.165:30305");
admin.addPeer("enode://de5c93a4fa8b4aa5e4bba856b83f5cedb1898db3c6b755335bcf1cda3a65e30b44ccfccce80d4f3e8bf0b6d2256e5fcd73d59e8892da99ab2990f7199f10c3a8@206.189.64.101:30303");
@joepie91
joepie91 / random.md
Last active Dec 10, 2019
Secure random values (in Node.js)
View random.md

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@lukin0110
lukin0110 / GulpReactBrowserifyBabelify.md
Last active Aug 7, 2019
Gulp + browserify + babelify + react
View GulpReactBrowserifyBabelify.md

Use React with Gulp, Browserify and Babelify. This allows you to use React in jsx & node.js style. It let's you use require('module') in your JavaScript. Babelify will transform the jsx code to JavaScript code.

Development

gulp build-react

This will generate a main.min.js file in the build directory with sourcemaps.

Production

View pbkdf2dotnetsample.cs
public class PasswordHash
{
public const int SaltByteSize = 24;
public const int HashByteSize = 20; // to match the size of the PBKDF2-HMAC-SHA-1 hash
public const int Pbkdf2Iterations = 1000;
public const int IterationIndex = 0;
public const int SaltIndex = 1;
public const int Pbkdf2Index = 2;
public static string HashPassword(string password)
View ConfusedDDD.fs
module Person =
open System
type PersonState = private { id: Guid; name: string; age: int}
let createPerson id name age = {id = id; name = name; age = age}
let changeName name personState = {personState with name = name}
let changeAge age personState =
// some crazy business rule involving age
{personState with age = age}
module SomeOtherModule =
View nextTick.js
// Only add setZeroTimeout to the window object, and hide everything
// else in a closure.
(function() {
var timeouts = [];
var messageName = "zero-timeout-message";
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
function setZeroTimeout(fn) {
@cojocar
cojocar / tomato-static-mac.md
Last active Oct 31, 2018
Set a fixed MAC address on a TAP interface (OpenVPN client) on Tomato Firmware 1.28.0000 MIPSR2-101 K26 USB AIO-64K and maybe on others
View tomato-static-mac.md

How to set a fixed MAC address on a TAP interface (OpenVPN client) on Tomato Firmware

Problem

Using the lladdr 00:11:22:33:44:55 option in the OpenVPN client custom configuration form doesn't change the MAC of the tap interface.

Solution

Paste this in the custom configuration box:

script-security 2
You can’t perform that action at this time.