Skip to content

Instantly share code, notes, and snippets.

@raul
raul / fastly.rake
Last active August 29, 2015 14:10 — forked from jmoe/fastly.rake
namespace :fastly do
desc "set fastly cors headers to fix chrome/firefox font loading issues"
task allow_cors: :environment do
# check for the Cors Allow header
versions = Yajl.load(Excon.get("https://api.fastly.com/service/#{ENV['FASTLY_SERVICE_ID']}/version",
:headers => {'Fastly-Key'=>ENV['FASTLY_API_KEY']}).body)
last_version = versions.last['number']

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

  1. one

  2. two

Some text...

$ foo bar
#!/bin/sh -
#
# new_tab.sh v0.01
#
# Script to open a new tab on MacOSX's terminal from the command line
#
# Usage:
# new_tab.sh -> opens new tab in current directory
# new_tab.sh /tmp -> opens new tab in /tmp
# new_tab.sh /tmp ls -> opens new tab in /tmp and executes ls
# Quick & Dirty textmate command to execute only the selected test on the current Rails test file
# Note: It's so quick and so dirty that it doesn't support the new 'test "foo bar baz" do' syntax
#
# 1) Open Bundles > Bundle Editor > Edit commands
# 2) Select Ruby > Run Focused Unit Test and press "copy" icon (++)
# 3) Rename the new command and select it
# 4) Paste this into Command(s) and customize the activation keys
cd ../..
# Quick & Dirty textmate command to execute the current Rails test file
#
# 1) Open Bundles > Bundle Editor > Edit commands
# 2) Select Ruby > Run and press "copy" icon (++)
# 3) Rename the new command and select it
# 4) Paste this into Command(s) and customize the activation keys
cd ../..
#/opt/local/bin/ruby -I=test $TM_FILEPATH
export RUBYLIB="$TM_BUNDLE_SUPPORT/RubyMate${RUBYLIB:+:$RUBYLIB}"
export RUBYLIB="test:$RUBYLIB"
# class to test
require 'rubygems'
require 'active_record'
class Post < ActiveRecord::Base
validates_presence_of :title
before_save :create_slug
# spanish dummy group
class AppServer
attr_accessor :admin_password
end
-- AppleScript doesn't load shell's environment variables
-- in "do shell script", so here goes a nasty workaround
on shell_cmd(command)
do shell script "source ~/.profile; " & command
end shell_cmd
do shell script "echo $EDITOR" -- => ""
shell_cmd("echo $EDITOR") -- => "mate"
# arrays can be used as a kind of circular list
a = ['a','b','c']
(1..20).each{ |n| puts a[n%a.size]} # forward
(-10..0).each{ |n| puts a[n%a.size]} # backwards