Skip to content

Instantly share code, notes, and snippets.

View tablinks.js
@RSully
RSully / bourne.fish
Last active Jan 18, 2018
Source *sh environments from fish.
View bourne.fish
function set_bourne
set --local line $argv[1] # the line X=Y
set --local exp $argv[2] # 1/0: export the variable
set --local key (echo $line | perl -pe 's/^([A-Za-z0-9_]+)=(.*)/$1/g')
set --local dataraw (echo $line | perl -pe 's/^([A-Za-z0-9_]+)=(.*)/$2/g')
set --local data $dataraw
# echo "in set_bourne for $key with $exp"
# echo "old value: $$key"
@RSully
RSully / freadit.php
Created Jan 12, 2016
Keep trying to copy a file until success.
View freadit.php
<?php
$path = '/Volumes/drive/path.dat';
$write_to = '/tmp/output.dat';
$fh_out = fopen($write_to, 'w+');
clearstatcache();
while (!file_exists($path)) {
sleep(1);
@RSully
RSully / libcec-sample.cpp
Last active Oct 26, 2015
Sample code for libCEC initialization
View libcec-sample.cpp
//
// main.cpp
// Test libCEC
//
// Created by Ryan Sullivan on 10/26/15.
// Copyright © 2015 Ryan Sullivan. All rights reserved.
//
#import <iostream>
#import <cec.h>
@RSully
RSully / generate.sh
Created Oct 8, 2015
Generate commands to reinstall homebrew packages
View generate.sh
#!/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 / regex-pricing.txt
Created Dec 29, 2014
Regex to match US pricing (without dollar sign)
View regex-pricing.txt
^(\d*)(\.(\d{0,2})?)?$/
View Generator.php
<?php
class Generator {
protected $namespaces = [];
protected $outputDirectoriesPSR4 = [];
protected $aliasMapTypes = [];
protected $inputFiles = [];
/*
* Methods to setup the data we need to generate
View filters.php
<?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)
@RSully
RSully / gol.php
Last active Dec 19, 2015
PHP implementation of Game Of Life
View gol.php
<?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];
@RSully
RSully / sha.go
Last active Dec 19, 2015
My first Go program. Hash a file using a buffered reader
View sha.go
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 (
You can’t perform that action at this time.