Skip to content

Instantly share code, notes, and snippets.

@sphinxid
sphinxid / .bashrc
Last active January 11, 2018 09:13
sphinx bashrc - Colorful BASHrc config with github branch support displayed.
#git branch
# __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
# "\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
function parse_git_dirty {
echo -n $(git status 2>/dev/null | awk -v out=$1 -v std="dirty" '{ if ($0=="# Changes to be committed:") std = "uncommited"; last=$0 } END{ if(last!="" && last!="nothing to commit (working directory clean)") { if(out!="") print out; else print std } }')
}
function parse_git_branch {
echo -n $(git branch --no-color 2>/dev/null | awk -v out=$1 '/^*/ { if(out=="") print $2; else print out}')
}
@sphinxid
sphinxid / anagram.php
Created December 12, 2016 07:55
Simple anagram checker in PHP
<?php
/*
* 2016/12/12
*
* anagram.php
* Simple anagram checker. (cAsE sEnsiTivE)
*
* Firman Gautama <[email protected]>
*
@sphinxid
sphinxid / palindrome.c
Last active December 12, 2016 09:24
simple palindrome checker in C
/*
* 2016/12/12
*
* palindrome.c
* Simple palindrome checker for small string. (cAsE sEnsiTivE)
*
* Firman Gautama <[email protected]>
*
*/
#include <stdio.h>
@sphinxid
sphinxid / concurrent-phantomjs-example.py
Created November 27, 2016 18:04
How to Render a Html Page with Selenium Webdriver + PhantomJS in Python
#
# 20160929 - [email protected]
#
from selenium import webdriver
import time
import concurrent.futures
import signal
from concurrent.futures import ThreadPoolExecutor
from random import randint
@sphinxid
sphinxid / gist:e8b46899959bc9d3382f
Last active August 29, 2015 14:24
Javascript: Call URL before Exit from Page
window.onbeforeunload = function() {
var URL = '//preview.adskom.net/test12345.js';
var request = null;
if (window.XMLHttpRequest){
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}