Skip to content

Instantly share code, notes, and snippets.

Yehonathan Sharvit viebel

Block or report user

Report or block viebel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
viebel / replace_string_in_files
Last active Aug 29, 2015
Replace String in files
View replace_string_in_files
find . | xargs grep -wl ugly | xargs sed -i .bak 's/\<ugly\>/nice/g'
viebel / nameOfArgs
Created Feb 27, 2014
In javascript, retrieve the names of the arguments
View nameOfArgs
function namesOfArgs(fn) {
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,
FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m,
fnText = fn.toString().replace(STRIP_COMMENTS, ''),
argDecl = fnText.match(FN_ARGS);
return argDecl[1].split(FN_ARG_SPLIT)
viebel / get-it.clj
Last active Aug 29, 2015
Clojure Macros: get-it, assoc-it
View get-it.clj
;;First rule of macros: Don't write a macro if you a function can do the job!
(defn assoc-it[obj & more]
(let [path (vec (drop-last 1 more))
val (last more)]
(assoc-in obj path val)))
(assoc-it {:a {:b 6}} :a :b 5 ) ;; {:a {:b 5}}
(defn get-it[obj & path]
viebel / js_fun_loop.js
Created Aug 22, 2012
javascript: function defined inside a loop
View js_fun_loop.js
var numbers = [1,2,3];
for (var i = 0, n = numbers.length; i<n; i++) {
var num = numbers[i];
setTimeout(function() {
}, 0);
viebel / concatenated_words.clj
Last active Nov 22, 2015
given a string, determine whether it is a concatenation of english words
View concatenated_words.clj
; given a string, determine whether it is a concatenation of english words
; string of digits only is considered an english word
; assume that strings are lower cased
; empty string: don't care
(defn word? [w]
(or (re-matches #"[0-9]" w)
(contains? #{"go" "hi" "my" "cat" "is" "nice" "mymy" "mymymy"} w)))
viebel / colums
Last active Dec 13, 2015
print columns
View colums
column <FILENAME> -ts,
View foo.cljs
(defn square [x] (* x x))
View bar.cljs
(:require [ :refer [square]]))
(defn square-square [x] (square (square x)))
viebel / color.cljs
Last active May 26, 2016
color me in red
View color.cljs
(ns viebel.gist-368d3bec58d3ec47e935ad488bafb600.raw.color
(:require [viebel.gist-3800b8ebae5292921c7d6fcb6c995c1f.raw.body-color :refer [set-bg-color]]))
(set-bg-color "blue")
viebel / dump-1464465949284.cljs
Created May 28, 2016
ClojureScript REPL dump
View dump-1464465949284.cljs
cljs.user=> (ns my.ns$macros)
my.ns$macros=> (defmacro hello[x] x)
my.ns$macros=> (my.ns/hello 19)
You can’t perform that action at this time.