Skip to content

Instantly share code, notes, and snippets.

View simshanith's full-sized avatar
p̟̖̹h̯͎͙̺̤̤ͅi̜l͓͖̟͎̬̺̰o̧̻̝͖͍̻̥s̝̪̪̣͕o͍̮͖r̛̦̲̫̱̞̜̞a̸͎p͇͙̪̀t͇͖ò̙̦͈̘̣ṛ̟͕

Shane Daniel simshanith

p̟̖̹h̯͎͙̺̤̤ͅi̜l͓͖̟͎̬̺̰o̧̻̝͖͍̻̥s̝̪̪̣͕o͍̮͖r̛̦̲̫̱̞̜̞a̸͎p͇͙̪̀t͇͖ò̙̦͈̘̣ṛ̟͕
View GitHub Profile
/* originally written by Chouser. taken from clojure google group, http://groups.google.com/group/clojure
discussion title: clojure -> javascript
http://groups.google.com/group/clojure/browse_frm/thread/83c3c18951a764e2/62d630249e75599c?#62d630249e75599c
Some (hopefully annotated) additions are by Shane Daniel.
of note: Karl Krukow's streamlined port of Clojure data structures to Java.
https://github.com/krukow/clj-ds
*/
// goog.require('goog.structs.LinkedMap');
goog.provide('sim.examples.linkedMap_');
sim.examples.linkedMap_.getKeyByIndex = function getKeyByIndex(i, lMap) {
return lMap.getKeys()[i];
};
sim.examples.linkedMap_.getValueByIndex = function getValueByIndex(i, lMap) {
return lMap.getValues()[i];
<!DOCTYPE html>
<html class="en">
<head>
<meta charset="utf-8">
<title>Example Facebook Page Like Box</title>
</head>
<body>
<div id="fb-root"></div>
<div id="main-wrapper" style="height: 100%;">
</div><!-- end main wrapper -->
// example anonymous function
var doop = (function(){var thisFunc = arguments.callee; thisFunc.foo = 'bar'; return arguments.callee.foo;});
// returns null
doop.foo;
// ...until it's called once. both return "bar".
doop();
doop.foo;
@simshanith
simshanith / Example Backbone app JS skeleton.html
Last active December 12, 2015 06:08
Example Backbone app JS skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example Backbone Skeleto</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<style>
.hidden{
display: none !important;
}
@simshanith
simshanith / windowScroll.js
Last active December 15, 2015 06:19
Progressively enhanced cross-browser scrolling, via Modernizr, jQuery Transit, and classic $.scrollTo fallback
var sliding = false; // variable outside function scope to detect a slide is in progress
function slideTo(target, duration){ // credit to Mahieddine Abdelkader & Ludwig Wendzich for original ideas.
var to = isNaN(target) ? $(target).offset().top : target, //find scroll to position
from = $(window).scrollTop() //find starting point
dy = to-from, //calculate change in scroll position - deltaY
body = $("body"), // TODO: better to have it outside of local scope already rather than fetching it every time...
duration = isNaN(duration) ? 500 : duration;
// We're going to use translate-y to move the the page so it feels like we're at the *from* scroll position, when we're actually instantly at the *to* scroll position. */
@simshanith
simshanith / querystring.js
Created April 5, 2013 15:53
Pull name/value pairs from URL query string
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}
@simshanith
simshanith / gruntfile.js
Last active December 15, 2015 20:49
Grunt file that builds Stylus, Jade, & minified JavaScript, and watches for changes to source files.
module.exports = function(grunt) {
// Load all of our NPM tasks...
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-stylus');
@simshanith
simshanith / example.dev.html
Last active December 16, 2015 15:29
Building dev & production HTML with Jade & Grunt.
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!-->
<html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Example Jade Template</title>
<script src="/_assets/js/modernizr-2.6.2.min.js"></script>
</head>
<body>
<h1>Example Jade Template</h1>
14:13:10 ⑆ [sdaniel@sim-vmlmac]
~/Code/gcom-static/trunk
svn [✓]
λ cp -vf htdocs/_assets/css/*.css ~/Code/gcom/trunk/src/gcom/_assets/css/
λ cp -vf htdocs/_assets/js/*.js ~/Code/gcom/trunk/src/gcom/_assets/js/
λ svn export htdocs/_assets/images/ ~/Code/gcomimages/
λ cp -rvf ~/Code/gcomimages/ ~/Code/gcom/trunk/src/gcom/_assets/images/
λ svn export htdocs/science-of-g/_assets/ ~/Code/sogAssets/
λ cp -rvf ~/Code/sogAssets/ ~/Code/gcom/trunk/src/gcom/science-of-g/_assets/