Skip to content

Instantly share code, notes, and snippets.

View andykant's full-sized avatar

Andy Kant andykant

View GitHub Profile
@andykant
andykant / app.html
Last active December 21, 2015 04:48
Tabs component in Angular
<!doctype html>
<html ng-app="App">
<head>
<script src="http://code.angularjs.org/1.2.0rc1/angular.js"></script>
<script src="tabs.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="tabs.css" />
</head>
<body>
<div ng-controller="Ctrl1">
@andykant
andykant / andykant.tmTheme
Last active December 17, 2015 10:19
My TextMate theme modified for SublimeText
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>andykant</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@andykant
andykant / kmp_search.coffee
Created November 24, 2011 03:39
CoffeeScript implementation of the Knuth–Morris–Pratt (KMP) algorithm
# http://en.wikipedia.org/wiki/KMP_algorithm
kmp_tables = {}
kmp_search = (haystack, needle) ->
# compute/cache the lookup table for this needle
lookup = kmp_tables[needle] = kmp_tables[needle] || (->
[pos, sub, table] = [2, 0, [-1, 0]]
while pos < needle.length
if needle[pos-1] == needle[sub]
sub++
table[pos] = sub
@andykant
andykant / buffertools-indexOf.js
Created April 1, 2011 07:28
buffertools.indexOf sometimes returns -1 instead of the expected value for this particular buffer.
var util = require('util'),
buffertools = require('buffertools'),
buffer = new Buffer("9A8B3F4491734D18DEFC6D2FA96A2D3BC1020EECB811F037F977D039B4713B1984FBAB40FCB4D4833D4A31C538B76EB50F40FA672866D8F50D0A1063666721B8D8322EDEEC74B62E5F5B959393CD3FCE831CC3D1FA69D79C758853AFA3DC54D411043263596BAD1C9652970B80869DD411E82301DF93D47DCD32421A950EF3E555152E051C6943CC3CA71ED0461B37EC97C5A00EBACADAA55B9A7835F148DEF8906914617C6BD3A38E08C14735FC2EFE075CC61DFE5F2F9686AB0D0A3926604E320160FDC1A4488A323CB4308CDCA4FD9701D87CE689AF999C5C409854B268D00B063A89C2EEF6673C80A4F4D8D0A00163082EDD20A2F1861512F6FE9BB479A22A3D4ACDD2AA848254BA74613190957C7FCD106BF7441946D0E1A562DA68BC37752B1551B8855C8DA08DFE588902D44B2CAB163F3D7D7706B9CC78900D0AFD5DAE5492535A17DB17E24389F3BAA6F5A95B9F6FE955193D40932B5988BC53E49CAC81955A28B81F7B36A1EDA3B4063CBC187B0488FCD51FAE71E4FBAEE56059D847591B960921247A6B7C5C2A7A757EC62A2A2A2A2A2A2A25552591C03EF48994BD9F594A5E14672F55359EF1B38BF2976D1216C86A59847A6B7C4A5C585A0D0A2A6D9C8F8B9E999C2A836F786D577A798
@andykant
andykant / mass_google_translate_bookmarklet.js
Created June 17, 2010 16:33
A mass Google Translate bookmarklet
/*
1. Copy the compressed version into a bookmark address
2. Go to Google Translate: http://translate.google.com/
3. Paste your message block in the textarea (default delimiters are new lines for each message and '=' to separate the key/value
4. Click the bookmarklet
5. The result is injected back into the textarea, focused, and selected
6. Copy + paste back into your message file
Note: Strings with special characters (like HTML) may result in inaccurate results and should be done manually
*/
// Provides a device_scale class on iOS devices for scaling user
// interface elements relative to the current zoom factor.
//
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari
// Copyright (c) 2010 37signals.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// See comments below.
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
e = "elf",
f = "fly",
g = "gnu",
#!/opt/local/bin/zsh
PROJECT_PATH=$HOME/Projects/project
PROJECT_JAR=$PROJECT_PATH/java-libraries
PROJECT_MAIN=$PROJECT_PATH/main
PROJECT_TEST=$PROJECT_PATH/test
PROJECT_JSAPI=$PROJECT_PATH/docs/jsapi/index.html
PROJECT_SELENIUM=$PROJECT_JAR/selenium
PROJECT_SELENIUM_SERVER=selenium-server-1.0.3.jar
PROJECT_KERBEROS=project@project.com
/*
Form Elements
-- Styled to look like native Safari on OS X.
-- Drop-down <select> menus are unaffected.
-- Buttons are unaffected. Native OS style.
*/
input,
button,
select,
/* Use this to cause a function to fire no more than once every 'ms' milliseconds.
For example, an expensive mousemove handler:
$('body').mouseover(ratelimit(function(ev) {
// ...
}, 250));
*/
function ratelimit(fn, ms) {
var last = (new Date()).getTime();