Skip to content

Instantly share code, notes, and snippets.

@nikopol
nikopol / redis-del.fish
Created August 2, 2021 14:56
fish fn to delete multiple keys in a redis at once
function redis-del
set cmd (status current-command)
set _flag_host 'localhost'
set _flag_port '6379'
set _flag_db '0'
argparse 'help' 'h/host=' 'p/port=' 'n/db=' -- $argv
if test -n "$_flag_help" -o -z "$argv"
test -z "$argv"; and echo -e "missing key!\n"
echo "delete multiple keys in a redis at once"
echo
@nikopol
nikopol / setup-groot
Created March 30, 2021 04:00
setup groot
#!/bin/bash
echo -e '
\033[00;32m \\^V//
\033[00;33m |\033[01;37m. \033[01;37m.\033[00;33m| \033[01;34m I AM (G)ROOT!
\033[00;32m- \033[00;33m\\ - / \033[00;32m_
\033[00;33m \\_| |_/
\033[00;33m \\ \\
\033[00;31m __\033[00;33m/\033[00;31m_\033[00;33m/\033[00;31m__
\033[00;31m|_______| \033[00;37m With great power comes great responsibility.
@nikopol
nikopol / koco.js
Last active January 4, 2021 09:01
happy new year!
(() => {
let p = 0;
const
ucb = p => new Promise(r => r(alert('happy new year!'))),
l = () => document.addEventListener('keydown', el),
cb = () => ucb(document.removeEventListener('keydown', el)).then(l),
k = [76,82,85,68,97,98],
co = [2,2,3,3,0,1,0,1,5,4],
el = e => {
p = k[co[p]] - e.key.charCodeAt(Math.min(e.key.length-1, 5)) ? 0 : ++p===10 ? cb()||0 : p;
function fish_greeting
if status --is-interactive
/home/niko/bin/hi -s
end
end
set fish_term256 1
set -gx PATH ~/bin $PATH
if test -z $DISPLAY; and test "$XDG_VTNR" = "1"; and systemctl -q is-active graphical.target
exec startx
end
@nikopol
nikopol / dom-core.cljs
Last active September 15, 2019 01:31
minimalist dom manipulation clojure script library
(ns dom.core
(:require [clojure.string :as str]
[clojure.set :refer [difference union]]))
; sample usage:
; (-> (all ".class") (hide) (+css "titi") (clear) (html "<span>zob</span>") (show))
(defn- nodelist-coll [nodelist]
(doall (map #(.item nodelist %) (range (.-length nodelist)))))
@nikopol
nikopol / trowl.css
Last active September 26, 2016 09:33
yet another vanilla growl like notification for the browser called 'trowl'
/* trowl.css - niko 2016 */
div.trowl-dock {
position: fixed;
top: 0;
right: 0;
max-width: 400px;
overflow: hidden;
z-index: 9999999;
text-align: right;
function fish_prompt
set sepcol (set_color -o blue)
set hstcol (set_color -o yellow)
set pthcol (set_color cyan)
set gitcol (set_color normal)
if test $USER = "root"
set usrcol (set_color red)
else
set usrcol (set_color -o green)
end
function fish_right_prompt
set -l delay
set -l now (date +%s)
if set -q __fish_last_prompt
set -g dur (math $now - $__fish_last_prompt)
if test $dur -lt 120
set delay (printf '%ds' $dur)
else if test $dur -lt 3600
set delay (printf '%d:%02d' (math "floor($dur / 60)") (math "$dur % 60"))
else
@nikopol
nikopol / csvcount.c
Created October 19, 2015 13:42
LIGTHNING FAST CSV ROW COUNT
/*
LIGTHNING FAST CSV ROW COUNT
syntax: csvcount filename
niko 2015
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>