Skip to content

Instantly share code, notes, and snippets.

View seadowg's full-sized avatar

Callum Stott seadowg

View GitHub Profile
@seadowg
seadowg / buildfile
Created March 13, 2012 19:07
Add growl 1.3 to buildr
# Add this to a buildr 'buildfile' to receive growl notifications when compilation
# completes or fails (including cc compilations)
require 'ruby_gntp'
# Growl setup
Buildr.application.on_completion do |title, message|
GNTP.notify({
:app_name => "buildr",
:title => title,
@seadowg
seadowg / Semaphore.scala
Created May 20, 2012 13:32
Semaphore implementation with Scala's synchronized
class Semaphore(private var count : Int) {
def p() {
synchronized {
while (count < 1) {}
count = count - 1
}
}
def v() {
synchronized {
@seadowg
seadowg / prodcon.scala
Created May 20, 2012 16:02
Producer/Consumer with Split Counting Semaphore in Scala
import actors.Actor._
val n = 8
val front = 0
val back = 0
val buffer = new Array[Int](n)
val full = new Semaphore(0)
val empty = new Semaphore(n)
// Producer
@seadowg
seadowg / setup.txt
Created July 28, 2012 16:41
My Rails Setup
rails new <appname>
cd <appname>
git init
rm -r test
gem 'rspec-rails' -> Gemfile
bundle install
rails generate rspec:install
gem 'factory_girl_rails' -> Gemfile
@seadowg
seadowg / frappuccino.coffee
Created August 13, 2012 01:13
Prototype FRP + Backbone collision
class Frappuccino.Backbone.Event extends Backbone.Event
event: (event_name) -> new Frappuccino.Event(this, event_name)
class Frappuccino.Event extends Backbone.Event
constructor: (origin, event) ->
@origin = origin
@event = event
@origin.bind(@event, (value) => this.occur(value))
@seadowg
seadowg / commit-msg
Created October 24, 2012 16:34
Append a random emoji commit-msg hook
#!/usr/bin/env ruby
emoji = [":bowtie:", ":smile:", ":laughing:", ":blush:", ":smiley:", ":relaxed:", ":smirk:", ":heart_eyes:", ":kissing_heart:", ":kissing_face:",
":flushed:", ":relieved:", ":satisfied:", ":grin:", ":wink:", ":wink2:", ":tongue:", ":unamused:", ":sweat_smile:", ":sweat:", ":weary:",
":pensive:", ":disappointed:", ":confounded:", ":fearful:", ":cold_sweat:", ":persevere:", ":cry:", ":sob:", ":joy:", ":astonished:", ":scream:",
":neckbeard:", ":tired_face:", ":angry:", ":rage:", ":triumph:", ":sleepy:", ":yum:", ":mask:", ":sunglasses:", ":dizzy_face:", ":imp:", ":smiling_imp:",
":neutral_face:", ":no_mouth:", ":innocent:", ":alien:", ":yellow_heart:", ":blue_heart:", ":purple_heart:", ":heart:", ":green_heart:", ":broken_heart:",
":heartbeat:", ":heartpulse:", ":two_hearts:", ":revolving_hearts:", ":cupid:", ":sparkles:", ":star:", ":star2:", ":dizzy:", ":boom:", ":collision:",
":anger:", ":exclamation:", ":question:", ":grey_exclamation:", ":grey_question:", ":zzz:", ":da
@seadowg
seadowg / EventActivity.java
Created May 15, 2013 06:48
Cleaner (IMO) Event Handling in Android
// Standard way of hooking up Events:
public class EventActivity extends Activity {
public onCreate(Bundle savedInstanceState) {
findViewById(R.id.button_one).setOnClickListener(new View.OnClickListener) {
@Override
public void onClick(View view) {
Toast toast = Toast.makeText(EventActivity.this, "Clicked One!", Toast.LENGTH_SHORT);
toast.show()
}
@seadowg
seadowg / MeasureTest.java
Created August 23, 2013 07:17
Test requestLayout uses correct MeasureSpec
@Test
public void contentViewShouldBeMeasuredWithSpecExactly() {
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
final int[] measureModes = {0, 0};
View contentView = new View(activity) {
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
measureModes[0] = MeasureSpec.getMode(widthMeasureSpec);
measureModes[1] = MeasureSpec.getMode(heightMeasureSpec);
$ fly --atcURL http://ci.initech.com:8080 execute -c test.yml --exclude-ignored </dev/null | cat
Connecting to 10.0.2.15:8080 (10.0.2.15:8080)
- 100% |*******************************| 10320k 0:00:00 ETA
initializing with docker:///cstott/node-ruby-kitchen-sink
running script/test.sh
+ git submodule init
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
@seadowg
seadowg / direction.swift
Last active March 10, 2017 09:25
ADT examples in Swift
enum Direction {
case Left
case Right
}
func angle(direction: Direction): Int {
switch(direction) {
case Left: return 90
case Right: return -90
}