Skip to content

Instantly share code, notes, and snippets.

@shafeeq
shafeeq / snippets.sh
Created September 10, 2018 14:09
Snippets
# Log all commands in zsh to files
export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history | tail -n 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'
prmptcmd() { eval "$PROMPT_COMMAND" }
precmd_functions=($precmd_functions prmptcmd)
@shafeeq
shafeeq / spec-serialization.clj
Created April 5, 2017 10:04
Spec Serialization
(require '[clojure.spec :as sp])
(defn dependencies [spec]
(let [deps (atom [])]
(clojure.walk/prewalk
(fn [x]
(if ((sp/registry) x)
(do (swap! deps conj x)
(sp/form x))
x))
(ns cljs-hello.debounce
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [reagent.core :as r]
[cljs.core.async :refer [>! <! chan sliding-buffer timeout]]))
(defn button
[text on-click-callback]
[:div
[:p
[:button {:class "btn btn-info btn-lg"
(ns playsync.pipeline
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go chan buffer close! thread alts! alts!! timeout alt! pipeline-async]]
[clojure.tools.logging :as log]))
(defn api-call
[success-rate]
(do
(Thread/sleep (+ 100 (rand-int 200)))
@shafeeq
shafeeq / combination.c
Created September 18, 2013 12:27
Non repeating combinations of alphabets in a string of specified length
#include <stdio.h>
void generate(int n, char set[27], int n1, char s[27]/*, char c[27],int count*/)
{
int i, j;
char c;
if(n1 == 1){
for(i = 0; i < 26; i++){
if(set[i] != '#'){
for(j = 0; j < n-1; j++)
printf("%c",s[j]);