Skip to content

Instantly share code, notes, and snippets.

View sndsgd's full-sized avatar

Russell sndsgd

  • Glens Falls, NY
View GitHub Profile
@sndsgd
sndsgd / build-i3status.yaml
Created August 24, 2021 20:59
Ansible task to build i3status
---
- name: register i3status version
shell: i3status --version | cut -d' ' -f2
ignore_errors: yes
register: i3status_version_command
- name: build i3status from source
block:
- name: install dependencies
@sndsgd
sndsgd / hashdir.php
Created April 21, 2016 00:21
A directory hashing script
#!/usr/bin/env php
<?php
list($dir, $isDump) = DirHasher::getArgs($argv);
$hasher = new DirHasher($dir);
if ($isDump) {
echo $hasher->getHashes()."\n";
} else {
echo $hasher->getHash()."\n";
@sndsgd
sndsgd / gif-to-video.sh
Created February 4, 2015 23:06
Convert a gif to a video for use on the web
#!/bin/bash
if [[ -z "$1" ]]; then
echo "provide a path to the source gif file"
exit 1
elif [ ! -f "$1" ]; then
echo "the provided path is not a file"
exit 1
fi
@sndsgd
sndsgd / httpd-chmod.sh
Last active August 29, 2015 14:06
Set permissions for a web server document root directory
#!/bin/bash
dir=$1
user=$2
err=()
if [ "$UID" -ne 0 ]; then
err+=("this script must be run as root")
fi
@sndsgd
sndsgd / install-imagemagick.sh
Created July 15, 2014 17:51
install imagemagick from source on ubuntu 14.04
#!/bin/bash
CWD=$(pwd)
TMP_DIR=/tmp/install-imagemagick
if [ "$UID" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#!/bin/bash
FPM_CONF=/etc/init/php5-fpm.conf
if [ "$UID" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [[ $(grep -E '^umask [[:digit:]]{4}' "$FPM_CONF") ]]; then
@sndsgd
sndsgd / update-google-closure-tools.sh
Last active August 29, 2015 14:02
Update Google Closure Tools
#!/bin/bash
GOOG_LIB_DIR=/usr/lib/google/closure
TMP_DIR=/tmp/update-google-closure-tools
if [ "$UID" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@sndsgd
sndsgd / trusty-setup.sh
Last active August 29, 2015 14:02
Ubuntu 14.04 setup
#!/bin/bash
if [ "$UID" -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#############################################################################
# Install Packages ##########################################################
@sndsgd
sndsgd / func-curlMulti.php
Last active August 29, 2015 14:01
Perform multiple cURL requests in parallel with PHP
/**
* perform multiple curl requests in parallel
* @param array.<string> $urls - an indexed array of urls to fetch
* @param array.<integer> $curopts - curl options to pass to curl_setopt_array()
* @return array
*/
function curlMulti(array $urls, array $curlopts)
{
$ret = [];
$chs = [];
@sndsgd
sndsgd / PDO-bug.php
Last active August 29, 2015 14:00
PDO bug
<?php
const DB_HOST = 'localhost';
const DB_NAME = 'php_bug_test';
const DB_TABLE = 'timestamp_test';
const DB_USER = 'root';
const DB_PASSWORD = 'root';
$dbSQL = "CREATE DATABASE IF NOT EXISTS ".DB_NAME;
$combo = DB_NAME.'.'.DB_TABLE;