Skip to content

Instantly share code, notes, and snippets.

View lancejpollard's full-sized avatar
😍
Lots of coding

Lance Pollard lancejpollard

😍
Lots of coding
View GitHub Profile
@taterbase
taterbase / system-beep.js
Created July 21, 2012 05:01
System Beep in Node.js
function alertTerminal(){
console.log("\007");
}
@joelpt
joelpt / squirt.js
Created October 2, 2012 23:41
Manually calculate the square root of a number with Javascript
// The Babylonian Method
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
function squirt(n, g) {
if (!g) {
// Take an initial guess at the square root
g = n / 2.0;
}
var d = n / g; // Divide our guess into the number
@max-mapper
max-mapper / index.js
Created October 30, 2012 03:15
twitter bot for @sandyaid retweets
var crypto = require('crypto')
var request = require('request')
var url = require('url')
var irc = require('./IRC/lib/irc') // https://github.com/gf3/IRC-js
var ntwitter = require('ntwitter')
var twitter = require('twitter')
var qs = require('querystring')
// separate accounts to post and search because twitter was sending me 500s
// when I tried to use the same oauth creds for both twitter() and ntwitter()
/**
* Mark and Sweep Garbage Collection technique.
* MIT Style License
* by Dmitry Soshnikov
*/
// This diff describes the simplest version of mark and sweep
// GC in order to understand the basic idea. In real practice the
// implementation can be much tricker and optimized.
@heapwolf
heapwolf / npm-qos-heuristic.md
Last active December 11, 2015 10:38
general heuristics for ranking package quality

Health

Has CI

Tests pass

Total number of breaking commits

Number of dependencies

Average age of issue

Frequency of issues fixed

Average response time of issues fixed to bugs filed

Last commit

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@DmitrySoshnikov
DmitrySoshnikov / reference-counting-gc.js
Last active September 30, 2022 00:19
Reference counting GC
/**
* Automatic Reference Counting (ARC) Garbage Collection technique.
*
* This diff describes Reference counting GC technique.
* See also previous lesson on Mark and Sweep GC:
* https://gist.github.com/4391763
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style License
*/
@thomasmassmann
thomasmassmann / chef.conf
Last active December 11, 2015 23:18
Install a chef server on debian with fabric.
upstream chef_server {
server 127.0.0.1:4000 fail_timeout=0;
}
upstream chef_server_webui {
server 127.0.0.1:4040 fail_timeout=0;
}
server {
listen 443 default ssl;
@dherman
dherman / explanation.txt
Last active December 13, 2015 04:59
demonstrating that lexing JavaScript requires a pushdown automaton
Looking at the preceding token when the lexer points to a '/'
character is insufficient to determine which context it's in. In
fact, you need to look at an arbitrary number of preceding tokens
to figure it out. This example demonstrates a case where we can
pump up the number of preceding tokens to an arbitrary size
before you can disambiguate your syntactic context.
@mharsch
mharsch / gist:5188206
Last active February 8, 2024 02:43
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory