Skip to content

Instantly share code, notes, and snippets.

View aarti's full-sized avatar
🎯
Focusing

aarti

🎯
Focusing
  • San Francisco Bay Area
View GitHub Profile
<cluster-user>admin</cluster-user>
<cluster-password>mypassword</cluster-password>
@matthewlehner
matthewlehner / autopgsqlbackup
Created July 11, 2012 16:10
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@jboner
jboner / latency.txt
Last active May 13, 2025 17:54
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
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 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@rklemme
rklemme / BitSet.rb
Last active October 5, 2015 07:58
Basis for a bit set which uses String as storage. Storage is split up into multiple String instances to avoid too large allocations.
#!/usr/bin/ruby
# Implementation of a bit set which stores membershio in binary
# Strings managed in chunks.
class BitSet
ZERO = "\000".encode(Encoding::BINARY).freeze
DEFAULT_SEGMENT_SIZE = 1024 * 1024
# Create the BitSet instance. If max_num is given, we preallocate
# as much memory as needed.
@nathanaschbacher
nathanaschbacher / sudo_env_output
Created March 13, 2012 20:10
Torquebox 2.x errors trying to daemonize the gem install (sudo jruby -S rake torquebox:upstart:start)
GEM_HOME=/usr/local/rvm/gems/jruby-1.6.7
TERM=xterm-256color
JBOSS_HOME=/usr/local/rvm/gems/jruby-1.6.7@global/gems/torquebox-server-2.0.0.cr1-java/jboss
PATH=/usr/local/rvm/gems/jruby-1.6.7/bin:/usr/local/rvm/gems/jruby-1.6.7@global/bin:/usr/local/rvm/rubies/jruby-1.6.7/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
JRUBY_HOME=/usr/local/rvm/rubies/jruby-1.6.7
LANG=en_US.UTF-8
TORQUEBOX_HOME=/usr/local/rvm/gems/jruby-1.6.7@global/gems/torquebox-server-2.0.0.cr1-java
GEM_PATH=/usr/local/rvm/gems/jruby-1.6.7:/usr/local/rvm/gems/jruby-1.6.7@global
JRUBY_OPTS=--1.9
SHELL=/bin/bash
15:39:06,062 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "current-knob.yml"
15:39:06,639 INFO [org.torquebox.core.runtime] (Thread-109) Initialize? true
15:39:06,639 INFO [org.torquebox.core.runtime] (Thread-109) Initializer=org.torquebox.web.rack.RackRuntimeInitializer@7df86f75
15:39:06,979 INFO [org.torquebox.core.runtime] (Thread-109) Setting up Bundler
15:39:08,138 INFO [stdout] (Thread-109) Could not find rake-0.8.7 in any of the sources
15:39:08,138 INFO [stdout] (Thread-109) Run `bundle install` to install missing gems.
15:39:08,139 ERROR [org.torquebox.core.runtime] (Thread-109) Error during evaluation: require %q(bundler/setup): org.jruby.exceptions.RaiseException: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:856) [jruby.jar:]
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:825) [jruby.jar:]
at (Anonymous).(root)(/opt/torquebox-current/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/setup.rb:14) at org.jruby.RubyK
@slok
slok / jboss_apache.md
Created December 31, 2011 09:06
Setup for jboss 7 with apache and mod_cluster in ubuntu 11.10

Preparing Jboss environment

Create Jboss user and group

Create a group for a system user (daemnos and program users like www-data, mysql...)

# addgroup --system jboss

Create a user (system user, without home -> See below the command, to the jboss group and no login shell)

@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@3dd13
3dd13 / ruby_ftp_example.rb
Created November 5, 2011 17:08
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@exoer
exoer / db_server.rb
Created July 4, 2011 17:58 — forked from coderanger/db_server.rb
Create postgres users and databases from Chef
include_recipe "postgresql::server90"
# inspiration from
# https://gist.github.com/637579
execute "create-root-user" do
code = <<-EOH
psql -U postgres -c "select * from pg_user where usename='root'" | grep -c root
EOH
command "createuser -U postgres -s root"