Skip to content

Instantly share code, notes, and snippets.

View sthorne's full-sized avatar

Sean Thorne sthorne

View GitHub Profile
@sthorne
sthorne / gist:122106bcdaec62c695cc
Created February 20, 2015 16:56
Read a file and Escape each line
package main
import (
"os"
"fmt"
"bufio"
"strconv"
)
@sthorne
sthorne / gist:71b272b35e55dceb3ac6
Created February 20, 2015 17:06
Copy iOS AddressBook into NSArray
CFErrorRef error = NULL;
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(nil, &error);
if (error != NULL) {
NSLog(@"Error reading AddressBook: %@", error);
}
CFArrayRef contacts = ABAddressBookCopyArrayOfAllPeople(addressBook);
NSArray contactArray = CFBridgingRelease(contacts);
@sthorne
sthorne / gist:d0fa9da8388d275ac635
Last active August 29, 2015 14:15
Go - MD5 File
package main
import (
"fmt"
"io/ioutil"
"crypto/md5"
"encoding/hex"
)
@sthorne
sthorne / gist:a42870b0a5ee5f1f28b1
Created February 20, 2015 23:05
Go - SHA256 File
package main
import (
"fmt"
"io/ioutil"
"encoding/hex"
"crypto/sha256"
)
@sthorne
sthorne / gist:bd4a14e2b92ddc7d6848
Created February 20, 2015 23:08
Go - Check if File Exists
import "os"
func FileExists(File string) bool {
_, e := os.Stat(File)
if os.IsNotExist(e) {
return false
}
@sthorne
sthorne / gist:9894c6394f042b6e736e
Created February 20, 2015 23:12
Objective-C Pretty Function and Line Logging
NSLog(@"%s [Line %d] %@", __PRETTY_FUNCTION__, __LINE__, data);
@sthorne
sthorne / gist:68b2f08faab1e170d650
Created February 22, 2015 00:32
Go - Determine if Timezone is valid
import "fmt"
import "time"
_, e := time.LoadLocation("America/Denver")
if e != nil {
fmt.Println("Timezone is not valid")
return
}
@sthorne
sthorne / gist:cc324985b225e862bc95
Last active August 29, 2015 14:16
IPTables - Disable Tracking for DNS requests
## If IPTables conntrack is enabled and lots of connections are sucking up resources this can alleviate the problem
## This example is specific to DNS
/sbin/iptables -t raw -I OUTPUT -p udp --sport 53 -j NOTRACK
/sbin/iptables -t raw -I PREROUTING -p udp --dport 53 -j NOTRACK
@sthorne
sthorne / gist:bb9b233c57ec501dd84c
Created February 24, 2015 14:40
Mac OS X AppleScript Command Line Notification
osascript -e 'display notification "That just happened" with title "Shake and Bake"'
@sthorne
sthorne / gist:bbfbbf251b96b027b5da
Last active February 28, 2016 22:19
OpenSSL Connect to Server
# Regular Old HTTPS
openssl s_client -connect my-host:443 -state -debug
# HTTPS w/ SNI
openssl s_client -connect my-host:443 -state -debug -servername my-host