This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Semaphore(private var count : Int) { | |
def p() { | |
synchronized { | |
while (count < 1) {} | |
count = count - 1 | |
} | |
} | |
def v() { | |
synchronized { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Java | |
require '$SCALA_HOME/scala-library.jar' | |
require 'lib/echo.jar' | |
include_class Java::com.github.oetzi.echo.core.Behaviour | |
include_class Java::com.github.oetzi.echo.core.Event | |
beh = Behaviour.new { | time | 5 } | |
event = Event.new | |
beh.at(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following code is a series of test that were written in the order you'll read them. After | |
// each test was written it was run against the HashMap and the implementation was updated if it | |
// failed. The HashMap code is the final implementation that was built naively to pass each test. | |
// The Tests: | |
public class HashMapTest { | |
private HashMap map; | |
// Set up an empty map before each test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I always run into massive problems when trying to write Scala that uses Java libraries. Recently | |
// one thing that threw me off was trying to do the following: | |
val class = MyAwesomeType.class | |
// This is often used in Java to get the 'Class' class for a class (yeah, I know). But how do we do | |
// this in Scala? | |
val class = MyAwesomeType.class // No. This reports that there is no 'class' member for the type |