Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
def find_deps(cookbook_dir)
nel = Hash.new { |h, k| h[k] = [] }
Dir.glob("#{cookbook_dir}/*/").each do |r|
deps_for(r, nel)
end
nel
end
@fujin
fujin / 8_vol_ebs_stripeset.rb
Created November 24, 2010 21:48
automatic 8 vol ebs LVM2 stripe set (raid0). 256k chunks, 8-way stripe. 65k readahead.
include_recipe "aws"
include_recipe "lvm"
include_recipe "xfs"
esvg = node.elasticsearch.ebs.lvm.volume_group
eslv = node.elasticsearch.ebs.lvm.logical_volume
Chef::Log.info "ElasticSearch: setting up 8 100G EBS volumes"
aws = data_bag_item("aws", node.app_environment)
8.times do |d|
disk = (d == 0 ? "/dev/sdi" : "/dev/sdi#{d}")
@mperham
mperham / Go.txt
Created September 22, 2011 19:38
Network stack performance
> ab -n 10000 -c 100 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1139530 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@psebborn
psebborn / countCSSRules.js
Last active April 25, 2023 11:43
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {

Node.js Resources

What is node.js?

Node.js is just JavaScript running on the server side. That's it. That's all there is to it.

Express

  • Express Docs, if you want to get started and already know JavaScript this is the place to be
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
#!/bin/sh
# INSTALL
wget -O- http://hydra.nixos.org/build/4253979/download/1/nix-1.5.1-x86_64-linux.tar.bz2 \
| tar xj -C /
sudo -i nix-finish-install
# DEFAULT PROFILE
ln -sf /nix/var/nix/profiles/default/etc/profile.d/nix.sh \
/etc/profile.d/nix.sh
@dysinger
dysinger / boto-with-gnu-parallel.md
Last active August 29, 2015 13:56
Boto w/ GNU-Parallel for Reports & Actions

Using Boto & GNU-Parallel Together

For mass destruction (j/k I mean powerful data gathering)

Useful Prelude of Functions

# Activate the gem you are reporting the issue against.
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do