Skip to content

Instantly share code, notes, and snippets.

type Person struct {
Name string `url:"name"`
HomeAddress string `url:"home_address"`
// ...
}
// EncodeQueryString serializes a struct into a query string
func EncodeQueryString(s interface{}) string {
queryString := url.Values{}
v := reflect.ValueOf(s)
@kladd
kladd / encode_struct.go
Created July 30, 2015 03:27
for encoding a struct into a querystring
func encodeParams(params interface{}) string {
v := reflect.ValueOf(params).Type()
vals := url.Values{}
for i := 0; i < v.NumField(); i++ {
vals.Set(
v.Field(i).Tag.Get("url"),
reflect.ValueOf(params).Field(i).String(),
)
}

Keybase proof

I hereby claim:

  • I am kladd on github.
  • I am kladd (https://keybase.io/kladd) on keybase.
  • I have a public key whose fingerprint is 535C AEDD AF58 7A17 7D3A D529 5E12 4B4F 66A8 00C6

To claim this, I am signing this object:

@kladd
kladd / flickrJustifiedGallery.js
Created November 26, 2014 15:42
flickrJustifiedGallery for photosets
/*
* Flickr Justified Gallery - v1.0.1
* http://github.com/kladd/flickr-justified-gallery/
*
* flickrJustifiedGallery.js
*/
(function($) {
$.fn.flickrJustifiedGallery = function (arg) {
var defaults = {
flickrApiKey: "",
@kladd
kladd / gist:fd1382754436575ff5c4
Created November 16, 2014 22:29
Moto X - CM 12 - Debugging
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): EvaluatingState{ when=-1ms what=532486 arg1=2 target=com.android.internal.util.StateMachine$SmHandler }
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): Checking http://clients3.google.com/generate_204 on n.ispsn
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "clients3.google.com": No address associated with hostname
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): EvaluatingState{ when=-5ms what=532486 arg1=3 target=com.android.internal.util.StateMachine$SmHandler }
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): Checking http://clients3.google.com/generate_204 on n.ispsn
D/NetworkMonitorNetworkAgentInfo [MOBILE (LTE) - null]( 806): Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "clients3.google.com": No address associated with hostname
D/NetworkMonitorNetworkAge
[2013/08/28 16:02:18, 0] nmbd/nmbd_incomingrequests.c:171(process_name_refresh_request)
process_name_refresh_request: unicast name registration request received for name RHA-G7-DEAD<20> from IP 35.8.90.132 on subnet UNICAST_SUBNET.
[2013/08/28 16:02:18, 0] nmbd/nmbd_incomingrequests.c:172(process_name_refresh_request)
Error - should be sent to WINS server
[2013/08/28 16:02:18, 0] nmbd/nmbd_incomingrequests.c:171(process_name_refresh_request)
process_name_refresh_request: unicast name registration request received for name RHA-G7-DEAD<00> from IP 35.8.90.132 on subnet UNICAST_SUBNET.
[2013/08/28 16:02:18, 0] nmbd/nmbd_incomingrequests.c:172(process_name_refresh_request)
Error - should be sent to WINS server
[2013/08/28 16:02:18, 0] nmbd/nmbd_incomingrequests.c:171(process_name_refresh_request)
process_name_refresh_request: unicast name registration request received for name WORKGROUP<00> from IP 35.8.90.132 on subnet UNICAST_SUBNET.
@kladd
kladd / command.py
Created July 26, 2013 17:58
Python library for working with the command line in a natural way.
#
# Command
#
# For working with the shell and all that
#
import subprocess
import shlex
class Command(object):
@kladd
kladd / gist:5767728
Created June 12, 2013 18:15
stage all delete files in git for commit
# i have this aliased to grm in basrhc
git diff --diff-filter=D --name-only -z | xargs -0 git rm
@kladd
kladd / kernel-doc
Last active December 17, 2015 19:58
#!/usr/bin/perl -w
use strict;
## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ##
## Copyright (C) 2000, 1 Tim Waugh <twaugh@redhat.com> ##
## Copyright (C) 2001 Simon Huggins ##
## Copyright (C) 2005-2012 Randy Dunlap ##
## Copyright (C) 2012 Dan Luedtke ##
## ##
gconftool-2 --set /apps/gnome-terminal/profiles/Default/foreground_color --type string "#FEFFD3"
gconftool-2 --set /apps/gnome-terminal/profiles/Default/background_color --type string "#141414"
gconftool-2 --set /apps/gnome-terminal/profiles/Default/bold_color --type string "#FEFFD3"
gconftool-2 --set /apps/gnome-terminal/profiles/Default/palette --type string "#141414:#C06C43:#AFB979:#C2A86C:#444649:#B4BE7B:#778284:#FEFFD3:#262626:#DD7C4C:#CBD88C:#E1C47D:#5A5D61:#D0DB8E:#8A989A:#FEFFD3"