rails new example_app --skip-activerecord \
--skip-testunit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from bottle import route, run, debug, template, request, validate, static_file, error | |
@route('/') | |
@route('/index.html') | |
def index(): | |
return 'Index' | |
@route('/static/:filename') | |
def serve_static(filename): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("http://www.google.com") | |
val result = try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = active_record_model.column_names.map{ |f| m.send f.to_sym } | |
csv << values | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo pip install -U scikit-learn | |
sudo pip install -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib |