Skip to content

Instantly share code, notes, and snippets.

View surjikal's full-sized avatar
👁️‍🗨️

Nick Porter surjikal

👁️‍🗨️
  • CTO @ 42
  • Oakland
View GitHub Profile
@surjikal
surjikal / graphite.md
Created May 17, 2012 18:14 — forked from caged/graphite.md
Installing Graphite on OS X Lion

Follow these steps to install graphite on OS X Lion.

Prerequisites

  • Python 2.7
  • Brew
  • Git

Install dependencies

Install Cairo

@surjikal
surjikal / monitoring-stack-ubuntu-precise.md
Created May 23, 2012 21:18
Installing a complete monitoring stack on Ubuntu 12.04

Follow these steps to install Graphite on a fresh Ubuntu 12.04 instance. Make sure you read and understand the commands because by the time you read this, things could be outdated.

Graphite

Installing dependencies

# apt-get install libpq-dev
# apt-get install python-dev python-pip python-cairo python-psycopg2
# apt-get install python-django python-django-tagging

Access remote port from local machine:

ssh -f -L <local_port>:localhost:<remote_port> <remote_host> -N

Execute command on file/dir change:

watchmedo shell-command --patterns="*.rmd" --command="Rscript compile.rscript"

What is Diamond?

https://github.com/BrightcoveOS/Diamond

From their wiki:

Diamond is a python daemon that collects system metrics and publishes them to Graphite. It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.

Deps

apt-get install build-essentials
apt-get install python-dev

To get htaccess like user authentication on Nginx, add the following to your site config:

auth_basic            "Restricted";
auth_basic_user_file  <password_file_location>;

If you want the authentication to be applied on all locations, place it in the top scope of the config. If you want it specific to a location, just add it in the scope of that location.

Creating a password file

@surjikal
surjikal / jquery.getstyleobject.js
Created June 27, 2012 21:57
jQuery - Get styles of an element
// Taken from http://upshots.org/javascript/jquery-copy-style-copycss
(function($) {
$.fn.getStyleObject = function() {
var dom = this.get(0);
var style;
var returns = {};
@surjikal
surjikal / restore_username_hashes.py
Created July 29, 2012 18:52
Script to restore the username hashes off django-email-as-usernames after ./manage.py dumpdata/loaddata
from django.core.management import setup_environ
import settings
setup_environ(settings)
######################################################################################
from django.contrib.auth.models import User
from django.core.validators import email_re
from emailusernames.utils import _email_to_username as create_username_hash_from_email
。◕‿◕。
ヽ(゜∇゜)ノ
(ノಠ益ಠ)ノ彡┻━┻
(づ。◕‿‿◕。)づ
(´・ω・`)
٩(͡๏̯͡๏)۶
(▮◡▮)❤
(⊛ี௮⊛ี)
(☺♭☺)
⋙(≗ิ⊽≗ิ)⋘
@surjikal
surjikal / decorators.js
Created October 23, 2012 16:44
Javascript Tests
function decorator(fn) {
function wrapper() {
console.log('Before function.');
var ret = fn.apply(this, arguments);
console.log('After function.');
return ret;
}
return wrapper;
@surjikal
surjikal / fetch-libs.sh
Created November 11, 2012 11:12
Fetch client-side dependencies for a static site
#!/bin/sh
LIBS_DIR="./src/scripts/libs"
COLOR_RED="\033[0;31m"
COLOR_PURPLE="\033[0;35m"
COLOR_BRIGHT_PURPLE="\033[1;35m"
COLOR_GREEN="\033[0;32m"
COLOR_RESET="\033[0m"