Skip to content

Instantly share code, notes, and snippets.

@GideonPARANOID
GideonPARANOID / index.html
Last active August 29, 2015 14:04
Gregorian/julian date converter
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Gregorian/Julian Date Converter</title>
<style type='text/css'>
body, input {
margin : 0 auto;
@GideonPARANOID
GideonPARANOID / num_format.js
Last active August 29, 2015 14:03
Rough number formatting.
/**
* @param data number to format
* @param width how many digits the number should have, not inclusive of decimal point or sign
* @param dec index of the decimal point
* @param sign whether to include the positive sign or not
* @return string formatted number
*/
function num_format(data, width, dec, sign) {
var res = Math.abs(data).toFixed(width - dec);
res = Array(width - res.replace('.', '').length + 1).join('0') + res;
@GideonPARANOID
GideonPARANOID / front_page.php
Created July 9, 2014 16:11
Parses the Reddit JSON front page URL into a table. Designed for use with command line browsers, like Lynx.
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Front page</title>
</head>
<body>
<table>
<thead>
<tr>
@GideonPARANOID
GideonPARANOID / .bashrc
Last active August 29, 2015 14:03
Dirty little function for making googling things from command line easier
function lygo () {
str="google.co.uk/search?q="
for i in $@; do
str="$str+$i"
done
lynx $str
}
@GideonPARANOID
GideonPARANOID / lighttpd.conf
Created April 27, 2014 19:50
Block access to hidden files & folders with Lighttpd, just in case you didn't want to deny their existence entirely.
$HTTP["url"] =~ "\/\..*" {
url.access-deny = ( "" )
}
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@GideonPARANOID
GideonPARANOID / .bashrc
Last active January 5, 2018 17:22
Bash prompt which tells you the exit status of the last command with colour & displays current git branch (if in a repo)
GREY="\[\e[0m\]"
CYAN="\[\e[0;36m\]"
YELLOW="\[\e[0;33m\]"
GREEN="\[\e[0;32m\]"
RED="\[\e[0;31m\]"
PS1_USER="$YELLOW[\u@\h]$GREY:"
PS1_PATH="[ \$? = "0" ] && echo -n '$GREEN[\w]' || echo -n '$RED[\w]' && echo -n $GREY"
PS1_BRANCH="[ -z \$(__git_ps1 %s) ] && echo -n '' || __git_ps1 ':$CYAN[%s]$GREY'"
@GideonPARANOID
GideonPARANOID / var-dump-js.php
Last active January 4, 2016 03:39
I'm getting really tired of PHP's rubbish variable printing, using the JS terminal is far easier.
/**
* @param $dat a php array or variable
* prints the parameter to the javascript console, only suitable for use inside dom elements
*/
function var_dump_js($dat) {
echo '<script type=\'text/javascript\'>console.log(' . json_encode($dat) . ');</script>';
}
@GideonPARANOID
GideonPARANOID / copy-directory-structure.sh
Last active January 3, 2016 11:29
Copies a directory structure sans files.
#!/bin/bash
# usage:
# copy-directory-structure.sh <target> <destination>
if [ ! -d $2 ]; then
mkdir $2
fi
find $1 -type d > $2/.lst
@GideonPARANOID
GideonPARANOID / snakes-and-ladders.sh
Created December 27, 2013 13:48
Generates a snakes & ladders board in the form of a folder structure, using symbolic links for snakes & ladders. Snakes & ladders are taken from a file in the format: <start> <end>\n
#!/bin/bash
# @author gideon mw jones
# @created 2013-12-27
# @version 1
# creates a directory structure board for snakes & ladders
BRDSZ=100
# initialising board & links