Skip to content

Instantly share code, notes, and snippets.

View Kapott's full-sized avatar
🏠
Working from home

kapott Kapott

🏠
Working from home
View GitHub Profile
@Kapott
Kapott / .gitconfig
Last active August 29, 2015 14:17
.gitconfig
[user]
name =
email =
[push]
default = current
[core]
editor = vim
[alias]
c = commit
co = checkout
@Kapott
Kapott / getParameterByName.js
Created April 3, 2015 09:17
JS / Get query parameter by name
/**
* From SO thread :
* http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
*/
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
@Kapott
Kapott / config
Last active January 24, 2016 11:30
i3wm / config
# Kapott's i3wm configuration
#
# I don't like non-tiled window managers, and i3 is easy to configure,
# and not as hardcore keyboard-purist like e.g. ratpoison.
#
# Programs I combine with this;
#
# scrot screenshots
# imagemagick fast image-processing withing bash scripts
# i3lock locking my screen
@Kapott
Kapott / blur-lock.sh
Created April 3, 2015 09:52
i3wm / blur-lock.sh
#!/bin/bash
# Requires : scrot, imagemagick, i3lock
# Creates a screenshot of the current desktop,
# blurs it, then sets it as the "lock" image
# for i3lock. Looks pretty slick!
scrot /tmp/tempshot.png
convert /tmp/tempshot.png -blur 0x5 /tmp/screenshot.png
i3lock -i /tmp/screenshot.png
@Kapott
Kapott / imgscrot.sh
Created April 7, 2015 10:06
Scrot to Imgur bash script
function uploadImage {
curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" https://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*"
}
scrot -s "shot.png"
uploadImage "shot.png" | xclip -selection c
rm "shot.png"
notify-send "Done uploading to imgur!"
@Kapott
Kapott / EventBus.js
Created April 13, 2015 09:53
EventBus.js pub/sub snippet for nodejs.
/**
* EventBus is a simple pub/sub system for an application
* written for demonstration purposes.
* When using NodeJs you should use the 'event' module.
*/
var EventBus = {
topics: {},
subscribe: function(topic, listener){
if (!this.topics[topic]) { this.topics[topic] = []; }
@Kapott
Kapott / aliases.sh
Last active August 29, 2015 14:20
Useful shell aliases
#----------------------------------------
# Navigation aliases
#----------------------------------------
alias please="sudo"
alias ..="cd .."
alias 2="cd ..\.."
alias 3="cd ..\..\.."
alias 4="cd ..\..\..\.."
alias x="pushd"
alias xx="popd"
@Kapott
Kapott / vercomp.sh
Created June 16, 2015 07:07
version comparison in pure bash
# From : http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format
#!/bin/bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
@Kapott
Kapott / p
Last active December 16, 2016 06:42
tmux project switcher
#!/bin/bash
# Usage:
#
# p <projectname>
# e.g.
# p website
#
# Will open up a tmux session with VIM started in the main
# window, and two smaller windows (process & linting) at the bottom
/*
Bubble sort *hurr*
*/
function bubbleSort(list) {
let swapped;
do {
swapped = false;
for (let i = 0; i list.length; i++) {
if (list[i] > list[i+1]) {