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
:styles => lambda { |i| i.instance.file_content_type =~ /image/ ? { :original => "800x600>" } : {} } |
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
window.resize_crop = (img) -> | |
org = new Image() | |
org.src = img.src | |
org.onload = -> | |
j_img = $(img) | |
src = @src | |
img_w = parseInt j_img.css "width" |
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
#!/usr/bin/env ruby | |
# sudo gem install sass | |
# npm install less -g | |
# npm install coffee -g | |
p 'Dux sass/less/coffee compiler v0.1' | |
while true | |
sleep 1 if (@last_mtime ||=0) > 0 |
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
find -type f | grep .coffee | xargs ls -t | head -n 1 | xargs coffee -cw |
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
#!/bin/bash | |
FILE="/var/www/${1}.sql" | |
echo "Delete remote dump [${FILE}]" | |
ssh [email protected] "rm -rf ${FILE}" | |
echo "Remote database dump" | |
ssh [email protected] "mysqldump --user=root --password=XYZ ${1} > ${FILE}" |
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
#!/bin/bash | |
FILE="${1}.sql" | |
rm -rf $FILE | |
echo "Database dump to [${FILE}]" | |
mysqldump -u root $1 > $FILE | |
echo "Deleting remote database" |
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
connection.execute - base execute | |
connection.select_all - hash | |
connection.select_values - only ids | |
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
module Base62 | |
MAP = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a | |
def encode(numeric) | |
raise TypeError unless numeric.kind_of?(Numeric) | |
return '0' if numeric.zero? | |
s = '' | |
while numeric > 0 | |
s << Base62::MAP[numeric % 62] |
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
redirect_to(AWS::S3::S3Object.url_for(path, track.mp3.bucket_name, :expires_in => 10.seconds)) |
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
require 'openssl' | |
require "base64" | |
class Crypt | |
def self.sha1(str) | |
Digest::SHA1.hexdigest str.to_s | |
end | |
def self.cipher(mode, data, key='') | |
cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc').send(mode) |