Skip to content

Instantly share code, notes, and snippets.

View clojens's full-sized avatar

Rob Jentzema clojens

View GitHub Profile
@clojens
clojens / main.clj
Created September 3, 2013 22:12 — forked from lynaghk/main.clj
;;Using the Cassowary constraint solver from ClojureScript
;;This demo shows using multimethods for readable constraint syntax using +, -, and =.
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform.
(ns c2.main
;;refer-clojure :exclude is currently broken in ClojureScript master
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude
(:refer-clojure :exclude [+ - =])
; http://www.algolist.com/Dijkstra's_algorithm
(defn dijkstra [g src]
(loop [dsts (assoc (zipmap (keys g) (repeat nil)) src 0)
curr src
unvi (apply hash-set (keys g))]
(if (empty? unvi)
dsts
(let [unvi (disj unvi curr)
nextn (first (sort-by #(% dsts) unvi))

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@clojens
clojens / re.clj
Created December 12, 2013 17:58
A few clojure java regex samples
(def ptrn
{
:a {:pattern #"a(?!b)"
:purpose "Only allow a if it is not preceded by a 'b' (negative lookahead)"
:samples ["acdefg" ; ok
"abcdef" ; nil
]}
:b {:pattern #"(?i)(<title.*?>)(.+?)(</title>)"
@clojens
clojens / modal.phtml
Last active August 29, 2015 14:05
Magento Modal form
<?php
/**
* jQuery Avgrund Modal signup form
*
* Template for modal forms used in sign-up of marketing campaigns, promotional
* activities and other commercial activities which require modal windows to
* (loosely) enforce registration of information upon users of that application.
*
* PHP version 5.4
*
@clojens
clojens / w3c_uri_abnf.clj
Created August 23, 2014 18:20
RFC 3986 Uniform Resource Identifier (URI): Generic Syntax
;;
;; Copied from the w3c document and swapping quoting (double -> single)
;; for benefit of inline LightTable and Instaparse operability
;;
;; http://tools.ietf.org/html/rfc3986[RFC 3986 URI Generic Syntax 2005]
;;
(require '[alembic.still :refer [distill* distill]]
'(instaparse [core :as insta]
[combinators :as ipcombo]))
// ==UserScript==
// @name URL Observer Addon
// @namespace anon
// @match http://*/*
// @match https://*/*
// @exclude http://localhost/*
// @version 2
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_info
// @grant metadata
@clojens
clojens / foo.zsh
Last active August 29, 2015 14:06
ZSH script tested and I need raw since no paste console yet.
: ${(AA)=sgd::= ef02:bios 1:0:+2M
8300:boot 2:0:+200M
8300:root 3:0:+3G
8300:usr 4:0:+10G
8300:local 5:0:+5G
8300:opt 6:0:+5G
8300:var 7:0:+13G
8300:srv 8:0:+4G
8300:home 9:0:+8G
8200:swap 10:0:0
@clojens
clojens / 01.zsh
Last active August 29, 2015 14:06
Zsh Arch virtualbox install manual scripted
#!/usr/bin/env zsh
: ${(AA)=tokens::=
nil \\u0000 back \\u0008 feed \\u000A cret \\u000D esc \\u001B bang \\u0021 dquote \\u0022
pound \\u0023 dollar \\u0024 perc \\u0025 amp \\u0026 quote \\u0027 popen \\u0028 pclose \\u0029
star \\u002A plus \\u002B comma \\u002C dash \\u002D dot \\u002E slash \\u002F colon \\u003A
semic \\u003B hopen \\u003C equals \\003D hclose \\003E qmark \\003F at \\u0040 bopen \\u005B
bslash \\u005C bclose \\u005D uscore btick \\u0060 \\u005F copen \\u007B pipe \\u007C cclose \\u007D
nbsp \\u00A0 zwsp \\u200B wordj \\u2060 ideo \\u3000 zwnbsp \\uFEFF
}
@clojens
clojens / code.asciidoc
Last active August 29, 2015 14:07
golden rules?
  1. use fairly short, easy to read identifiers for high-use, limited-scope variables

  2. use longer, more descriptive names for less often seen identifiers

  3. use variable names that give an idea of their purpose (see K&R for examples)

  4. ensure identifiers are long enough and different enough to be easily distinguished

  5. ensure identifiers are easily remembered (i.e. not a random jumble of letters)

  6. give a full description of the purpose of a variable in a comment where it is declared

Taken from an article on programming C but you will see this in practice in Clojure as well: