Skip to content

Instantly share code, notes, and snippets.

@bmoore
bmoore / Auth.php
Created July 2, 2012 15:29
The authentication library.
<?php
class Auth
{
private $hasher;
private $session;
function __construct()
{
$this->hasher = new PasswordHash(8, false);
@bmoore
bmoore / install.sh
Created December 7, 2012 21:08 — forked from padcom/install.sh
Gitorious installation on Ubuntu 12.04
#!/bin/bash
#------------------------------------------------------------------------------
# SETTINGS
#------------------------------------------------------------------------------
MYSQL_ROOT_PASSWORD=password
MYSQL_GITORIOUS_PASSWORD=password
GITORIOUS_HOST=gitorious
SYSADMIN=sysadmin
@bmoore
bmoore / abr.sh
Created April 26, 2013 18:26
Android build and Ant debug install tool
#!/bin/bash
android update project --path ./
if [ $? -ne 0 ]
then
exit
fi
ant debug install
if [ $? -ne 0 ]
#!/bin/bash
# Usage: install_node 0.6.16
DIR=~/.node
TARGET=/Volumes/Macintosh\ HD
VER=$*
if [ ! -f ~/.node/$VER.pkg ]; then
curl --create-dirs -o $DIR/$VER.pkg http://nodejs.org/dist/v$VER/node-v$VER.pkg
fi
@bmoore
bmoore / upimg
Created May 28, 2013 18:02
Upload image selection to imgur, and pipe the image url to xclip. Based on http://sirupsen.com/a-simple-imgur-bash-screenshot-utility/
#!/bin/bash
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/[^<]*"
}
import shot.png
url=`uploadImage "shot.png"`
echo $url
echo $url | xclip -selection c
@bmoore
bmoore / gist:5831578
Last active December 18, 2015 19:18
Imagick resize
<?php
$x = $y = 0;
$image = new Imagick('orig.jpg');
//get_smallest_dimension
if ($image->getImageWidth() < $image->getImageHeight()) {
$x = 612;
} else {
$y = 612;
}
@bmoore
bmoore / tmtail
Last active December 21, 2015 20:09
tmux split and tail all your files in the logs directory.
#!/bin/bash
if [ !-d 'logs' ]
then
echo "No logs!"
exit 1
fi
i=0
count=$(ls logs | grep log | wc -l)
perc=$((100/$count))
@bmoore
bmoore / base_26.php
Created December 12, 2013 15:04
For Frankie about his base_26 problem.
<?php
function base_26($num)
{
$alpha = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
// Get the character
$i = $num%26;
// Get the rest of the characters "power/base" math
$num = ($num - $i)/26;
@bmoore
bmoore / gist:7995441
Created December 16, 2013 22:16
Lazy solution... like pseudoprototype.
var WebCam = {
capturing: false,
callbacks: [],
capture: function(cb) {
addCallback(cb);
_takePic();
},
addCallback(cb) {
def get_cruise_type_ticket_type_price_id_by_cruise_type_id_and_ticket_type_id(cruise_type_id, ticket_type_id):
with session_scope() as session:
result = session.execute('''
SELECT id
FROM cruise_type_ticket_type
WHERE cruise_type_id = :cruise_type_id
AND ticket_type_id = :ticket_type_id
''', {
'cruise_type_id': cruise_type_id,
'ticket_type_id': ticket_type_id