Skip to content

Instantly share code, notes, and snippets.

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

Nick Porter surjikal

👁️‍🗨️
  • CTO @ 42
  • Oakland
View GitHub Profile
var app = angular.module('converter', []);
app.directive('converter', function(converters) {
return {
require: 'ngModel',
link: function(scope, element, attr, ngModel) {
var converter = converters[attr.converter];
ngModel.$formatters.unshift(converter.formatter);
ngModel.$parsers.push(converter.parser);
},
@surjikal
surjikal / app.coffee
Last active August 29, 2015 14:02
Sears Hackathon
_ = require 'lodash'
ent = require 'ent'
assert = require 'assert'
Promise = require 'bluebird'
SearsAPI = require './sears-api'
CONSUMER_KEY = '<your key here>'
@surjikal
surjikal / sudoku.coffee
Last active August 29, 2015 14:05
Sudoku Solver
# board = [
# 1,2,3,4,5,6,7,8,9
# 4,5,6,1,7,8,3,3,3
# 7,8,9,2,2,2,1,4,5
# 3,5,6,7,8,9,9,9,9
# 1,4,9,3,6,6,6,6,6
# 7,7,7,1,4,5,3,3,3
# 2,4,5,8,8,8,8,8,8
# 1,7,7,2,5,5,5,5,5
# 7,7,7,4,1,1,null,null,null
@surjikal
surjikal / gentoo-minicron.md
Last active August 29, 2015 14:06
gentoo-minicron.md

Repo URL:
https://github.com/jamesrwhite/minicron

Info

The idea here is that one server holds the "hub", aka the Minicron server. The other servers are simply clients. We use ssh tunneling from clients to communicate with the server. The server should be able to ssh into the client machines, in order to modify the client's crontab. We add public keys with a prefix that only allow root ssh access from a single IP (the server's IP).

package main
import (
"path/filepath"
"os"
"flag"
"fmt"
"time"
)

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 / 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
。◕‿◕。
ヽ(゜∇゜)ノ
(ノಠ益ಠ)ノ彡┻━┻
(づ。◕‿‿◕。)づ
(´・ω・`)
٩(͡๏̯͡๏)۶
(▮◡▮)❤
(⊛ี௮⊛ี)
(☺♭☺)
⋙(≗ิ⊽≗ิ)⋘