Skip to content

Instantly share code, notes, and snippets.

@djKianoosh
djKianoosh / HKCU-Software-Microsoft-CommandProcessor.reg
Last active October 2, 2015 01:38
UNIX-like aliases in Windows
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
"CompletionChar"=dword:00000009
"DefaultColor"=dword:00000000
"EnableExtensions"=dword:00000001
"PathCompletionChar"=dword:00000009
"AutoRun"=hex(2):25,00,55,00,53,00,45,00,52,00,50,00,52,00,4f,00,46,00,49,00,\
4c,00,45,00,25,00,5c,00,70,00,72,00,6f,00,66,00,69,00,6c,00,65,00,2e,00,62,\
00,61,00,74,00,00,00
@djKianoosh
djKianoosh / gist:2648751
Created May 9, 2012 20:55
Some Clojure functions to help read custom access log files into maps
(defn comment? [s]
(.startsWith s "#"))
(defn not-comment? [s]
(not (comment? s)))
(defn remove-comments [line]
(filter not-comment? line))
(defn nil-if-hyphen [s]
@djKianoosh
djKianoosh / gist:2653859
Created May 10, 2012 15:19
Change *print-right-margin* in Clojure REPL
(defmacro with-ns
"Evaluates body in another namespace. ns is either a namespace
object or a symbol. This makes it possible to define functions in
namespaces other than the current one."
[ns & body]
`(binding [*ns* (the-ns ~ns)]
~@(map (fn [form] `(eval '~form)) body)))
(with-ns 'clojure.pprint (def ^:dynamic *print-right-margin* 140))
@djKianoosh
djKianoosh / super-shake.cljs
Created September 13, 2012 12:30 — forked from foogoof/super-shake.cljs
Shakes a DOM element
(defn super-shake [item value]
(start (apply bind item (mapcat (fn [dist] [{:effect :slide, :left dist, :time 375}
{:effect :slide, :left (- dist), :time 375}])
(range 500 0 -100)))))
@djKianoosh
djKianoosh / List-of-lists-from-hasDup-isDup.js
Created November 4, 2012 00:29
Create list of lists from a single list with hasDup and isDup flags
var expected = [
[
{item:"aa", hasDup:"false", isDup:"false"}
],
[
{item:"b1", hasDup:"true", isDup:"false"},
{item:"b2", hasDup:"true", isDup:"true"}
],
[
{item:"cc", hasDup:"false", isDup:"false"}
@djKianoosh
djKianoosh / _.merge.js
Last active December 26, 2015 03:59
Underscore mixin to merge objects; last item takes precedence (uses _.extend not _.default)
/**
* Underscore mixin to merge objects; last item takes precedence (uses _.extend not _.default)
**/
_.mixin({
merge : function() {
return _.reduce(arguments, function(list, obj){
return _.extend(list, obj);
}, {});
}
@djKianoosh
djKianoosh / ie-shims.js
Created October 21, 2013 20:36
IE shims for array indexOf, string startsWith and string trim
// Some common IE shims... indexOf, startsWith, trim
/*
Really? IE8 Doesn't have .indexOf
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this === null) {
throw new TypeError();
@djKianoosh
djKianoosh / _.safeString.js
Created October 21, 2013 20:39
just being overly safe with strings
//Be safe out there; Check for undefined, null and 'null' and return an empty string
_.mixin({
safeString : function(value) {
return (typeof value !== 'undefined' && value !== null && value !== "null") ? value : "";
}
});
@djKianoosh
djKianoosh / listen.clj
Created November 13, 2013 03:52
clojurescript way to listen to a button click on an element
; (:require
; [goog.dom :as dom]
; [goog.events :as events])
(defn log [msg]
(js/console.log msg))
(defn listen [el type f]
(let [e (dom/getElement el)]
(events/listen e type (partial f))))
@djKianoosh
djKianoosh / ._ gradle starter _.
Last active March 11, 2017 16:58
Example gradle starter + spring mvc + some gradle tools
.