Skip to content

Instantly share code, notes, and snippets.

user nginx;
worker_processes 8;
error_log /var/deploy/lola-live/web_head/shared/log/nginx_error.log;
events
{
worker_connections 1024;
accept_mutex off;
}
@danhunter
danhunter / gist:76c43feb4f932c0fdeae
Last active August 29, 2015 14:11
firmware.xml
<boards>
<!--
SJFW http://reprap.org/wiki/Sjfw
-->
<board name="Mega1280" icon="icon-mb24.png">
<version major="1" minor="0"/>
<programmer class="replicatorg.uploader.AvrdudeUploader">
<protocol>stk500v1</protocol>
<speed>57600</speed>
<arch>m1280</arch>
@danhunter
danhunter / gist:9ed626ce9c7ecbfe01e1
Created July 23, 2014 16:06
refactored spec attempt
['addresses', 'orders'].each do |includable|
describe "includes #{includable}" do
let!(:association) { create(includable.singularize, user: user) }
it "GET self" do
get "/api/v2/users/#{user.id}", {'include' => includable}, headers || {}
expect(json['user']).to include(includable)
(json[includable][0]).each do |k, v|
expect(v).to eq(association[k])
@danhunter
danhunter / gist:6f3c3419e2c6ef93e12e
Created May 2, 2014 21:50
iPhone App orders by day of month
day_of_month | count
--------------+-------
1 | 20
2 | 43
3 | 42
4 | 32
5 | 22
6 | 19
7 | 39
8 | 32
@danhunter
danhunter / gist:9232657
Last active August 29, 2015 13:56
.bash_profile
c_path=`tput setaf 6`
c_stgd=`tput setaf 2`
c_unstgd=`tput setaf 9`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
then
gitver=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
@danhunter
danhunter / gist:6709204
Last active December 23, 2015 23:19
Some something
# in config/initializers/foo.rb
Media.send :include, MediaConcern
# in concerns/media_concern.rb
require 'active_support/concern'
module MediaConcern
extend ActiveSupport::Concern
included do
def origin
purchase_order.shipper.location if purchase_order.shipper
end
@danhunter
danhunter / gist:3626578
Created September 4, 2012 21:13
plupload
$(function() {
var avatar_uploader = new plupload.Uploader({
runtimes: 'html5,flash,html4',
container : 'avatar-upload',
browse_button : 'avatar-browse',
url : '<%= upload_image_user_path %>',
max_file_size: '10mb',
multiple_queues: true,
flash_swf_url : '/plupload/plupload.flash.swf',
multipart: true,
class Category < ActiveRecord::Base
has_many :subcategories, :dependent => :destroy
has_many :users, :through => :subcategories
end
@danhunter
danhunter / gist:3505195
Created August 28, 2012 23:13
Joins on joins on joins..
# This..
Category.first.users
# ..generates this:
SELECT "users".* FROM "users" INNER JOIN "categorizations" ON "users"."id" = "categorizations"."user_id" INNER JOIN "subcategories" ON "categorizations"."subcategory_id" = "subcategories"."id" WHERE "subcategories"."category_id" = 1
# Is there something like this..