Skip to content

Instantly share code, notes, and snippets.

View sourcec0de's full-sized avatar
:octocat:
Focusing

James R Qualls sourcec0de

:octocat:
Focusing
View GitHub Profile
@sourcec0de
sourcec0de / global-variables-are-bad.js
Created November 22, 2012 00:17 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@sourcec0de
sourcec0de / gist:4223972
Created December 6, 2012 12:06 — forked from olistik/gist:2627011
Ubuntu 12.10 setup (rbenv/rvm, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
sudo apt-get install xclip
@sourcec0de
sourcec0de / README.md
Created December 13, 2012 07:28 — forked from fnichol/README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

Install Redis 2.6 as a Service on Ubuntu

  1. Install Ubuntu updates, set time zones, followed by GCC and Make
sudo apt-get update
sudo apt-get -y install build-essential
  1. Install tcl8.5 for Redis
/* sample aggregate command queries */
// make sure we're using the right db; this is the same as "use mydb;" in shell
db = db.getSisterDB("aggdb");
// just passing through fields
var p1 = db.runCommand(
{ aggregate : "article", pipeline : [
{ $project : {
tags : 1,
pageViews : 1
var cluster = require('cluster'),
app = require('./app');
var workers = {},
count = require('os').cpus().length;
function spawn(){
var worker = cluster.fork();
workers[worker.pid] = worker;
return worker;
@sourcec0de
sourcec0de / es.sh
Last active December 16, 2015 03:09
Download and install elasticSearch 0.90.0 as a service.
echo "This script requires superuser access to install apt packages."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
cd ~
sudo sh <<SCRIPT
apt-get update
apt-get install openjdk-7-jre-headless -y
sudo add-apt-repository ppa:webupd8team/sublime-text-2 && sudo apt-get update && sudo apt-get install sublime-text && sudo ln -s /usr/lib/sublime-text-2/sublime_text /usr/local/bin/sublime
@sourcec0de
sourcec0de / phantomInstall.sh
Last active December 17, 2015 18:39 — forked from shapeshed/gist:5433860
install phantomJS on ubuntu 13 x64
cd /usr/local/share
sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
sudo tar -xjf phantomjs-1.9.0-linux-x86_64.tar.bz2
sudo ln -sf /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
sudo rm /usr/local/share/phantomjs-1.9.0-linux-x86_64.tar.bz2
phantomjs --version
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost:8080/_search?q=*
#
# is rewritten to:
#