Skip to content

Instantly share code, notes, and snippets.

View BrianTheCoder's full-sized avatar

Brian Smith BrianTheCoder

View GitHub Profile
s3_host_alias = "s3-ap-southeast-2.amazonaws.com"
Spree::Image.attachment_definitions[:attachment][:url] = s3_host_alias
Spree::Image.attachment_definitions[:attachment][:path] = '/spree/products/:id/:style/:basename.:extension'
Spree::Image.attachment_definitions[:attachment][:storage] = :s3
Spree::Image.attachment_definitions[:attachment][:bucket] = ENV['s3_bucket']
Spree::Image.attachment_definitions[:attachment][:s3_credentials]= {
:access_key_id => ENV['s3_access_key_id'],
:secret_access_key => ENV['s3_secret_access_key']
}
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class Thumbnail
def make
src = Test::FileHelper.fixture_file('white_pixel.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else
@pengwynn
pengwynn / Rakefile
Created September 1, 2011 01:08
Build titanium
require 'rubygems'
require 'nokogiri'
require 'colored'
PROJECT_NAME="GolfStatus"
PROJECT_ROOT = File.dirname(__FILE__)
IPHONE_SDK_VERSION="4.3"
TI_SDK_VERSION="1.6.2"
TI_DIR='/Library/Application\ Support/Titanium'
@sishen
sishen / notifier.coffee
Created August 2, 2012 03:36
Web Notifications integration in Pragmatic.ly
class Notifier
constructor: ->
@enableNotification = false
@checkOrRequirePermission()
hasSupport: ->
window.webkitNotifications?
requestPermission: (cb) ->
window.webkitNotifications.requestPermission (cb)
#!/usr/bin/env ruby
# coding: utf-8
abort "Usage: fuck you <name>" unless ARGV[0] == "you" && ARGV.size == 2
a = "abcdefghijklmnopqrstuvqxyz".each_char.to_a
b = "ɐqɔpǝɟƃɥıɾʞʃɯuodbɹsʇnʌʍxʎz".each_char.to_a
ws = Hash[a.zip(b)]
ws.default = ->(f){f}
@txus
txus / .pryrc.rb
Last active December 18, 2015 17:59
Pry command to trace a method invocation and log backtraces of each invocation to a file.
def write_backtrace name, backtrace, filename
exceptions = Regexp.union([
/\.bundle/,
/spec/,
/test/,
/lib\/ruby\/1.9.1/
])
backtrace.reject! { |line| line =~ exceptions }
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@aiwilliams
aiwilliams / README.md
Created May 16, 2012 13:52
Storyboard in RubyMotion 1.4

Start XCode and create a new Storyboard file. I closed all my other XCode projects. When you choose the location of the created file, it should be your RubyMotion project's resources directory. Add a UIViewController, and set it's identifier property to "Start". Add some UI elements so you can see it working.

When you run rake in your RubyMotion project, it will compile the .storyboard file. You could auto-load the Storyboard using a plist configuration, but you'll see code can do it too.

@rweald
rweald / simple-linear-regression.rb
Created August 29, 2012 19:13
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))