Skip to content

Instantly share code, notes, and snippets.

View matthutchinson's full-sized avatar
🧐
`¯\_(ツ)_/¯`

Matthew Hutchinson matthutchinson

🧐
`¯\_(ツ)_/¯`
View GitHub Profile
# encoding: UTF-8
#!/usr/bin/ruby
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
class GoogleTranslate
# script to import cms assets from those hosted on cms.housetrip.com and
# upload them as cms asset objects to cloudfront, also updating all
# references to the images in cms_page_contents markdown for all locales
# only the about us and press corner pages contain assets
# create a tmp dir for this script to keep downloaded assets in
`rm -rf tmp/cms_asset_import`
`mkdir -p tmp/cms_asset_import`
# helper methods
@matthutchinson
matthutchinson / your-app.dev
Created June 20, 2013 13:38
your-app.dev
server {
listen 443 ssl;
server_name your-app.dev;
root /path/to/your-app/public;
index index.html index.htm;
### SSL log files ###
access_log logs/your-app.dev-ssl-access.log;
error_log logs/your-app.dev-ssl-error.log;
#!/usr/bin/env ruby
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
server {
listen 443 ssl;
server_name housetrip.dev;
root /u/apps/housetrip/public;
index index.html index.htm;
### SSL log files ###
access_log logs/housetrip.dev-ssl-access.log;
error_log logs/housetrip.dev-ssl-error.log;
# /usr/local/etc/nginx/nginx.conf
worker_processes 4;
events {
worker_connections 1024;
}
http {
@matthutchinson
matthutchinson / gem-public_cert.pem
Created June 3, 2013 11:11
My public gem certificate, for installing my gems with the HighSecurityPolicy
-----BEGIN CERTIFICATE-----
MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMQ0wCwYDVQQDDARtYXR0
MRowGAYKCZImiZPyLGQBGRYKaGlkZGVubG9vcDETMBEGCgmSJomT8ixkARkWA2Nv
bTAeFw0xMzA2MDMxMDA0NDNaFw0xNDA2MDMxMDA0NDNaMEAxDTALBgNVBAMMBG1h
dHQxGjAYBgoJkiaJk/IsZAEZFgpoaWRkZW5sb29wMRMwEQYKCZImiZPyLGQBGRYD
Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApUgO+NlewgetOcmX
8kk5IiISAmGGYqoFrDnzO7/NGjlWcSit91hZszadsQ00OM9h30WMDqSGPlwt2qVL
CQShDjOTx4PQcN9O8PchlhLow/wNVfB5b5sYQX3aDIiIoSLViQt+zquPhTHExN4X
HJJFxwUVIQot0JHV7mh9jApu+RJIpiVPM0is18NnOC2BIXjrGYxqHr7cG4BafvLz
tNTmPtpnp+bxKtp/bGP0wRtPSU9jX/a3V1p1DyI48O5wDLzctXJq/I088sTmB0Ao
[mysqld]
thread_concurrency = 16
#log-bin=mysql-bin
#binlog_format=mixed
innodb_data_file_path = ibdata1:100M:autoextend
innodb_buffer_pool_size = 1024M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 256M
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 2
# WARNING: fragment cache is no longer cleared on deploy to clear completely
# use a version key or bump FRAGMENT_CACHE_VERSION above
def fragment_cache(name, options = {}, &block)
old_within_fragment = @within_fragment
@within_fragment = true
# trace execution for NewRelic
CachingHelper.trace_execution_scoped(["Custom/Fragment cache overhead: #{name}"]) do
if_conditions = Array.wrap(options[:if])
unless_conditions = Array.wrap(options[:unless])
# Returns a score for last 10 bookings' acceptance rate
# If 1 booking rejected over past 10 bookings, return 0.5
# If 2 bookings rejected, return 0.0
def booking_acceptance_score
total_bookings_to_be_considered = 10
booking_ids = []
offset = 0
while booking_ids.length < total_bookings_to_be_considered do
# Fetch histories one by one