Skip to content

Instantly share code, notes, and snippets.

View overra's full-sized avatar
😀

Adam Snodgrass overra

😀
View GitHub Profile
@overra
overra / gist:1638573
Created January 19, 2012 07:25
Turntable Room & Room manager loader
(function(cb){
var log = function(a) { if (DEBUG_MODE) { console.log(a) } }
log('Looking for room & room manager..')
if (!turntable.room) {
for (i in turntable) {
if (turntable[i]&&turntable[i].selfId) { log('Found room'); turntable.room = turntable[i]; }
}
}
if (turntable.room&&!turntable.room.manager) {
for (i in turntable.room) {
@overra
overra / gist:3458721
Created August 25, 2012 01:57
Export Turntable Playlist Text
// Put this in the address bar on the turntable page
/* minified */
javascript:(function(){var e=turntable.playlist.songsByFid,t=[];for(var n in e){var r=e[n].metadata;t.push(r.artist+" - "+r.song+"\n")}window.prompt("Songs - Copy Input",t.join(""))})()
/* original */
(function() {
var songs=turntable.playlist.songsByFid, Songs=[];
for (var i in songs) {
var song = songs[i].metadata;
for (var i = 0; i < states.length; i++) {
var state = states[i];
var theBlob = "";
stateEvents[state.Abbr] = (function (state, i) {
return function (event, data) {
for(var key in state) {
var attrName = key;
var attrValue = state[key];
theBlob += attrName + ': ' + attrValue + '<br>';
}

FreeBSD 10 Nodejs setup with nginx, mongodb, redis and monit

This my receipe for installing a complete nodejs server on FreeBSD 10. The parameters used in this configuration are for a very small private server that I use for demo purpose only, so for a production server, you should somehow set the limits in pair with your ressources.

I use monit so I don't have to write rc scripts for node and it should take care of process lifecycle management for me. Alternatives exists such as supervisord or circus.

Installing mongodb

Keybase proof

I hereby claim:

  • I am overra on github.
  • I am overra (https://keybase.io/overra) on keybase.
  • I have a public key whose fingerprint is F1C9 80A7 936F 9455 1AEF 23F7 DA61 37C8 BC93 90DA

To claim this, I am signing this object:

Verifying that +overra is my openname (Bitcoin username). https://onename.com/overra
@overra
overra / big-city-population.js
Last active January 31, 2016 08:14
Determine how many US citizens live in major cities.
/*
For use on: https://en.wikipedia.org/wiki/List_of_United_States_cities_by_population
This gathers population of each major city and returns the sum.
Execute the following code in the developer console.
*/
var columns = $('table.sortable:nth(0) tr td:nth-of-type(4)').toArray();
columns.reduce(function(sum, el) {
var pop = $(el).text().replace(/\,/g, '');
@overra
overra / index.html
Last active February 1, 2017 00:16
for loop vs Array#forEach vs forEach #jsbench #jsperf (https://jsbench.github.io/#e3a637845badddf44c18239c8ef7a3cc) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>for loop vs Array#forEach vs forEach #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@overra
overra / a.js
Last active December 30, 2018 21:41
test gist
foo = () => {}
s
s
s
s
@overra
overra / foo.js
Last active December 30, 2018 22:31
console.log('hello world');