Skip to content

Instantly share code, notes, and snippets.

View chuckwagoncomputing's full-sized avatar

David Holdeman chuckwagoncomputing

View GitHub Profile
@chuckwagoncomputing
chuckwagoncomputing / spl2c.sh
Created February 18, 2014 00:12
Shakespeare 2 C Wrapper script
#!/bin/bash
LOCATION="/usr/local/bin"
if [ $# -eq 2 ]; then
if [ -f $1 ]; then
$LOCATION/spl/bin/spl2c < $1 > $2.c
gcc $2.c -o $2 -I $LOCATION/spl/include -L $LOCATION/spl/lib -lspl -lm
rm $2.c
rm $1
else
echo "USAGE: spl2c [file to compile] [name of resulting program]"
@chuckwagoncomputing
chuckwagoncomputing / xkcd_now_get.sh
Created February 27, 2014 01:40
get xkcd now image files
#!/bin/bash
for HOUR in {00..23}; do
for MINUTE in 00 15 30 45; do
wget "http://imgs.xkcd.com/comics/now/"$HOUR"h"$MINUTE"m.png"
done
done
exit
@chuckwagoncomputing
chuckwagoncomputing / xkcd_now_selector.sh
Created February 27, 2014 01:41
Selects the proper xkcd now image file for the time.
#!/bin/bash
# Change this to the directory containing the image files.
XKCDPATH="/usr/local/bin/xkcdnow"
HOUR=$(TZ=Asia/Kamchatka date +%H)
MINUTE=$(date +%M)
if [ $MINUTE -gt 00 -a $MINUTE -le 15 ]; then
MINUTE=15
elif [ $MINUTE -gt 15 -a $MINUTE -le 30 ]; then
MINUTE=30
#!/bin/bash
BIRTHDAY=$1
DAYSTODAY=$(date +%j | sed "s/^0*//g")
DAYSATBIRTH=$(date -d "$BIRTHDAY" +%j | sed "s/^0*//g")
YEARSOLD=$(($(date +%Y)-$(date -d "$BIRTHDAY" +%Y)))
if [ $DAYSATBIRTH -gt $DAYSTODAY ]; then
YEARSOLD=$(($YEARSOLD-1));
DAYSSINCE=$(($((365-$DAYSATBIRTH))+$DAYSTODAY))
else
DAYSSINCE=$(($DAYSTODAY-$DAYSATBIRTH))
@chuckwagoncomputing
chuckwagoncomputing / text.js
Created February 25, 2015 23:31
coordinate line font in javascript
var letters = {
' ' : [[50, 0, 50, 0]],
'!' : [[0, 45, 0, 50, 8],
[0, 10, 0, 35, 8]],
'"' : [[0, 10, 0, 20, 8],
[10, 10, 10, 20, 8]],
'#' : [[0, 35, 20, 35, 8],
[0, 25, 20, 25, 8],
[15, 20, 15, 40, 8],
[5, 20, 5, 40, 8]],
@chuckwagoncomputing
chuckwagoncomputing / ifchanged.sh
Created November 20, 2012 17:44
shell script to check results of command
badopts()
{
echo -e "Usage: ifchanged [command to check] [number of seconds to wait between checks] [command to execute if not changed] [command to execute if changed]"
exit
}
if [ $# -ne 4 ]
then
badopts
else
while true
@chuckwagoncomputing
chuckwagoncomputing / Paypal_error.txt
Created November 20, 2012 23:05
PayPal iOS app console error
Tue Nov 20 16:47:25 PayPal[30597] <Error>: *** -[__NSCFCalendar components:fromDate:toDate:options:]: fromDate cannot be nil
I mean really, what do you think that operation is supposed to mean with a nil fromDate?
An exception has been avoided for now.
A few of these errors are going to be reported with this complaint, then further violations will simply silently do whatever random thing results from the nil.
Here is the backtrace where this occurred this time (some frames may be missing due to compiler optimizations):
(
0 CoreFoundation 0x3a1d948f <redacted> + 86
1 PayPal 0x0019981b -[PPKBCheckInManager nearbyMerchantRefresh] + 162
2 PayPal 0x0018833f -[PPMerchantListingsViewController viewWillAppear:] + 1414
3 UIKit 0x333cb319 <redacted> + 136
@chuckwagoncomputing
chuckwagoncomputing / randprog.sh
Created November 29, 2012 23:40
Random Program opener shell script
#!/bin/bash
LINES=`cat $1 | wc -l`
LINESB=`echo $((RANDOM % LINES))`
WHICH=`echo $((LINESB + 1))`
COM=`cat $1 | head -n $WHICH | tail -n 1`
eval $COM
exit
@chuckwagoncomputing
chuckwagoncomputing / error.log
Created December 3, 2012 21:37
Emoticon in Error message iOS
2012-12-03 21:35:26 +0000 assistant_service the local store doesn't allow tasks and we have no default calendar :(