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
<ul class="faint" id="links"> | |
<li><a href="http://www.twitter.com" class="rounded">Twitter</a></li> | |
<li><a href="http://www.flickr.com"class="rounded">Flickr</a></li> | |
</ul> |
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 hashlib, urllib2, sys, os | |
class Gravatar: | |
def __init__(self, email): | |
self.email = email | |
self.hash = hashlib.md5(self.email.lower()).hexdigest() | |
def get(self): | |
try: |
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 sys | |
def isapoweroftwo(n): | |
if n == 0: | |
return False | |
if n & (n - 1) == 0: | |
return True |
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: | |
def init(self, n): | |
self.lock = BinSemaphore(1) | |
self.delay = BinSemaphore(0) | |
self.var = n | |
def wait(self): | |
self.lock.wait() | |
self.var = self.var - 1 | |
if self.var < 0: |
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
<project name="scalaIsAwesome" basedir="." default="build"> | |
<property name="scala-compiler.jar" | |
value="/usr/local/Cellar/scala/2.8.1/libexec/lib/scala-compiler.jar"/> | |
<property name="scala-library.jar" | |
value="/usr/local/Cellar/scala/2.8.1/libexec/lib/scala-library.jar"/> | |
<path id="scala.classpath"> | |
<pathelement location="${scala-compiler.jar}"/> | |
<pathelement location="${scala-library.jar}"/> | |
</path> | |
<taskdef resource="scala/tools/ant/antlib.xml"> |
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
gem install rjb -v 1.3.3 --platform ruby | |
gem install buildr |
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
#!/bin/bash | |
rm /Users/$USER/Downloads/*.pdf |
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 |
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
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) |
OlderNewer