Skip to content

Instantly share code, notes, and snippets.

@ashayh
ashayh / autobackupmongo.rb
Created November 10, 2012 01:38 — forked from lajunta/autobackupmongo.rb
auto backup mongo (ruby version and very concise)
#!/usr/local/ruby/bin/ruby -w
Dbpath = "/data/db" # database path
Backpath = "/data/dbbackup" # backup directory
Host = "" # mongo host to connect,empty is for local
Database = "" # database to use. empty is for all
Collection = "" # collection to use
User = ""
Passwd = ""
Now = Time.now
DATE = Now.strftime("%Y-%m-%d")
@ashayh
ashayh / latency.txt
Created November 14, 2012 04:58 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@ashayh
ashayh / bind_conf.treetop
Created December 3, 2012 22:41 — forked from mat813/bind_conf.treetop
simple named.conf parsing
require 'ip'
grammar BindConf
include IP
rule entries
(zone / key / server)* {
%w(zone key server).each do |i|
module_eval <<-eot, __FILE__, __LINE__+1
def each_#{i}(&block)
@ashayh
ashayh / .gitignore
Created December 20, 2012 22:39 — forked from karmi/.gitignore
.DS_Store
Gemfile.lock
*.pem
node.json
tmp/*
!tmp/.gitignore
@ashayh
ashayh / firedns.js
Created January 16, 2013 01:27 — forked from vikrum/firedns.js
var crypto = require('crypto');
var dns = require('native-dns');
var rest = require('restler');
var server = dns.createServer();
server.on('request', function (request, response) {
var domain = request.question[0].name;
if(domain == 'webutils.flourishworks.com') {
// Don't log this because it can't be uniquely identified and subsequently retrieved
@ashayh
ashayh / dnsd.rb
Created January 16, 2013 01:27 — forked from peterc/dnsd.rb
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@ashayh
ashayh / firedns.js
Created January 16, 2013 01:31 — forked from vikrum/firedns.js
var crypto = require('crypto');
var dns = require('native-dns');
var rest = require('restler');
var server = dns.createServer();
server.on('request', function (request, response) {
var domain = request.question[0].name;
if(domain == 'webutils.flourishworks.com') {
// Don't log this because it can't be uniquely identified and subsequently retrieved
- Tune /etc/ssh/sshd_config
UseDNS no # Disable DNS lookups
GSSAPIAuthentication no # Disable negotation of slow GSSAPI
don't forget to restart it, use a script provider to set it , or create it with veewee or snapshot it
- Tune Vagrantfile
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
@ashayh
ashayh / pre-commit
Created February 20, 2014 19:54 — forked from fluxrad/pre-commit
#!/bin/bash
# pre-commit git hook to check the validity of a puppet manifest
#
# Prerequisites:
# gem install puppet-lint puppet
#
# Install:
# /path/to/repo/.git/hooks/pre-comit
# Source RVM if needed
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(