Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rss'
subscriber_id = "41TjtXC14dnMq0aFyllyKw"
download_dir = "/srv/http/data.ineu.pp.ua/shared/public/system/railscasts"
url = "http://railscasts.com/subscriptions/#{subscriber_id}/episodes.rss"
feed = RSS::Parser.parse(url)
require 'net/http'
require 'pry'
class RailscastsScanner
end
uri = URI("http://railscasts.com/episodes/407")
Net::HTTP.start uri.host, uri.port do |http|
resp = http.head uri.path
@orendon
orendon / Install_tmux
Last active January 4, 2016 17:09 — forked from simme/Install_tmux
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh [email protected]

Add ssh fingerprint and enter password provided in email

desc 'rolls back migrations in current branch not present in other'
task :rollback_branch_migrations, [:other_branch] do |t, args|
load "#{Dir.pwd}/Rakefile"
branch_migrations = BranchMigrations.new(args.other_branch)
puts ['Rollback the following migrations', branch_migrations, 'y,n? ']
next if %w[no n NO N].include?(STDIN.gets.chomp)
migrate_task = Rake::Task['db:migrate:down']

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Tested in Ubuntu 12: super == ctrl

Open/Goto


  • super+t: go to file
@orendon
orendon / localstorage_polyfill.js
Last active August 29, 2015 14:01 — forked from juliocesar/best-localStorage-polyfill-evar.js
LocalStorage Polyfill in memory
if (!('localStorage' in window)) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
removeItem : function(id) { return delete this._data[id]; },
clear : function() { return this._data = {}; }
};
}
@orendon
orendon / save_and_open_screenshot.rb
Last active August 29, 2015 14:02 — forked from metaskills/gist:2836849
capybara save open screenshot launchy
module SaveOpenScreenshot
def save_and_open_screenshot
dir = "#{Rails.root}/tmp/cache/capybara"
file = "#{dir}/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
FileUtils.mkdir_p dir
page.driver.render file
while !File.exists?(file) do sleep 0.1; end
Launchy.open file
======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'