Skip to content

Instantly share code, notes, and snippets.

@thetristan
thetristan / Main.scala
Created June 23, 2017 13:57
libcurl w/ scala-native
import scala.scalanative.native
import native._
@native.link("curl")
@native.extern object curl {
import CurlTypes._
@native.name("curl_global_init")
def globalInit(flags: native.CLong): native.Ptr[Byte] = native.extern
@thetristan
thetristan / diff_url
Created August 6, 2013 21:57
Compare two URLs (headers and response body) with curl: $ diff_url http://foobar.com http://bazqux.com
#!/bin/bash
# Diff the headers and response body of two different urls with curl
NAME=`basename $0`
COMMAND="diff <(curl -is '$1') <(curl -is '$2')"
if [ $# -ne 2 ]
then
echo "Usage: $NAME <http://foobar.com> <http://bazqux.com>" 1>&2
exit 1
isFn = (fn) -> typeof fn is 'function'
multiMap = (coll, [fn, fns...]...) ->
return coll unless isFn fn
multiMap map(coll, fn), fns...
# Usage:
# multiMap myCollection, fn1, fn2, fn3
o =
a: 'foo'
b: 'bar'
p = map o, (val, key) ->
object [[k,v]]
var bh = require('bulk-hogan');
bh.baseDirectory = 'foo';
var bh2 = { prototype: bh };
console.log(bh.baseDirectory, bh2.baseDirectory);
bh2.baseDirectory = 'bar';
@thetristan
thetristan / curry.coffee
Last active December 17, 2015 11:29
Currying w/ CoffeeScript
partial = (fn, args...) ->
(innerArgs...) ->
args = args.concat(innerArgs)
fn(args...)
curry = (fn, arity = fn.length) ->
(args...) ->
innerFn = (arity) ->
if arity > 0
curry partial(fn, args...), arity
--noheading
--ignore-dir=public/assets
--ignore-dir=public/javascripts/cache
--ignore-dir=db
--ignore-dir=log
--type-add=js=.mustache
--type-set=coffee=.coffee,.cakefile
--type-set=tests=.spec,.feature,.rb
--type-set=ruby=.rb,.rhtml,.rjs,.rxml,.erb,.rake,.haml,.mustache
--type-set=mustache=.mustache
@thetristan
thetristan / git-fresh
Created May 23, 2012 23:17
Quick shell script to check the freshness of your git branches
#!/bin/bash
# ## git-fresh
#
# Author: Tristan Blease <[email protected]>
# Website: tristanblease.com
# License: http://www.opensource.org/licenses/MIT
#
# Quick shell script to check the freshness of your git repository branches
#
@thetristan
thetristan / gist:2704924
Created May 15, 2012 20:36
Start tmux on ssh login
# Taken from http://william.shallum.net/random-notes/automatically-start-tmux-on-ssh-login
if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
then
STARTED_TMUX=1; export STARTED_TMUX
sleep 1
( (tmux has-session -t remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0
echo "tmux failed to start"
fi
@thetristan
thetristan / gist:1936640
Created February 29, 2012 00:51
ExpressionEngine Loop/Split Template Pseudo Code
{!-- Looping and splitting entries --}
{exp:channel:entries channel="foo"}
{if count == 1}
<ul>
{/if}
<li>{bar}</li>
{if count == total_results}