Skip to content

Instantly share code, notes, and snippets.

View constantine-nikolaou's full-sized avatar

Constantine Nikolaou constantine-nikolaou

View GitHub Profile
@constantine-nikolaou
constantine-nikolaou / git reset --hard HEAD ; git pull --rebase origin 2.0.0pre
Created June 14, 2011 11:41
git reset --hard HEAD ; git pull --rebase origin 2.0.0pre
(14:38) user:~/dev/rubinius(master)$ git reset --hard HEAD ; git pull --rebase origin 2.0.0pre
HEAD is now at 9175c06 Merge pull request #1014 from apotheon/master
remote: Counting objects: 8015, done.
remote: Compressing objects: 100% (3301/3301), done.
remote: Total 7234 (delta 4511), reused 6178 (delta 3695)
Receiving objects: 100% (7234/7234), 3.40 MiB | 51 KiB/s, done.
Resolving deltas: 100% (4511/4511), completed with 320 local objects.
From git://github.com/rubinius/rubinius
* branch 2.0.0pre -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
# Dutch translation in YML by Ariejan de Vroom <[email protected]>
# - Sponsored by Kabisa ICT - http://kabisa.nl
#
# Fully compatible with Translate (the Rails translation plugin)
# - http://developer.newsdesk.se/2009/01/21/translate-new-rails-i18n-plugin-with-a-nice-web-ui/
---
nl:
number:
format:
separator: ","
@constantine-nikolaou
constantine-nikolaou / compress_requests.rb
Created August 5, 2011 11:42 — forked from subdigital/compress_requests.rb
Rack Middleware to automatically unzip gzipped/deflated POST data
class CompressedRequests
def initialize(app)
@app = app
end
def call(env)
if env['REQUEST_METHOD'] =~ /(POST|PUT)/
if env.keys.include? 'HTTP_CONTENT_ENCODING'
input = env['rack.input'].read
@constantine-nikolaou
constantine-nikolaou / super_simple_sqs.rb
Created October 26, 2011 13:15 — forked from ssimeonov/super_simple_sqs.rb
This is a simple way to post a message to Amazon SQS w/o any gems (the queue must already exist)
module Amazon
module Authentication
SIGNATURE_VERSION = "2"
@@digest = OpenSSL::Digest::Digest.new("sha256")
def sign(auth_string)
Base64.encode64(OpenSSL::HMAC.digest(digester, aws_secret_access_key, auth_string)).strip
end
def digester
@constantine-nikolaou
constantine-nikolaou / gist:1438212
Created December 6, 2011 13:31
Convert string chars to hex values
ree-1.8.7-2011.03 :027 > array = []
=> []
ree-1.8.7-2011.03 :028 > "hello".each_byte {|x| array << x}
=> "hello"
ree-1.8.7-2011.03 :029 > array.join(",")
=> "104,101,108,108,111"

Here's how to install PostgreSQL and have it run automatically at startup, on an Ubuntu 10.04 virtual machine using Vagrant. This took me a while to figure out:

Add the default lucid32 base box to your vagrant, if you haven't already:

host> vagrant box add lucid32 http://files.vagrantup.com/lucid32.box 

Now make a new lucid32 virtual machine and install postgresql on it:

@constantine-nikolaou
constantine-nikolaou / setup-statsd.sh
Created September 9, 2012 15:08 — forked from collegeman/setup-statsd.sh
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use
class UpgradeToRefineryTwo < ActiveRecord::Migration
def self.up
# For refinerycms-authentication
rename_table :roles_users, :refinery_roles_users
rename_table :roles, :refinery_roles
rename_table :user_plugins, :refinery_user_plugins
rename_table :users, :refinery_users
remove_column :refinery_users, :persistence_token
remove_column :refinery_users, :perishable_token
remove_column :refinery_users, :remember_token
@constantine-nikolaou
constantine-nikolaou / caesar_cipher.rb
Created April 15, 2016 14:47
Solution to Caesar Cipher implemented in ruby
def alphabet
Array('a'..'z') | (Array('A'..'Z'))
end
def cs_encrypt(string, key = 0)
# Rotate switches alphabets based on the passed key
dictionary = Hash[alphabet.zip(alphabet.rotate(key))]
string.chars.map { |str| dictionary.fetch(str, ' ') }
end
@constantine-nikolaou
constantine-nikolaou / list_cheat_sheets.md
Last active May 9, 2016 11:14
Handy bookmark page to useful cheatsheets I use when coding