Skip to content

Instantly share code, notes, and snippets.

View djones's full-sized avatar
🍍
' OR '1'='1

David Jones djones

🍍
' OR '1'='1
View GitHub Profile
@djones
djones / github.md
Last active October 30, 2023 06:58

🍍

@djones
djones / apply-guetzli.sh
Last active March 22, 2017 14:43
Applying Guetzli encoding to JPG images in bulk
brew install guetzli
cd your/images/directory
for file in **/**.jpg; do guetzli "$file" "$file"; printf '.'; done
alias PhoenixTodosApi.Repo
alias PhoenixTodosApi.Todo
Repo.insert!(%Todo{title: "Create the Phoenix App", is_completed: true})
Repo.insert!(%Todo{title: "Prepare the Ember App", is_completed: false})
Repo.insert!(%Todo{title: "Ensure the Apps Work Together", is_completed: false})
@djones
djones / add_handoff_to_orders.rb
Created June 10, 2014 20:49
Handoff in iOS 8 and OS X Yosemite with Spree Commerce
# Generate this migration by running:
#
# bundle exec rails g migration add_handoff_to_spree_orders handoff:string
# bundle exec rake db:migrate
#
# db/migrate/add_handoff_to_orders.rb
class AddHandoffToOrders < ActiveRecord::Migration
def change
add_column :spree_orders, :handoff, :string
@djones
djones / gist:3281471
Created August 7, 2012 04:11
Xcode Experiments with ImageOptim and ImageAlpha
Ensure you first read http://imageoptim.com/xcode.html
Links: http://imageoptim.com - http://pngmini.com
Results when applying to Ace Rider:
(binary size)
40.4mb Xcode default
38.2mb ImageOptim
30.8mb ImageAlpha (256 colours)
@djones
djones / gist:2731965
Created May 19, 2012 18:59
Send screenshots to a screenshots directory on my desktop
mkdir ~/Desktop/screenshots
defaults write com.apple.screencapture location ~/Desktop/screenshots
# Log out and in again for it to take effect
@djones
djones / Grape + Goliath
Created May 10, 2012 01:55
Basic API app performance comparison: Rails + Thin VS Grape + Goliath
# Standard Grape API setup on a user model which uses ActiveRecord like the Rails example above.
# Goliath running in production mode.
# MySQL used for the database.
# Result: 1203.6 avg replies/s (with stddev 5.2)
$ httperf --server=localhost --port=9000 --uri=/users/1.json --num-conns=20 --num-calls=2000
httperf --client=0/1 --server=localhost --port=9000 --uri=/users/1.json --send-buffer=4096 --recv-buffer=16384 --num-conns=20 --num-calls=2000
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
@djones
djones / gist:2642094
Created May 9, 2012 05:26
Grape API being served with Goliath
#!/usr/bin/env ruby
# gem install grape --pre
# http://localhost:9000/hello.json
# => {"hello":"world"}
$:<< '../lib' << 'lib'
require 'goliath'
@djones
djones / gist:2596822
Created May 4, 2012 18:38
Sudocode on how I would like Grape to work with Goliath
# Sudocode on how I would like grape to work with Goliath
# http://localhost:9000/randomuser #=> random user in json
require 'goliath'
require 'grape'
require 'em-synchrony/activerecord'
class User < ActiveRecord::Base
end
@djones
djones / coffee_hydration.rb
Created April 19, 2012 16:27
Does my coffee hydrate or dehydrate me?
# Do you hydrate or dehydrate your body when having a coffee?
# Constants based on references below
MG_OF_CAFFEINE_PER_SHOT = 77 # mg
SHOT_VOLUME = 44 # ml
WATER_PERCENT_IN_MILK = 87 # %
WATER_LOSS_FROM_CAFFEINE = 1.17 # ml/mg
# number_of_shots : standard single shot
# size_of_cup : in ml