This file contains 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
def generate_valid_isbn | |
prefix = 978.to_s # must be 978 or 979 | |
registration_group_element = rand(10).to_s | |
registrant_element = (rand(90000) + 10000).to_s | |
publication_element = (rand(900) + 100).to_s | |
_isbn = prefix + registration_group_element + registrant_element + publication_element | |
check_digit = 0 | |
i = 0 | |
_isbn.each_char do |letter| | |
i+= 1 |
This file contains 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 org.openqa.selenium.*; | |
import org.openqa.selenium.remote.*; | |
import org.openqa.selenium.firefox.*; | |
public class CustomFirefoxProfile { | |
public static void main(String[] args) throws Exception { | |
DesiredCapabilities capabillities = new DesiredCapabilities("firefox", "3.6.", Platform.WINDOWS); | |
capabillities.setCapability("job-name", "Fancy Firefox profile"); | |
FirefoxProfile profile = new FirefoxProfile(); | |
profile.setPreference("network.http.phishy-userpass-length", 255); |
This file contains 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
package EasyJSON | |
import net.minidev.json.JSONValue | |
import net.minidev.json.JSONArray | |
import net.minidev.json.JSONObject | |
import scala.collection.JavaConversions._ | |
object JSON { | |
def parseJSON(s: String) = new ScalaJSON(JSONValue.parse(s)) |
This file contains 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
package com.sabrelabs.twitter.auth | |
import scala.collection.BitSet | |
import scala.annotation.tailrec | |
import scala.runtime.RichInt | |
import scala.collection.mutable.ListBuffer | |
object PercentEncoder { | |
def encodeRFC3986(str: String): String = { |
This file contains 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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains 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
apt-get install xvfb | |
apt-get install firefox |
This file contains 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 javax.mail.Authenticator; | |
import javax.mail.Flags; | |
import javax.mail.Folder; | |
import javax.mail.Message; | |
import javax.mail.MessagingException; | |
import javax.mail.PasswordAuthentication; | |
import javax.mail.Session; | |
import javax.mail.Store; | |
import javax.mail.internet.InternetAddress; | |
import javax.mail.search.FromTerm; |
This file contains 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
# YouTube playlist audio retreiver and iTunes-compliant podcast XML generation tool. | |
# This script will download each video file from the specified YouTube playlist, losslessly extract | |
# the audio, delete the video, and ultimately produce an iTunes-compliant podcast XML with the | |
# appropriate metadata, including chapter markers (if provided in the description). If you run the | |
# script again, only videos that haven't already been converted will be downloaded, allowing you to | |
# schedule the script to run as often as needed without stressing your internet connection or | |
# hard drive space. After generating the files and xml, you can easily host them on a local server | |
# in order to use them with iTunes or your favorite podcast aggregator -- but that's beyond this | |
# script's jurisdiction. |
This file contains 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 java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
@Retention( RetentionPolicy.RUNTIME ) | |
@Target( { | |
java.lang.annotation.ElementType.METHOD | |
} ) | |
public @interface Repeat { | |
public abstract int times(); |
This file contains 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
var ISBN = (function(){ | |
"use strict"; | |
var validateISBN13 = function(isbnChars){ | |
var checksum = 0; | |
isbnChars.forEach(function(isbnChar, key){ | |
checksum += parseInt(isbnChar, 10) * (key % 2 === 1 ? 3 : 1); | |
}); |
OlderNewer