Skip to content

Instantly share code, notes, and snippets.

View mwmahlberg's full-sized avatar
🎯
Focusing

Markus Mahlberg mwmahlberg

🎯
Focusing
  • Cologne, Germany
View GitHub Profile
@mwmahlberg
mwmahlberg / connect.sh
Created February 19, 2016 16:14
Script for connecting to mongod/mongos without the need to type in authInfo
#!/bin/bash
USER="foo"
PASS="bar"
AUTHDB="someDb"
mongo $1 -u $USER -p $PASS --authenticationDatabase $AUTHDB
@mwmahlberg
mwmahlberg / main.go
Last active January 23, 2016 12:51
XML stream parsing example for answer to http://stackoverflow.com/q/34958199/1296707:
package main
import (
"bytes"
"encoding/xml"
"fmt"
)
const (
book = `<?xml version="1.0" encoding="UTF-8"?>
@mwmahlberg
mwmahlberg / main.go
Created January 22, 2016 22:02
Using json.Decoder to decode API call.
package main
import (
"encoding/json"
"fmt"
"net/http"
)
// So ungefähr
type Contrib struct {
package main
import (
"os"
"io/ioutil"
)
// FileReadable returns true only if path is readable.
func FileReadable(path string) bool {
fi, err := os.Stat(path)
package main
import (
"fmt"
"golang.org/x/crypto/bcrypt"
)
func main() {
pwd := []byte("password")
fmt.Println("Generating hashes...")
{
"_id":"$objectid",
"name": { "$choose" : { "from" : [ "Foo", "Bar", "Baz", "Blarg", "Blubb" ] } },
"categoriesIds": {
"$array":{
"of":{
"$number" : {"min" : 1, "max" : 1000 }
},
"number":{
"$number" : {"min" : 1, "max" : 100 }