This file contains hidden or 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
func LoadGzippedJSON(r io.Reader, v interface{}) error { | |
raw, err := gzip.NewReader(r) | |
if err != nil { | |
return err | |
} | |
return json.NewDecoder(raw).Decode(&v) | |
} |
This file contains hidden or 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
func LoadGzippedJSON(r io.Reader, v interface{}) error { | |
data, err := ioutil.ReadAll(r) | |
if err != nil { | |
return err | |
} | |
// oh wait, we need a Reader again.. | |
raw := bytes.NewBuffer(data) | |
unz, err := gzip.NewReader(raw) | |
if err != nil { | |
return err |
This file contains hidden or 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
func ReadAll(r io.Reader) ([]byte, error) |
This file contains hidden or 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" | |
"io" | |
"net/http" | |
"os" | |
) | |
func init() { |
This file contains hidden or 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
+++ Statistics Dump +++ (1393879884) | |
++ Incoming Requests ++ | |
7122195 QUERY | |
1 IQUERY | |
4 STATUS | |
1 NOTIFY | |
++ Incoming Queries ++ | |
5189989 A | |
81035 NS | |
1754 CNAME |
This file contains hidden or 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 ( | |
"bytes" | |
"compress/gzip" | |
"database/sql/driver" | |
"errors" | |
"fmt" | |
"github.com/jmoiron/sqlx" | |
_ "github.com/mattn/go-sqlite3" |
This file contains hidden or 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
#!/usr/bin/env python | |
# I had a script which I wanted to have a special option that short-circuited the normal | |
# argument parsing error handling behavior so that it could be run without thenormal | |
# required arguments. This option would work similar to how `--help` or `--version` | |
# works, except that the parser would return a valid args object in its presence | |
# rather than exiting the program. | |
import argparse |
This file contains hidden or 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
const ( | |
white = iota + 89 | |
black | |
red | |
green | |
yellow | |
blue | |
purple | |
) |
This file contains hidden or 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 ( | |
"bytes" | |
"fmt" | |
"github.com/moovweb/gokogiri" | |
"github.com/moovweb/gokogiri/css" | |
"github.com/moovweb/gokogiri/html" | |
"github.com/moovweb/gokogiri/xml" | |
"github.com/moovweb/gokogiri/xpath" |
This file contains hidden or 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
// Selectable implements a simple interface which allows to get the inner text | |
// of some element as well as run a CSS select on it and get a list of nodes | |
type Selectable interface { | |
CssSelect(selector string) []Node | |
Text() string | |
} | |
// A node wrapper, in order to provide a similar interface in the future | |
// possibly without gokogiri | |
type Node struct { |