Skip to content

Instantly share code, notes, and snippets.

View sanbornm's full-sized avatar

Mark sanbornm

View GitHub Profile
// Wrap returns a new function which executes HandlerFunc before panicking.
func Wrap(fn func()) func() {
return func() {
// handle panics
defer func() {
if err := recover(); err != nil {
HandlerFunc(err)
pnic(err)
}
}()
@sanbornm
sanbornm / filename.go
Created November 25, 2019 20:25
logrus filename hook
package filename
import (
"fmt"
"runtime"
"strings"
"github.com/sirupsen/logrus"
)
@sanbornm
sanbornm / traverse.go
Created June 16, 2016 16:26
Utility package to find files traversing up the path
// Utility functions used to search up through directories for
// specific files.
package traverse
import (
"fmt"
"io/ioutil"
"path/filepath"
)
@sanbornm
sanbornm / CreateICNS.src
Created June 3, 2016 15:53
Convert 1024 PNG to icon file with various sizes
mkdir MyIcon.iconset
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_16x16@2x.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out MyIcon.iconset/icon_32x32@2x.png
sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_128x128@2x.png
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_256x256@2x.png
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png
@sanbornm
sanbornm / example.go
Created June 2, 2016 15:23 — forked from kavu/example.go
Minimal Golang + Cocoa application using CGO. Build with `CC=clang go build`
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
@sanbornm
sanbornm / install.sh
Created June 24, 2014 18:19
Install Java 1.7 for Elasticsearch on Debian
wget http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt -O /usr/local/bin/add-apt-repository && sudo chmod +x /usr/local/bin/add-apt-repository
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
@sanbornm
sanbornm / gist:8013944
Created December 17, 2013 22:39
Install phpunit globally with Mockery
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
php composer.phar global require 'phpunit/phpunit=3.7.*'
sudo pear channel-discover pear.survivethedeepend.com
sudo pear channel-discover hamcrest.googlecode.com/svn/pear
sudo pear install --alldeps deepend/Mockery
@sanbornm
sanbornm / date_default_timezone.php
Created November 19, 2013 20:57
default timezone and back
$defaultTime = date_default_timezone_get();
date_default_timezone_set('America/Los_Angeles');
$now = date("Y-m-d H:i:s");
date_default_timezone_set($defaultTime);
@sanbornm
sanbornm / table_size.sql
Created November 14, 2013 18:51
Get MySql Table size Desc. Change table_schema to name of your DB.
SELECT table_name AS "Table",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "test" AND table_name like "%"
ORDER BY 2 DESC;
@sanbornm
sanbornm / gist:6687666
Created September 24, 2013 16:50
How to create a linux Patch
diff -Naur standard.xml mynewchange.xml > myfile.patch