Using image: https://unsplash.com/new?photo=5RydGpXvpxE by Thomas Bühler
convert thomas-buhler-301493.jpg -colors 16 -depth 8 -format '%c' histogram:info:- \
| sort --reverse --numeric-sort
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
// Provides a device_scale class on iOS devices for scaling user | |
// interface elements relative to the current zoom factor. | |
// | |
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari | |
// Copyright (c) 2010 37signals. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
def compare_to(version) | |
reject_fields = ["_id", "updated_at", "version"] | |
diff_array = self.versions[version-1].attributes.to_hash.to_a - self.attributes.to_hash.to_a | |
diff_array.delete_if {|f| reject_fields.include?(f.first) } | |
Hash[diff_array] | |
end |
# Virtual Box Instructions | |
# -------------------------------- | |
# 1. Install VirtualBox Oracle VM VirtualBox Extension Pack. | |
# 2. Install deps for Guest Additions | |
sudo apt-get install dkms build-essential linux-headers-$(uname -r) | |
# 3. Install Guest Additions (from CD) | |
sh ./VBoxLinuxAdditions.run |
ENV['FIXTURES_DIR'] = "./" | |
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do |
function preresolve(dq) | |
if dq.qname:equal("www.google.com") then | |
dq:addAnswer(pdns.CNAME, "forcesafesearch.google.com.") | |
dq.rcode = 0 | |
dq.followupFunction="followCNAMERecords" -- this makes PowerDNS lookup your CNAME | |
return true; | |
end | |
return false; | |
end |
module ApplicationHelper | |
def present(object, klass = nil) | |
klass ||= "#{object.class}Presenter".constantize | |
presenter = klass.new(object, self) | |
yield presenter if block_given? | |
presenter | |
end | |
end |
/(?:get|put|post|patch)\s+:\w+,\s+(?!params).+/ |
Using image: https://unsplash.com/new?photo=5RydGpXvpxE by Thomas Bühler
convert thomas-buhler-301493.jpg -colors 16 -depth 8 -format '%c' histogram:info:- \
| sort --reverse --numeric-sort
# http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
# http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
# payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
# data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |