Skip to content

Instantly share code, notes, and snippets.

View emh's full-sized avatar

Evan Haveman emh

View GitHub Profile
@emh
emh / gist:7441569
Created November 13, 2013 00:43
I wanted to use a bunch of underscore.string (http://epeli.github.io/underscore.string/) functions as filters in an AngularJS project and rather than writing separate filters for each function I came up with this.
/**
* call titleize like:
* {{ expression | _str.'titleize' }}
* call truncate like:
* {{ expression | _str:'truncate':5:'...' }}
* etc.
*/
app.filter('_str', function() {
return function(text, fn) {
var args = Array.prototype.slice.call(arguments, 2);
@emh
emh / gist:329963
Created March 12, 2010 01:58
Javascript Partials - because I hate seeing HTML embedded in my Javascript code.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>javascript partials</title>
<script src="http://code.jquery.com/jquery-1.4.1.min.js" type="text/javascript"></script>
<script>
function createHello() {
var name = $('#name_field').attr('value');
@emh
emh / keybase.md
Last active August 29, 2015 14:06

Keybase proof

I hereby claim:

  • I am emh on github.
  • I am emh (https://keybase.io/emh) on keybase.
  • I have a public key whose fingerprint is 868F 95FA 4A0F 12D6 D8CF B181 A015 74A0 3833 02F2

To claim this, I am signing this object: