Skip to content

Instantly share code, notes, and snippets.

// reporting library
// http://stackoverflow.com/questions/9160001/how-to-profile-methods-in-scala
def perf[R](block: => R): Unit = {
val t0 = System.nanoTime()
for(_ <- 1 to 1000000) block
val t1 = System.nanoTime()
val elapsed = (t1 - t0) / 1000000000f
println("Elapsed time: " + elapsed + "s")
@tstone
tstone / checklist.md
Last active December 25, 2015 22:28
AC/Design Checklist

Titles/Text

  • How is overflow handled?
  • What is the behavior if the text/title is empty?

Links

  • Where does it go?

Images

@tstone
tstone / smack-lang.scala
Created August 31, 2013 06:35
A little evening project to test a proof of concept idea about turning SMACSS into it's own language.
import scala.util.parsing.combinator.JavaTokenParsers
object Parser extends JavaTokenParsers {
object Renderer {
def render(ms: List[Module]): String = {
// Assemble a map
val names = ms.map(_.name)
val modules = Map(names.zip(ms).toArray: _*)
@tstone
tstone / jquery_on_many.js
Created October 19, 2012 19:26
Jquery on multiple events (untested)
// Javascript
jQuery.fn.on_original = jQuery.fn.on;
jQuery.fn.on = function() {
var args = Array.prototype.slice.call(arguments, 0);
var events = args[0];
var params = args.slice(1);
events.split(' ').forEach(function(ev) {
var eventArgs = params.slice(0).unshift(ev);
jQuery.fn.on_original.apply(this, eventArgs);
}.bind(this));
@tstone
tstone / gist:3860011
Created October 9, 2012 16:53
Git cheat sheet
# Download the repo the first time
git clone git://github.com.....
# Update the whole repo with everything
git pull
# Update from a specific branch
git pull origin release
# Bring in only 1 commit
<input type="checkbox" data-represents="voting" />
$('input[type="checkbox"]').change(function() {
var represents = $(this).attr('data-represents');
$('[data-' + represents +'="true"]').show();
});
<div data-voting="true"></div>
<!DOCTYPE html>
<html>
<head>
<title>Examples</title>
<!-- Tags have a default attribute which can be ommitted -->
<meta="keywords" content="template language" />
<meta="author" content="template language" />
<script>
@tstone
tstone / gist:3759820
Created September 21, 2012 05:08
A ruby script to make running coffeelint a bit easier
#!/usr/bin/env ruby
#
# Use:
#
# => cfl
# => cfl all
# => cfl last
# => cfl last 3
#
@tstone
tstone / longhand.slim
Created September 13, 2012 22:41
Template Comparison
#
# Slim Using Longhand (full tags)
# slim-lang.org
#
<!DOCTYPE html>
<html>
<head>
<title>Slim Examples</title>
@tstone
tstone / gist:3364269
Created August 15, 2012 22:22
Divide by 3 (javascript)
<!DOCTYPE>
<html>
<body>
<script type="text/javascript">
var base10 = {
increment: function(v) {
var incrementBit = function(bits) {
var b = bits[0];
if (b == '0') {
bits.splice(0, 1, '1');