Skip to content

Instantly share code, notes, and snippets.

@RSully
RSully / input_parse.js
Created March 28, 2013 12:26
Parse input "arrays" in JS
function parseInputs(data) {
var ret = {};
retloop:
for (var input in data) {
var val = data[input];
var parts = input.split('[');
var last = ret;
for (var i in parts) {
@RSully
RSully / pcl2pdf.sh
Created April 19, 2013 00:37
Function to convert PCL to PDF using `pcl6`
pcl2pdf() {
input=$1
output=${2-$input.pdf}
pcl6 -o $output -sDEVICE=pdfwrite $input
}
@RSully
RSully / call.php
Created April 24, 2013 14:24
This script can be used with something like `xdg` in order to add `sip:` handling to Chrome or Firefox using SFLphone. It takes a single argument, strips it to numerics and triggers a `dbus-send` to SFLphone's method to place a call. It uses the first account, which may or may not be what you want. `xdg-mime default sip-call-handler.desktop x-sc…
#!/usr/bin/php
<?php
// Requirements:
// sudo apt-get install php5-cli php-pear libyaml-dev
// sudo pecl install yaml
$file = $_SERVER['HOME'] . '/.config/sflphone/sflphoned.yml';
$acct_id = get_account_id($file);
$call_to = preg_replace('/[^0-9]/', '', $argv[1]);
@RSully
RSully / sha.go
Last active December 19, 2015 11:09
My first Go program. Hash a file using a buffered reader
package main
/**
* Help from:
* http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file
* https://groups.google.com/forum/#!topic/golang-nuts/1mc64pj_S50
* http://pastebin.com/DgurHbpe
**/
import (
@RSully
RSully / gol.php
Last active December 19, 2015 13:29
PHP implementation of Game Of Life
<?php
// Implementation
function iterate($original)
{
$board = $original;
for ($x = 0; $x < count($board); $x++) {
$row = $board[$x];
for ($y = 0; $y < count($row); $y++) {
$cell = $row[$y];
<?php
App::before(function($request)
{
// determine the subdomain of the current request
$server = explode('.', Request::server('HTTP_HOST'));
$sansSubdomain = implode('.', array_slice($server, 1));
// there are 3 parts to the domain (i.e. user.domain.com)
if (count($server) == 3)
<?php
class Generator {
protected $namespaces = [];
protected $outputDirectoriesPSR4 = [];
protected $aliasMapTypes = [];
protected $inputFiles = [];
/*
* Methods to setup the data we need to generate
@RSully
RSully / regex-pricing.txt
Created December 29, 2014 20:10
Regex to match US pricing (without dollar sign)
^(\d*)(\.(\d{0,2})?)?$/
@RSully
RSully / generate.sh
Created October 8, 2015 17:56
Generate commands to reinstall homebrew packages
#!/usr/bin/env bash
brew tap | while read tap;
do
echo "brew tap $tap"
done
brew list | while read formula;
do
options=$(brew info --json=v1 $formula | jq '.[0] .installed | sort_by(.version) [0] .used_options | join(" ")' -r)
@RSully
RSully / libcec-sample.cpp
Last active October 26, 2015 22:54
Sample code for libCEC initialization
//
// main.cpp
// Test libCEC
//
// Created by Ryan Sullivan on 10/26/15.
// Copyright © 2015 Ryan Sullivan. All rights reserved.
//
#import <iostream>
#import <cec.h>