Skip to content

Instantly share code, notes, and snippets.

View soulcutter's full-sized avatar

Bradley Schaefer soulcutter

View GitHub Profile
@soulcutter
soulcutter / .powrc
Created June 7, 2013 18:54
Example powrc with rvm and ruby-gemset / ruby-version
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ] ; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`@`cat .ruby-gemset`
fi
if [ -f "~/.oh-my-zsh/custom/openssl.zsh" ] ; then
source "~/.oh-my-zsh/custom/openssl.zsh"
fi
@soulcutter
soulcutter / gist:5346232
Created April 9, 2013 14:42
Why we need to dup things in define_method blocks
class Obj
def self.new_method(name, options = {})
define_method(name) { options }
end
end
o = Obj.new
options = { one: :two }
Obj.new_method('baz', options)
@soulcutter
soulcutter / _stacked.scss
Last active December 11, 2015 18:39
SCSS mixin creating a stacked block element
////
// Makes a div appear to be a stacked like 3 sheets of paper with each
// sheet offset by a given amount.
//
// Example: @include stacked(5px);
@mixin stacked($offset) {
border: 1px solid #494949;
&:after, &:before {
background: inherit;
@soulcutter
soulcutter / sns_publisher.js
Created December 11, 2015 17:38
Publishing to an SNS topic in AWS lambda (as a promise)
var _ = require('lodash');
var Q = require('q');
var AWS = require('aws-sdk-q');
function SnsPublisher(topic, options) {
var topicOptions = {
params: {
TopicArn: topic
}
};
require_relative './upload_store'
class PhotoClaimer
attr_writer :photo_source
attr_writer :upload_storage_source
class FileNotFound < RuntimeError; end
def initialize(user_id, file_name)
@user_id = user_id
@soulcutter
soulcutter / categories.rb
Created November 14, 2012 06:14 — forked from Drewch/categories.rb
categories
module Categories
ALL = [
:BUSINESS,
:CALL,
:CONTACT,
:KNOWLEDGE,
:ENTERTAINMENT,
:EMAIL,
:HELP,
:TRAVEL,
@soulcutter
soulcutter / gist:4055002
Created November 11, 2012 14:14
Understanding ruby coerce
class Price
include Comparable
attr_reader :amount
def initialize(amount)
@amount = amount
end
def <=>(obj)
@soulcutter
soulcutter / gist:4003852
Created November 2, 2012 19:37
Installing savon under jruby 1.6.3
➜ ~ rvm install jruby-1.6.3
jruby-1.6.3 - #downloading jruby-bin-1.6.3, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.7M 100 14.7M 0 0 459k 0 0:00:32 0:00:32 --:--:-- 410k
jruby-1.6.3 - #extracting jruby-bin-1.6.3 to /Users/brschaefer/.rvm/src/jruby-1.6.3
jruby-1.6.3 - #extracted to /Users/brschaefer/.rvm/src/jruby-1.6.3
Building Nailgun
jruby-1.6.3 - #installing to /Users/brschaefer/.rvm/rubies/jruby-1.6.3
jruby-1.6.3 - adjusting #shebangs for (jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb).
@soulcutter
soulcutter / gist:3873662
Created October 11, 2012 16:33
Spring ActiveProfiles injection question
// Question: Can you do something like this without using interface-based injection?
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test")
public class FakeDownloadUtilTest extends BaseTest {
@Autowired
DownloadUtil downloadUtil;
@Test
public void testFaked() {
@soulcutter
soulcutter / gist:3738320
Created September 17, 2012 16:27
Adding magic encoding comments to ruby files
#!/bin/zsh
for file in $(awk 'FNR == 1 && !/^#\!/ { print FILENAME; nextfile }' **/*.rb); do
echo $file
sed -i 1i'# encoding: utf-8' $file
done