Skip to content

Instantly share code, notes, and snippets.

View Alanaktion's full-sized avatar
:shipit:
Working on too many things.

Alan Hardman Alanaktion

:shipit:
Working on too many things.
View GitHub Profile
@Alanaktion
Alanaktion / entropizer.php
Last active October 22, 2015 16:01
Simple PHP entropy calculator
<?php
/**
* Calculate entropy of a string
*
* @see https://github.com/jreesuk/entropizer
*
* @param string $str
* @return integer
*/
function entropizer($str) {
@Alanaktion
Alanaktion / phproject-stats.sh
Created November 3, 2015 07:00
Phproject stat calculation
git ls-tree --name-only -z -r HEAD |\
grep -zZP '^(?!(lib|tmp|fonts|app/helper/(diff|textile))/)(?!(css|less|js)/(bootstrap|jquery|chart|respond|modernizr|datepicker|simplemde|intercom|stupidtable|typeahead|bootswatch)).*\.(php|css|less|js|html)$' |\
xargs -0 -n1 git blame --line-porcelain |\
grep \"^author \" | sort | uniq -c | sort -nr
@Alanaktion
Alanaktion / ios5.html
Last active November 7, 2015 17:50
iOS 5 UI in CSS
<!DOCTYPE html>
<html>
<head>
<title>iOS 5</title>
<style type="text/css">
body {
margin: 0;
font-family: 'Helvetica Neue', Arial, sans-serif;
background-image: url("data:image/gif;base64,R0lGODlhCgAKAIABAN3d3f///yH5BAEKAAEALAAAAAAKAAoAAAIRjA2Zhwoc3GMSykqd1VltzxQAOw==");
background-repeat: repeat;
@Alanaktion
Alanaktion / mkdeb.sh
Last active November 9, 2015 18:12
Packages rbrito/mediterranean-gtk-themes as a .deb archive
#!/bin/bash
mkdir -p mediterranean-gtk-themes/usr/share/ && cd $_
git clone --depth=1 https://github.com/rbrito/mediterranean-gtk-themes.git themes
cd themes
VER=$(git rev-parse --short=12 HEAD)
rm -rf .git
rm LICENSE README.md
cd ../../..
mkdir DEBIAN
cat >DEBIAN/control <<EOL
@Alanaktion
Alanaktion / update-phproject.sh
Created November 24, 2015 22:45
Updates a Phproject instance and it's plugins via git
#!/bin/bash
PROJPATH="/var/www/phproject"
cd $PROJPATH
/usr/bin/git pull
cd $PROJPATH/app/plugin
for i in */; do
echo "Updating $i ..."
cd $i
@Alanaktion
Alanaktion / term.php
Last active December 2, 2015 21:40
Terminal window helper functions
<?php
/**
* Get terminal window size in characters
* @return array
*/
function getWindowSize() {
return array(exec('tput cols'), exec('tput lines'));
}
@Alanaktion
Alanaktion / bigformat.php
Last active December 21, 2015 06:38
PHP function to return massive numbers as readable strings such as "63.2 quadrillion" instead of 63200000000000000. This function uses short scale number formats, the standard in the U.S.
<?php
function bigformat($n) {
// Start with a Googol and work down
if($n>pow(10,100))
return round(($n/pow(10,100)),1).' googol';
// I'll add more later
if($n>pow(1000,32))
return round(($n/pow(1000,32)),1).' untrigintillion';
if($n>pow(1000,31))
return round(($n/pow(1000,31)),1).' trigintillion';
@Alanaktion
Alanaktion / prompt.sh
Created January 5, 2016 23:57
A basic prompt function for bash scripts
#!/bin/bash
function prompt() {
echo -n $1
echo -n " [y/n] "
read prompt_response
if [ $prompt_response == 'y' ]; then
return 0
else
return 1
@Alanaktion
Alanaktion / goog.svg
Created September 16, 2015 22:32
A not-quite-accurate minimal SVG Google logo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Alanaktion
Alanaktion / osx-defaults.sh
Created April 7, 2016 16:44
OS X Defaults
# I have issues with OS X's defaults. Luckily, most are easy to change.
# This is heavily based on saetia's gist: https://gist.github.com/saetia/1623487
# Disable autocomplete, which effectively disables that really stupid Escape key autocomplete handler
defaults write -g NSUseSpellCheckerForCompletions -bool false
# Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Expand save panel by default