Skip to content

Instantly share code, notes, and snippets.

Dan MacTough danmactough

Block or report user

Report or block danmactough

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
@danmactough
danmactough / second-boot.sh
Created Jul 31, 2015
Setting up a gpu (nvidia) ec2 instance with ubuntu and electron for headless webgl rendering
View second-boot.sh
#!/bin/bash -xe
# Unload nouveau
sudo rmmod nouveau
# Load nvidia
sudo modprobe nvidia
# Configure X
sudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0 --enable-all-gpus
@rvagg
rvagg / gist:96c959b7c31eedfa2c5c
Last active Aug 29, 2015
100 most downloaded npm packages for the period 6-Jul-2014 to 6-Aug-2014
View gist:96c959b7c31eedfa2c5c
1: async (5,306,139)
2: mkdirp (3,989,808)
3: request (3,822,748)
4: glob (3,750,793)
5: minimatch (3,476,898)
6: commander (3,475,471)
7: debug (3,454,917)
8: qs (3,372,442)
9: inherits (3,105,353)
10: graceful-fs (3,005,257)
@JamieMason
JamieMason / annotated-jshintrc.txt
Created Jun 13, 2014
An annotated .jshintrc file, based on the docs at http://jshint.com/docs/options.
View annotated-jshintrc.txt
{
/**
* Tell JSHint about global variables.
*/
"predef": [
// https://github.com/pivotal/jasmine
"after",
"afterEach",
@mikeal
mikeal / install.bash
Last active Aug 29, 2015
Find and install latest node from source on Ubuntu.
View install.bash
#!/bin/bash
echo "Finding latest version."
VERSION=`curl -s http://nodejs.org/dist/latest/SHASUMS.txt | awk '/node-v/ {print $2}' | head -1 | sed s/node-v// | sed s/-/\ / | awk '{print $1}'`
echo "Preparing to install node-v$VERSION"
url="http://nodejs.org/dist/v"$VERSION"/node-v"$VERSION".tar.gz"
echo "GET" $url
curl $url | tar -zxf -
@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active Aug 8, 2019
Quick steps of how to create a flame graph using perf
View perf-flame-graph-notes.md

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@insin
insin / BootstrapModalMixin.js
Last active Mar 25, 2019
A Bootstrap (3) modal mixin for React / MIT License
View BootstrapModalMixin.js
/** @jsx React.DOM */
var BootstrapModalMixin = function() {
var handlerProps =
['handleShow', 'handleShown', 'handleHide', 'handleHidden']
var bsModalEvents = {
handleShow: 'show.bs.modal'
, handleShown: 'shown.bs.modal'
, handleHide: 'hide.bs.modal'
@sindresorhus
sindresorhus / post-merge
Last active Aug 22, 2019
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
View post-merge
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
View waitforit.js
// Optional `options. Stuff like retry count, ramp-up, etc.
// should have sane defaults.
var wait = waitforit(options, function (cb) {
// This would be the 'test' function.
// cb(true) when 'it' is done.
});
wait.on('ready', function () {
// Do something because the test condition passed.
@rektide
rektide / writing-code.md
Last active Dec 15, 2015
Promises are about Getting Rid of a Phase Distinction - A crude guide to what makes Promises Actually Different than every other tool.
View writing-code.md

A promise is a value, and values are by definition not machines.

Phase Distinctions, Machines, Higher Order Functions,

Tools for composing systems

In CS: a phase distinction is a boundary code goes through on it's way to being run. We write the prime artifact, "the code," but to run a machine, this code is transformed by machines, often many machines transforming, taking whatever the current code is, making decisions about what that code looks like, what it represents, and outputting a new code closer to the final execution target. This is the compilation pipeline goes go through to get executed on the target machine. Phase distinction is applied to types, as types change as code goes through the pipeline, but in general all aspects of the code are going through phasal distinctions as they become closer to being run.

Higher order functions: composing complexity

Async- the most popular library on the planet for helping to deal with functional programming- is a library dedicated to composing functio

View domain-cluster-example.js
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
You can’t perform that action at this time.