Skip to content

Instantly share code, notes, and snippets.

@vertis
vertis / dependencies.sh
Created January 25, 2013 04:16
Generate gem dependencies. You need to have graphviz installed
#!/usr/bin/env bash
if [ $# -eq 0 ] ; then
printf "%s\n" "no args given, exiting"
exit 1
fi
export TMP_GEM_PATH=/tmp/$1
mkdir -p
GEM_HOME=$TMP_GEM_PATH GEM_PATH=$TMP_GEM_PATH gem install $1
GEM_HOME=$TMP_GEM_PATH GEM_PATH=$TMP_GEM_PATH gem list \
| cut -d\ -f1 \
BOX_NAME=vagrant-build
BASE_DIR="`pwd`/machines"
BOX_DIR="${BASE_DIR}/${BOX_NAME}"
mkdir -p ${BASE_DIR}
VBoxManage createvm --name "${BOX_NAME}" --ostype RedHat_64 --basefolder ${BASE_DIR}
VBoxManage registervm "${BOX_DIR}/${BOX_NAME}.vbox"
mkdir -p tmp
@vertis
vertis / rbenv-install-system-wide.sh
Created August 9, 2012 03:29 — forked from v1nc3ntlaw/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p194 on Debian 6 Squeeze
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl libssl-dev \
libreadline5 libreadline5-dev \
zlib1g zlib1g-dev \
libmysqlclient-dev \
libcurl4-openssl-dev \
libxslt-dev libxml2-dev
@vertis
vertis / rbenv-install-system-wide.sh
Created July 25, 2012 06:03 — forked from jpfuentes2/rbenv-install-system-wide.sh
CentOS: rbenv install and system wide install
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@vertis
vertis / rbenv-install-system-wide.sh
Created May 4, 2012 10:19
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@vertis
vertis / gauges_tracking.rb
Created March 2, 2012 01:53
Gauges tracking code in ruby
before_filter :track
...
private
def track
headers = request.headers
query = {"h" => {}}
query["h"]["site_id"]=Settings.gauges_site_id
query["h"]["resource"]="http://#{headers['HTTP_HOST']}/#{headers['REQUEST_PATH']}" # REQUEST_URI seems to be incorrect
@vertis
vertis / samba.3.6.3.osx-getgrouplist.patch
Created February 23, 2012 13:30 — forked from lasombra/samba.3.6.1.osx-getgrouplist.patch
_SC_NGROUPS_MAX cannot be used with getgrouplist on OS X
--- a/source3/lib/system.c 2012-02-22 22:46:14.000000000 -0200
+++ b/source3/lib/system.c 2012-02-22 22:47:51.000000000 -0200
@@ -1161,7 +1161,14 @@
int groups_max(void)
{
-#if defined(SYSCONF_SC_NGROUPS_MAX)
+#if defined(DARWINOS)
+ /* On OS X, sysconf(_SC_NGROUPS_MAX) returns 16
+ * due to OS X's group nesting and getgrouplist
@vertis
vertis / rename_rails3.rb
Created January 24, 2012 21:27
Simple script that can be used to rename a rails3 app
#!/usr/bin/env ruby
require 'fileutils'
require 'tempfile'
def replace_in_file(filename,oldvalue,newvalue)
temp_file = Tempfile.new(File.basename(filename))
contents = File.read(filename)
changed_contents = contents.gsub(oldvalue,newvalue).gsub(oldvalue.downcase,newvalue.downcase)
temp_file.print(changed_contents)
begin
descriptors = []
files = []
ARGV.each do |filename|
io = IO.sysopen(filename, 'r')
descriptors << io
i = IO.open(io)
i.seek(0, IO::SEEK_END) # TODO: go back a few lines so we have context
files << i
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWindows {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello, world!");