Skip to content

Instantly share code, notes, and snippets.

View michaeljs1990's full-sized avatar

Michael Schuett michaeljs1990

View GitHub Profile
@michaeljs1990
michaeljs1990 / struct.go
Created June 10, 2014 04:18
Go Example
type Handler struct {
pat string
http.Handler
}
@michaeljs1990
michaeljs1990 / unused.go
Created August 9, 2014 17:30
contentbody declared and not used.
// Run all tests and log to file
func RunTests(tests []testCase) {
color.Blue("Starting test casses...")
client := &http.Client{}
for _, test := range tests {
color.Blue("Test: " + test.Name)
color.Blue(test.Method + " " + test.Path)
@michaeljs1990
michaeljs1990 / sqlite3.py
Last active August 29, 2015 14:05
Python Sqlite3
import sqlite3
#python 3.4
# This fails with key of site_title
db.execute("SELECT * FROM options WHERE key=?;", (key.encode('utf-8'),))
# This works...
db.execute("SELECT * FROM options WHERE key='site_title';")
# This says I have supplied to many arguments...
@michaeljs1990
michaeljs1990 / broken
Created August 19, 2014 02:43
sqlite3 oddness
# output from print as seen in my console.
[18/Aug/2014:21:41:00] HTTP Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/cherrypy/_cprequest.py", line 670, in respond
response.body = self.handler()
File "/usr/local/lib/python3.4/dist-packages/cherrypy/lib/encoding.py", line 217, in __call__
self.body = self.oldhandler(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/cherrypy/_cpdispatch.py", line 61, in __call__
return self.callable(*self.args, **self.kwargs)
File "/home/mschuett/python/CherryBlog/CherryBlog/admin.py", line 49, in settings
@michaeljs1990
michaeljs1990 / people.php
Created September 29, 2014 14:50
Get People Image
<?php
list($titan, $options) = uwmpeople_get_plugin_options();
// By default, let's try to get the profile photo. This may return an integer
// or a URL. Thanks WordPress. If profile photo is empty, then we set it to
// default image, which ALSO might be an integer or a URL. Hopefully this covers all cases.
$featured_image = $titan->getOption('profile_photo', $post_id);
if ( empty($featured_image) )
$featured_image = $titan->getOption('default_image');
@michaeljs1990
michaeljs1990 / people_boilerplate.php
Created September 30, 2014 15:57
People Boilerplate
<?php
/*
Template Name: UWM People Profile Directory
*/
get_header();
// Because WordPress is trying to be oh so helpful
remove_filter('the_content', 'wpautop');
@michaeljs1990
michaeljs1990 / error.txt
Last active August 29, 2015 14:07
PECL OCI8 PHP56
# pecl install oci8
downloading oci8-2.0.8.tgz ...
Starting to download oci8-2.0.8.tgz (190,854 bytes)
.........................................done: 190,854 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
@michaeljs1990
michaeljs1990 / controller.go
Created January 31, 2015 20:51
Example include
// Located in /controllers directory
package controller
func stuff(){}
@michaeljs1990
michaeljs1990 / help.go
Created February 20, 2015 17:30
xml parser
package parsing
import (
"encoding/xml"
"io"
"log"
"reflect"
"code.google.com/p/go-charset/charset"
_ "code.google.com/p/go-charset/data" //
var socket = new WebSocket(r.thebutton._websocket._url);
socket.onmessage = function (event) {
payload = JSON.parse(event.data).payload;
console.log(payload.seconds_left);
if (payload.seconds_left == 1.0) {
document.getElementById('thebutton').click();
}
}