This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"actions":[ | |
{ | |
"add":{ | |
"index":"%s", | |
"alias":"%s", | |
"filter":[ | |
{ | |
"term":{ | |
"meta.publish_records.timestamp":"%s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thanks https://coderwall.com/p/khym-w | |
curl -s "http://someapi.com/json" | ruby -rawesome_print -rjson -e 'ap JSON.parse(STDIN.read)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://play.golang.org/p/YfMF5mG3v2 | |
func UnPKCS7Padding(data []byte) []byte { | |
dataLen := len(data) | |
// Grab the last byte which is *always* the pad byte for the password implementation | |
endIndex := int(data[dataLen-1]) | |
fmt.Println(data[dataLen-1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package httpclient | |
import ( | |
"net" | |
"net/http" | |
"time" | |
) | |
type Config struct { | |
ConnectTimeout time.Duration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Cat struct { | |
name string | |
skill string | |
} | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db *sql.DB | |
func Count() (int, error) { | |
rows, err := db.Query("SELECT COUNT(*) AS count FROM users") | |
if err != nil { | |
return nil, err | |
} | |
var count int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zcat foo.sql.gz | mysql -uroot -ppassword foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The dumb way to deal with SOAP requests | |
func userRequest(userId string) string { | |
template := soapify(userTemplate) | |
return fmt.Sprintf(template, userId) | |
} | |
func soapify(template string) string { | |
return fmt.Sprintf(soapTemplate, template) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo networksetup -getwebproxystate "iPhone USB" | |
Enabled: No | |
Server: 127.0.0.1 | |
Port: 6666 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo networksetup -setwebproxystate "iPhone USB" off |