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
module HttpAuthentication | |
module Basic | |
def authenticate_or_request_with_http_basic(realm = 'Application') | |
authenticate_with_http_basic || request_http_basic_authentication(realm) | |
end | |
def authenticate_with_http_basic | |
if auth_str = request.env['HTTP_AUTHORIZATION'] | |
return 'login:password' == ActiveSupport::Base64.decode64(auth_str.sub(/^Basic\s+/, '')) | |
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
# http://unicorn.bogomips.org/SIGNALS.html | |
# change these to match your app | |
app_name = "APP_NAME" | |
rvm_string = "RVM_STRING" | |
user = "USER" | |
pid_file = "/srv/webapps/#{app_name}/shared/pids/#{app_name}.pid" | |
gem_home = "/usr/local/rvm/gems/#{rvm_string}" | |
app_root = "/srv/webapps/#{app_name}/current" |
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
module Tilt | |
class HandlebarsSlimTemplate < ::Slim::Template; end | |
register HandlebarsSlimTemplate, :handlebars_slim | |
end | |
class Slim::EmbeddedEngine | |
register :handlebars, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" } | |
register :handlebars_slim, TagEngine, tag: :script, attributes: { type: "text/x-handlebars" }, engine: StaticTiltEngine | |
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
# verified to work on DigitalOcean Ubuntu 12.10 X32 Server instance | |
# prerequisites | |
sudo addroup admin | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev gcc git make zsh | |
chsh -s /bin/zsh | |
# oh-my-zsh | |
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh |
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
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev | |
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz | |
tar -xvzf ruby-1.9.3-p125.tar.gz | |
cd ruby-1.9.3-p125/ | |
./configure --prefix=/usr/local | |
make | |
make install |
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
defmodule JSON do | |
import String | |
def parse( content ) do | |
case parse_content(content) do | |
{ value, "" } -> value | |
{ _, _ } -> raise "crap" | |
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
Usage example: | |
>> text = Morpher.new('Большой город') | |
{:Р=>"Большого города", :Д=>"Большому городу", :В=>"Большой город", :Т=>"Большим городом", :П=>"Большом городе", :П_о=>"о Большом городе", :род=>"Мужской", :множественное=>{:И=>"Большие города", :Р=>"Больших городов", :Д=>"Большим городам", :В=>"Большие города", :Т=>"Большими городами", :П=>"Больших городах", :П_о=>"о Больших городах"}, :где=>"в Большом городе", :куда=>"в Большой город", :откуда=>"из Большого города"} | |
>> text.singular('Д') | |
"Большому городу" | |
>> text.plural('Д') |
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
# For finding images as in Article.attachments.images | |
scope :images, where("file_content_type LIKE ?", "image%") | |
# For finding other files Article.attachments.docs | |
scope :docs, where("file_content_type NOT LIKE ?", "image%") |
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
var request = require('request'); | |
var consumer_key = 'YOUR_CONSUMER_KEY'; | |
var consumer_secret = 'YOUR_CONSUMER_SECRET'; | |
var enc_secret = new Buffer(consumer_key + ':' + consumer_secret).toString('base64'); | |
var oauthOptions = { | |
url: 'https://api.twitter.com/oauth2/token', | |
headers: {'Authorization': 'Basic ' + enc_secret, 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}, | |
body: 'grant_type=client_credentials' | |
}; |
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 cp nginx /etc/init.d/ | |
sudo update-rc.d nginx defaults | |
sudo chmod +x /etc/init.d/nginx | |
/etc/init.d/nginx start |
OlderNewer