Skip to content

Instantly share code, notes, and snippets.

<!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>
<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>
@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
@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 / 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 / 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

// 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")
// reporting library
// http://stackoverflow.com/questions/9160001/how-to-profile-methods-in-scala
def perf[R](block: => R): Unit = {
val t0 = System.nanoTime()
block
val t1 = System.nanoTime()
val elapsed = (t1 - t0) / 1000000000f
println("Elapsed time: " + elapsed + "s")
implicit class Unlessable[A](a: => A) {
def unless(p: => Boolean) = if (!p) Some(a) else None
}
implicit class Iffable[A](a: => A) {
def iff(p: => Boolean) = if (p) Some(a) else None
}
// Class
package presenters.poiattributes
import scala.language.implicitConversions
import play.api.templates.Html
trait AttributePresenter {
val identifier: String
val value: Any