Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| function simpleSearch(text, str) { | |
| var matches = []; | |
| for (var i = 0; i <= text.length; i++) { | |
| if (matchesAtIndex(i, text, str)) { | |
| matches.push(i); | |
| } | |
| } | |
| return matches; | |
| } |
| package models | |
| import anorm._ | |
| import anorm.SqlParser._ | |
| import play.api.db.DB | |
| import play.api.Play.current | |
| case class Destination(id: Long, originalUrl: String, shortUrlHash: String) | |
| object Destination { |
| # Simple bijective function | |
| # Basically encodes any integer into a base(n) string, | |
| # where n is ALPHABET.length. | |
| # Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047 | |
| ALPHABET = | |
| "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//) | |
| # make your own alphabet using: | |
| # (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join |
| #!/Users/dustyeike/.rvm/rubies/ruby-1.9.2-p290/bin/ruby | |
| require "rubygems" | |
| require "test/unit" | |
| require "date" | |
| EPOCH = Date.new(1970, 1, 1) | |
| # | |
| # Returns the number of seconds from the epoch to date | |
| def epoch_seconds date |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| /** | |
| * Quick and Easy Integration of Google URL Shortener API in your Java Applications using Scribe-Java and GSon | |
| * http://codeoftheday.blogspot.com/2013/07/quick-and-easy-integration-of-google.html | |
| */ | |
| package smhumayun.codeoftheday.google.urlshortener; | |
| import com.google.gson.GsonBuilder; | |
| import com.google.gson.reflect.TypeToken; | |
| import org.scribe.builder.ServiceBuilder; | |
| import org.scribe.builder.api.GoogleApi; |
| val regex = """mongodb://(\w+):([\w|-]+)@([\w|\.]+):(\d+)/(\w+)""".r | |
| url match { | |
| case Some(regex(u, p, host, port, dbName)) => | |
| ConnectionParams(host, port.toInt, dbName, u, p) | |
| case None => { | |
| ConnectionParams("127.0.0.1", 27017, "mylocaldb") | |
| } |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading…</strong>";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://gist.github.com/ttscoff/6109434/raw/Bullseye.js?x="+(Math.random());})(); |
The diff output is more specific:
[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.
>The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.