Skip to content

Instantly share code, notes, and snippets.

Avatar

Denis Ciccale dciccale

View GitHub Profile
@dciccale
dciccale / http-ping.sh
Created Jul 27, 2016
Print http status every `n` seconds
View http-ping.sh
# Print http status every n seconds
# n defaults to 1s
# usage:
# http-ping google.com .5 (500 milliseconds)
# http-ping google.com 2 (2 seconds)
http-ping() {
n=1 && (($#>1)) && n=$2
while true
do
curl -o /dev/null --silent --head --write-out '%{http_code}\n' $1
@dciccale
dciccale / docker-enter
Last active Jul 29, 2016
docker-enter bash alias to enter a docker container
View docker-enter
# usage docker-enter [CONTAINER_ID]
dockerenter() {
docker exec -it $1 bash
}
alias docker-enter=dockerenter
@dciccale
dciccale / demo.html
Created Jun 4, 2014
Client-side template engine
View demo.html
<!doctype html>
<script>function t(s,d){for(var k in d)s=s.replace(new RegExp('{{\\s*'+k+'\\s*}}','g'),d[k]);return s;}</script>
<script type="template" id="tmpl">
<h1>Hello {{ name }}!</h1>
</script>
<script>
var tmpl = document.getElementById('tmpl').innerHTML;
@dciccale
dciccale / README.md
Last active Dec 22, 2015
Binary search function done with 109 bytes of JavaScript
View README.md

binarySearch

Tiny binary search done with 109 bytes of JavaScript.

@dciccale
dciccale / README.md
Last active May 22, 2018
Cross-browser triggerEvent function done with 127 bytes of JavaScript
View README.md

triggerEvent

Cross-browser function to trigger DOM events.

@dciccale
dciccale / git_branch.sh
Created May 11, 2013
Bash script to get the current git branch and last commit
View git_branch.sh
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@dciccale
dciccale / README.md
Last active Mar 27, 2016
Cross-browser eventHandler function done with 270 bytes of JavaScript
View README.md

eventHandler

Cross-browser function to handle DOM events.

@dciccale
dciccale / README.md
Last active Dec 17, 2015
Cross-browser removeEvent function done with 84 bytes of JavaScript
View README.md

removeEvent

Cross-browser function to remove events from DOM elements.

@dciccale
dciccale / README.md
Last active Dec 16, 2015
Cross-browser addEvent function done with 81 bytes of JavaScript
View README.md

addEvent

Cross-browser function to add events on DOM elements.

@dciccale
dciccale / README.md
Last active Dec 11, 2015
hasOwnProperty shim in 115 bytes (counting only the actual function)
View README.md

hasOwnProperty shim

Cross-browser hasOwnProperty shim in 115 bytes of JavaScript.