Skip to content

Instantly share code, notes, and snippets.

@eliranmal
eliranmal / json.sh
Last active June 11, 2019 16:56
a bash json parser via node js
#!/usr/bin/env bash
# example usage:
#
# json_response="$(curl --flag http://whatever.man)" # -> { "status": 22, "errors": [ { "message": "oh no!" } ] }
# errors="$(echo "$json_response" | json_get "errors")"
# [[ $errors ]] && {
# msg="$(echo "$errors" | json_get "0" | json_get "message")"
# }
json_get() {
@eliranmal
eliranmal / pull_request.sh
Last active February 28, 2017 00:51 — forked from devongovett/pull_request.sh
Bash script to make a pull request from the current git repository.
#!/usr/bin/env bash
pull_request() {
local to_branch="$1"
if [ -z $to_branch ]; then
to_branch="master"
fi
local access_token="[some access token with lots of characters]"
@eliranmal
eliranmal / show-ansi-colors.sh
Last active November 7, 2022 07:30
spits N ansi colors to the terminal
#!/usr/bin/env sh
usage() {
echo "show-ansi-colors <n>"
exit 0
}
(( $# < 1 )) && usage
show_ansi_colors() {
@eliranmal
eliranmal / utf.sh
Created January 23, 2017 15:40
encode/decode utf strings in bash
#!/usr/bin/env sh
utf_encode() {
printf "\\\x%s" $(printf "$1" | xxd -p -c1 -u)
}
utf_decode() {
printf "%b" "$1"
}
@eliranmal
eliranmal / difftree
Last active November 20, 2016 16:28
#!/usr/bin/env bash
diff <(tree -C "$1") <(tree -C "$2")
@eliranmal
eliranmal / app.html
Last active October 27, 2016 12:15 — forked from geleto/app.html
Aurelia - change to a bound repeat input element is applied to the VM a second time after the element has been deleted.
<template>
<h3>messages</h3>
<p>${messages.length}</p>
<p>${messages}</p>
<div repeat.for="i of messages.length">
<input type="text" value.bind="$parent.messages[i]" input.delegate="onMessageChanged(i)">
</div>
</template>
// this is a configuration file for grunt-string-replace plugin
// todo - turn this into a proper grunt plugin of its own
module.exports = function (grunt) {
var config = {
sass: {}
},
@eliranmal
eliranmal / colors
Last active December 17, 2019 16:31 — forked from twerth/colors
List colors in shell
#!/usr/bin/env bash
echo -e "\033[0mNC (No color)"
echo -e "\033[1;37mWHITE\t\033[0;30mBLACK"
echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE"
echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN"
echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN"
echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED"
echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE"
echo -e "\033[0;33mYELLOW\t\033[1;33mLIGHT_YELLOW"
@eliranmal
eliranmal / npm-commons.sh
Last active June 21, 2016 11:36
functions for common npm tasks
#!/usr/bin/env bash
##################################
# functions for common npm tasks #
##################################
##### public #####
@eliranmal
eliranmal / dabblet.css
Last active August 29, 2015 14:26
switching kittens #6 - love thy kitten
/* switching kittens #6 - love thy kitten */
input[type=checkbox] {
display: none;
}
input[type=checkbox] + label {
background-image: url('//placekitten.com/400/404');
display: block;
width: 400px;