Skip to content

Instantly share code, notes, and snippets.

View aputs's full-sized avatar

Allan Ralph Hutalla aputs

  • Earth
  • Philippines
View GitHub Profile
@defunkt
defunkt / god.rb
Created November 18, 2008 18:04 — forked from mojombo/gist:26183
rails_root = "/data/github/current"
20.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
w.uid = 'git'
@peo3
peo3 / setup_lxc_rootfs_fedora15.sh
Created August 12, 2011 14:52
How to boot up Fedora 15 with systemd inside Libvirt LXC
#!/bin/sh
# Setup a rootfs of Fedora 15 for libvirt lxc
#
# The rootfs is based on http://download.openvz.org/template/precreated/fedora-15-x86_64.tar.gz
#
# See also
# - http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01707/lxc-fedora.in
if [ $# != 1 ]; then
@pda
pda / unicorn.rake
Created September 12, 2011 07:39
Rake tasks for Unicorn: start stop restart increment decrement pstree
namespace :unicorn do
##
# Tasks
desc "Start unicorn"
task(:start) {
config = rails_root + "config/unicorn.rb"
sh "bundle exec unicorn --daemonize --config-file #{config}"
}
@hectoregm
hectoregm / gist:1401897
Created November 28, 2011 20:30
Regexp, Ruby and You

Regular Expressions: The Good Parts (Ruby Edition)

Introduction

So what are regular expressions?, Wikipedia has a nice [definition][1]:

Regular expressions provides a concise and flexible means for "matching" (specifying and recognizing) strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp".

@nherment
nherment / backup.sh
Created February 29, 2012 10:42
Backup and restore an Elastic search index (shamelessly copied from http://tech.superhappykittymeow.com/?p=296)
#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`
@bennylope
bennylope / LICENSE
Last active August 17, 2023 10:44
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
Copyright the authors of Honcho and/or Ben Lopatin
Licensed for reuse, modification, and distribution under the terms of the MIT license
@yoneken
yoneken / remove_CLI_tools.sh
Created August 7, 2012 11:03
Xcode Command Line Tools Uninstaller
# remove_CLI_tools.sh
# written by cocoanetics:http://www.cocoanetics.com/2012/07/you-dont-need-the-xcode-command-line-tools/
# modified by yoneken
#!/bin/sh
RECEIPT_FILE1=/var/db/receipts/com.apple.pkg.DevSDK.bom
RECEIPT_PLIST1=/var/db/receipts/com.apple.pkg.DevSDK.plist
RECEIPT_FILE2=/var/db/receipts/com.apple.pkg.clang.bom
RECEIPT_PLIST2=/var/db/receipts/com.apple.pkg.clang.plist
@twobitfool
twobitfool / create-smartos-vm.sh
Last active May 28, 2023 01:51
Create a SmartOS VM in VirtualBox
#!/bin/sh
#
# Creates a SmartOS VM in VirtualBox (assuming you alread have VirtualBox installed)
#
# This script will:
# * Download the latest live ISO image of SmartOS
# * Create a VirtualBox VM, or update an existing VM with the latest ISO
# * Configure the VM with a zones disk, and boot it!
#
#
@bshamric
bshamric / cache.js
Last active January 24, 2021 12:08
I like phantomjs, but it doesn't directly support getting images from webpages without requesting them separately like in casperjs. I went through QTNetworking code in the phantomjs repo until I figured out where the cache was. To use this, have all three files in the same directory. Then modify test.js for whatever you need. Call phantom js wit…
var fs = require('fs');
//this is the path that QTNetwork classes uses for caching files for it's http client
//the path should be the one that has 16 folders labeled 0,1,2,3,...,F
exports.cachePath = '/path/to/phantomjs/cache/data/folder';
//this is the extension used for files in the cache path
exports.cacheExtension = "d";
//the resources that are to be saved
@phette23
phette23 / current-dir-in-iterm-tab-title.sh
Last active January 4, 2024 10:20
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html