Skip to content

Instantly share code, notes, and snippets.

Owain Lewis owainlewis

Block or report user

Report or block owainlewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
owainlewis / Rails3.markdown
Created Apr 29, 2012
Rails 3 with Mongoid and Rspec
View Rails3.markdown

Generating the app

rails new example_app --skip-activerecord \


owainlewis / deployer.rake
Created May 8, 2012 — forked from morgoth/deployer.rake
Rake task to copy local files to remote server via FTP
View deployer.rake
# Rake task to copy local files to remote server via FTP
# required credentials.yml file, that contains keys:
# server, username, password
require "net/ftp"
require "yaml"
class FTPClient
attr_reader :remote_path
View cassandra.markdown

Start Cassandra

sudo bin/cassandra -f

Connect to the CLI

bin/cassandra-cli -h -p 9160

owainlewis /
Created Jun 22, 2012 example app
import os
from bottle import route, run, debug, template, request, validate, static_file, error
def index():
return 'Index'
def serve_static(filename):
owainlewis / firefox-fix.js
Created Jun 23, 2012
Firefox background image rendering bug, jQuery
View firefox-fix.js
* I encountered a strange bug with Firefox and dynamic background image updates.
* Background images can't be dynamically updated either through the console or via JavaScript.
* A simple hack is to update the opacity by a very small increment.
* This will force Firefox to re-render the background image correctly.
var rand_opacity = ((0.9 + Math.floor((Math.random()*10)+1))/100);
$(el).css({"background-image":new_image, 'opacity':0.9 + rand_opacity});
owainlewis / http.scala
Created Jun 28, 2012
Scala Apache HTTP
View http.scala
import org.apache.http.client._
import org.apache.http.client.methods._
import org.apache.http.impl.client._
class HTTP {
def getRequest: String = {
val client = new DefaultHttpClient()
val httpGet = new HttpGet("")
val result = try {
View sort.rb
# Sort columns by param
# eg ?sort=id_reverse or ?sort=first_name
sort_by_params = lambda do
sort = params[:sort]
return 'id' if sort.blank? # sort by id if no params given
if sort.match(/_reverse/)
sort.split(/_reverse/).first + " DESC"
owainlewis / model_to_csv.rb
Created Jul 2, 2012
Export Rails model to CSV
View model_to_csv.rb
# Export Active Record model as a CSV file
def self.render_csv active_record_model
CSV.generate do |csv|
csv << active_record_model.column_names
active_record_model.all.each do |m|
values ={ |f| m.send f.to_sym }
csv << values
View Cassandra


Create a keyspace

create keyspace store with replication_factor=1 and placement_strategy='org.apache.cassandra.locator.SimpleStrategy';

List keyspaces

show keyspaces;
owainlewis /
Created Jul 17, 2012
Machine Learning Packages for Python
sudo pip install -U scikit-learn
sudo pip install -f matplotlib
You can’t perform that action at this time.