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 / 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 / setup-osx.sh
Created October 7, 2015 20:08
Auto-setup for OS X
#!/bin/bash
# Sets up a new OS X installation with reasonable defaults
# Based partially on https://gist.github.com/saetia/1623487
echo 'Setting defaults...'
# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
# Set default Finder location to home folder (~/)
@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 / deb-setup.sh
Last active November 9, 2017 21:02
A perfect Xubuntu setup
#!/bin/bash
# This script is designed to run on Xubuntu 14.04, but should work on
# most Ubuntu and Debian-based distros
##################
# Define globals #
##################
SETUPNAME="Alan's Xubuntu Setup"
DISTRO=`lsb_release -c | awk '{ print $NF }'`
@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