This file contains hidden or 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
desc "Backup and download database" | |
task :backup do | |
filename = "#{Time.now.strftime("%Y-%m-%d-%H-%M")}.sql" | |
run "mysqldump -u #{user} -p#{password} #{application}_prod > /tmp/#{filename}" | |
download "/tmp/#{filename}", "backups/#{filename}" | |
end |
This file contains hidden or 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
class Users::RegistrationsController < Devise::RegistrationsController | |
# Use this if you are sending a confirmation email before completing sign up | |
def after_inactive_sign_up_path_for(resource) | |
# resource is an instance of User | |
"http://www.example.com?user_id=#{resource.id}" | |
end | |
# Use this one once the account is active | |
def after_sign_up_path_for(resource) |
This file contains hidden or 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
// to open a websocket | |
socket = new WebSocket("ws://<server>:<port>/<path>"); | |
// to react to a message | |
socket.onmessage = function(event) { | |
// your code | |
} | |
// to send a message | |
socket.send("a string") |
This file contains hidden or 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
// to save a value | |
localStorage.setItem(key, value) | |
// to read a value | |
var value = localStorage.getItem(key) | |
// to count items in the cache | |
var count = localStorage.length |
This file contains hidden or 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 stopPropagation = function(event){ | |
event.stopPropagation(); | |
event.preventDefault(); | |
} | |
document.addEventListener('dragenter', stopPropagation, false); | |
document.addEventListener('dragexit', stopPropagation, false); | |
document.addEventListener('dragover', stopPropagation, false); | |
document.addEventListener('drop', function (event) { | |
// your code here |
This file contains hidden or 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
deploy@184:~$ uname -a | |
Linux 184.106.206.118 2.6.33.5-rscloud #2 SMP Thu Jun 10 15:26:23 UTC 2010 x86_64 GNU/Linux | |
deploy@184:~$ gem -v | |
1.3.7 | |
deploy@184:~$ bundle -v | |
Bundler version 1.0.0.rc.2 | |
deploy@184:~$ mkdir temp | |
deploy@184:~$ cd temp/ | |
deploy@184:~/temp$ bundle init | |
Writing new Gemfile to /home/deploy/temp/Gemfile |
This file contains hidden or 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 was dealing with a number of different log methods (per minute, per hour, per day) etc | |
# Where times with no data were not stored in the database. This was an attempt at getting active record to | |
# inject zeroed data into to the returned datasets. | |
# | |
# It worked, but the experiment was a failure: | |
# 1) extracting times from the where_values is brittle and will fail often | |
# 2) It gets applied to all AR models | |
# 3) It required adding two methods (new_default and period) to the corrospoding AR classes creating too strong coupling | |
This file contains hidden or 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
#Compares to Bundler lock files and prints a report | |
#of which gems have changed version | |
require "yaml" | |
old = YAML.load_file("Gemfile.lock.old") | |
current = YAML.load_file("Gemfile.lock") | |
old['specs'].each do |elem| | |
elem.each do |name, details| | |
old_name = name |