Skip to content

Instantly share code, notes, and snippets.

When /^the process job workers run$/ do
while job = Resque.reserve(:data_extraction_process_queue)
job.perform
end
end
@fields
fields / server.js
Created July 31, 2012 19:25
mongo / socket.io / node.js / express
//var io = require('socket.io');
var express = require('express')
, stylus = require('stylus')
, http = require('http')
, nib = require('nib');
var app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server);
@fields
fields / limits.conf
Last active December 15, 2015 02:48
/etc/security/limits.conf
* - nofile 65535
mongod - nproc 65535
@fields
fields / mongod
Created March 18, 2013 18:30
/etc/init.d/mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongo/mongo.pid
@fields
fields / gist:5189677
Created March 18, 2013 18:43
script for checking ulimits
return-limits(){
for process in $@; do
process_pids=`ps -C $process -o pid --no-headers | cut -d " " -f 2`
if [ -z $@ ]; then
echo "[no $process running]"
else
for pid in $process_pids; do
echo "[$process #$pid -- limits]"
cat /proc/$pid/limits
done
@fields
fields / Vagrantfile
Created May 20, 2013 15:48
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# override these variables in ~/.vagrant.d/Vagrantfile for your local changes
$local_username ||= `whoami`.strip
$local_projects_directory ||= "~/projects/vagrant/"
$vm_memory ||= "4096"
$vm_cpus ||= "4"
$server_root_password = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
@fields
fields / send_mail_to_reminders.scpt
Created September 17, 2013 13:25
applescript to create reminders from mail in mountain lion
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
set theText to "This AppleScript is intended to be used as an AppleScript rule action, but is also an example of how to write scripts that act on a selection of messages or mailboxes." & return & return & "To view this script, hold down the option key and select it again from the Scripts menu."
repeat with eachMessage in theMessages
set theSubject to subject of eachMessage
set theBody to content of eachMessage
try
-- If this is not being executed as a rule action,
-- getting the name of theRule variable will fail.
@fields
fields / speedtest_mongo.rb
Created November 18, 2013 18:51
speedtest_mongo.rb
#!/usr/bin/env ruby
require 'yajl'
require 'mongo'
speedtest_json = `/path/to/speedtest-cli --json`
begin
if speedtest_json.nil? or speedtest_json == ""
raise Yajl::ParseError
@fields
fields / make_gemfile_from_gems.rb
Created April 1, 2014 13:37
make a Gemfile from currently installed gems
#!/usr/bin/env ruby
gems = `gem list`
puts "source https://rubygems.org"
gems.each_line{|line|
(gem, versions) = line.split(' ')
highest_version = versions.split(',').first.gsub(/[\(\)]/, '')
puts "gem '#{gem}', '#{highest_version}'"
}
@fields
fields / session_rename.sh
Created January 5, 2016 19:41
Bash script to rename the current window
#!/bin/bash
echo -n -e "\033]0;$1\007"