Skip to content

Instantly share code, notes, and snippets.

@djKianoosh
djKianoosh / hellostaticplug.ex
Last active January 6, 2016 13:25
Minimalistic elixir starter... index from priv, all other static from priv/static, and remaining catch all to hello world
defmodule Hellostaticplug do
use Plug.Router
plug Plug.Static, at: "/static", from: :hellostaticplug
plug :match
plug :dispatch
get "/" do
Plug.Conn.send_file(conn, 200, "priv/index.html")
end
@djKianoosh
djKianoosh / mycd.sh
Last active November 6, 2015 20:30 — forked from leipzig/mycd.sh
directory based history bash profile
function cd_dir_history()
{
OLDPWD="$PWD"
echo "# $(date) $USER -> $@" >> "$HISTFILE"
command cd "$@"
# If this directory is writable then write to directory-based history file
# otherwise write history in the usual home-based history file.
touch "$PWD/.dir_bash_history" 2>/dev/null \
(function (root, definition) {
var _module_name = "myModule";
if (typeof define === 'function' && define.amd) {
define(['jquery', 'lodash'], function($, _){
return (root[_module_name] = definition($, _));
});
} else {
root[_module_name] = definition($, _);
}
@djKianoosh
djKianoosh / ._ gradle starter _.
Last active March 11, 2017 16:58
Example gradle starter + spring mvc + some gradle tools
.
@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 / _.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 / 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 / _.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 / 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 / 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)))))