Skip to content

Instantly share code, notes, and snippets.

(defn force-login [app]
(fn [req]
(println "force-login: ****** " req "******")
(if (or (= "/login" (:uri req)) (:user (:session req)))
(app req)
(resp/redirect "/login"))))
@jclosure
jclosure / jquery-tmpl.js
Created October 24, 2010 07:01
Modification to jquery-tmpl works with IE when you have an attribute value with spaces in it.
/*
* jQuery Templating Plugin
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
*/
(function (jQuery, undefined) {
var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
function newTmplItem(options, parentItem, fn, data) {
@jclosure
jclosure / cli github repo
Last active September 13, 2016 07:31
create github repo from cli
CLI commands for github API v3 (replace all CAPS keywords):
git init
git add .
git commit -am "initial commit"
curl -u 'USER:PASS' https://api.github.com/user/repos -d '{"name":"REPO"}'
git remote add origin git@github.com:USER/REPO.git
git push origin master
@podlech
podlech / yosemite_ruby_libv8_therubyracer.sh
Last active November 1, 2016 11:02
OS X Yosemite ruby (1.9.3p484) libv8 (3.11.8.17) therubyracer (0.11.4)
brew install homebrew/dupes/apple-gcc42
rbenv install 1.9.3-p484
rbenv global 1.9.3-p484
git clone https://github.com/cowboyd/libv8.git
cd libv8
git checkout 3.11
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
bundle install
@bj0
bj0 / jinja2.ipynb
Created April 9, 2013 05:55
IPython Custom Cell Magic for Rendering Jinja2 Templates
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from abc import abstractmethod
from itertools import chain, imap
from typing import Any, Iterable
from typing import Callable, Generic, List
from typing import TypeVar
A = TypeVar('A')
B = TypeVar('B')
C = TypeVar('C')
@jclosure
jclosure / sample.org.gpg
Created October 21, 2020 17:49
Org-file header to be automatically encrypted/decrypted
HeadlineTime
Total time0:00
@3demax
3demax / tabbar-tweak.el
Created October 5, 2011 14:58
Emacs tabbar-mode visual tweaks
;; This are setting for nice tabbar items
;; to have an idea of what it looks like http://imgur.com/b0SNN
;; inspired by Amit Patel screenshot http://www.emacswiki.org/pics/static/NyanModeWithCustomBackground.png
;; Tabbar
(require 'tabbar)
;; Tabbar settings
(set-face-attribute
'tabbar-default nil
:background "gray20"
@Rpsl
Rpsl / terminal.sh
Last active May 25, 2021 19:28
Open iTerm terminal from PhpStorm ( NativeNeighbourhood plugin );
cd ~/Library/Application\ Support/WebIde70/NativeNeighbourhood/classes/org/intellij/plugins/nativeNeighbourhood/icons/macosx
echo '#!/bin/sh
#
# Reveal a directory in the Terminal.
#
# The script takes one argument, the qualified name of a directory.
#
# Note that the script is necessary because osascript before osx 10.4 could not
# pass arguments.
@ulve
ulve / remoteobserver.sh
Created February 2, 2016 20:19
Connect to remote phoenix node with observer
# On the phoenix node
# if production mode
MIX_ENV=prod PORT=4001 elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -pa _build/prod/consolidated -S mix phoenix.server
# if debug mode
elixir --name phoenix@127.0.0.1 --cookie 123 --erl "-kernel inet_dist_listen_min 9001 inet_dist_listen_m 9001" -S mix phoenix.server
# On the observing node
# Terminal 1, start SSH tunnel
ssh -N -L 9001:localhost:9001 -L 4369:localhost:4369 pi@192.168.1.31