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
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 |
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
User | |
has_many :bookings | |
| id | name | | |
--------------- | |
| 1 | amy | | |
| 2 | jack | | |
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
# Update the system and packages | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
# Restart server | |
sudo shutdown -r now | |
# Check openssl is upgraded against versions below | |
dpkg -l | grep "openssl" |
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
<!-- START aircraftsalesandparts.com widget --> | |
<style type="text/css" media="screen"> | |
#asap.asap-widget{margin:20px 0;}#asap.asap-widget .title{background:#ddd;color:#666;text-shadow:1px 1px 0 #eee;top:-1px;border:1px solid #C2C2C2;padding:10px;margin:0;}#asap.asap-widget .link{padding:5px;background:#333;color:#eee;}#asap.asap-widget table{display:block;border:1px solid #D8D8D8;border-bottom:none;}#asap.asap-widget table tr{padding:5px;}#asap.asap-widget table th{text-align:left;padding:5px;color:#333;}#asap.asap-widget table td{padding:10px;}#asap.asap-widget table td.title{width:200px;font-weight:bold;color:#777;}#asap.asap-widget table form input.submit{margin-left:4px;}</style> | |
<div id="asap" class="asap-widget"><div class="recent-widget"><h3 class="title"><span>Find Aircraft Parts</span></h3><div class="items"><table><tr><td><form action="https://aircraftsalesandparts.com/parts/search" method="get" target="_blank"><input id="search" name="search" type="text" /><input type="hidden" name="submit" value=" |
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
# redis install | |
sudo apt-get install tcl8.5 | |
wget http://download.redis.io/redis-stable.tar.gz | |
tar xvzf redis-stable.tar.gz | |
cd redis-stable/ | |
make | |
make test | |
sudo make install | |
sudo mkdir /etc/redis |
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
# convert lines in text file | |
tr '[:lower:]' '[:upper:]' <oldfile> newfile | |
# download a gzip file from remote server | |
ssh server "gzip -c remote_file" > local_file.gz | |
# secure copy local file to remote server | |
scp localfile user@remote_server.com:remote_directory | |
# find all files that have been modified in the last 3 days |
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
# controller | |
def proc_csv | |
import = Import.find(params[:id]) | |
if import.load_csv | |
flash[:notice] = "woo" | |
redirect_to some_url | |
else | |
flash[:error] = "ohoh" | |
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
# For bitfield calculations... | |
#------------------------------------------------------------------------ | |
# flag | sale | lease | charter | hide | vertical | |
#------------------------------------------------------------------------ | |
# booleans | 1 | 1 | 1 | 1 | 1 | |
#------------------------------------------------------------------------ | |
# position | 1 | 2 | 3 | 4 | 5 | |
#------------------------------------------------------------------------ | |
# value | 1 | 2 | 4 | 8 | 16 | |
# |
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
require 'hmac-sha1' | |
require 'net/https' | |
require 'base64' | |
desc "Invalidate files from cloudfront distribution" | |
task :files, :filenames do |task, args| | |
CONFIG = YAML.load_file(File.join(RAILS_ROOT, 'config', 'amazon_s3.yml'))[RAILS_ENV] | |
s3_access = CONFIG['access_key_id'] |
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 hate this... it's fugly: | |
order("CEIL((artworks.votes + POW(subscriptions.amount, 2)) / POW(((DATEDIFF(CURDATE(), artworks.created_at)) + 1), 1.5))") | |
# Would love to be able to do something similar to this (although I like typing *POW!*): | |
order(((artworks.votes + subscriptions.amount)**2) / (((Time.parse(DateTime.now.to_s) - Time.parse(created_at.to_s) + 1) / 86400).round + 1)^1.5) | |
# Code could have some boo boos init... this is just as an example fyi |
OlderNewer