Skip to content

Instantly share code, notes, and snippets.

Darren Terhune darrenterhune

Block or report user

Report or block darrenterhune

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@darrenterhune
darrenterhune / rails_status_codes.rb
Created Jan 24, 2017
List of rails status codes
View rails_status_codes.rb
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
@darrenterhune
darrenterhune / redis.sh
Last active Aug 29, 2015
Redis install
View redis.sh
# 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
@darrenterhune
darrenterhune / search-widget.html
Last active Aug 29, 2015
ASAP Search Widget (NEW)
View search-widget.html
<!-- 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="
@darrenterhune
darrenterhune / heartbleed.sh
Created Apr 9, 2014
openssl heartbleed update
View heartbleed.sh
# 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"
@darrenterhune
darrenterhune / finder.rb
Last active Aug 29, 2015
Find all users unless has_many matches a specific date
View finder.rb
User
has_many :bookings
| id | name |
---------------
| 1 | amy |
| 2 | jack |
@darrenterhune
darrenterhune / nokogiri.sh
Last active Aug 29, 2015
Nokogiri Mac OS X Mavericks
View nokogiri.sh
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
@darrenterhune
darrenterhune / digitalocean.md
Last active Apr 14, 2016
Digital Ocean [Virtual Hosts, MySQL] Setup
View digitalocean.md

Setup Virtual Hosts

Execute the following commands after ssh into vps:

sudo mkdir -p /var/www/example.com
sudo chown -R $USER:$USER /var/www/example.com
cd /var/www/
sudo chown www-data:www-data * -R 
sudo usermod -a -G www-data username-logged-in-as
cd
@darrenterhune
darrenterhune / passwordless_ssh.zsh
Last active Jan 17, 2018
Dreamhost passwordless login
View passwordless_ssh.zsh
scp ~/.ssh/id_rsa.pub user@example.com:~/
ssh user@example.com
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
rm id_rsa.pub
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
View order_ranking_algorithm.rb
# 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
View aws_cf_invalidate.rake
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']
You can’t perform that action at this time.