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" | |
| "io/ioutil" | |
| "log" | |
| "os/exec" | |
| "regexp" | |
| "sort" |
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 ( | |
| "runtime" | |
| "sync" | |
| ) | |
| func main() { | |
| runtime.GOMAXPROCS(runtime.NumCPU()) | |
| var wg sync.WaitGroup |
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
| import Prelude | |
| fizzbuzz :: (Eq a, Num a) => a -> a -> [Char] -> [Char] | |
| fizzbuzz 0 0 _ = "FizzBuzz" | |
| fizzbuzz 0 _ _ = "Fizz" | |
| fizzbuzz _ 0 _ = "Buzz" | |
| fizzbuzz _ _ x = x | |
| checkfb :: (Show a, Integral a) => a -> [Char] | |
| checkfb n = fizzbuzz (n `rem` 3) (n `rem` 5) (show n) |
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
| <?php | |
| define('KEXT_DELIMITER', " \t\n"); | |
| class KEXT { | |
| public $index; | |
| public $refs; | |
| public $size; | |
| public $wired; | |
| public $name; |
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 updateNode(nid string, title string, body BodyField, cookie *http.Cookie) { | |
| body.value = editBody(body.value) | |
| postdata := fmt.Sprintf("title=%s&body[und][0][summary]=&body[und][0][value]=%s&body[und][0][format]=%s", url.QueryEscape(title), url.QueryEscape(body.Value), url.QueryEscape(body.Format)) | |
| resp := post("node/" + nid, postdata, cookie, "PUT") | |
| if resp.StatusCode != http.StatusOK { | |
| log.Fatal(resp.Status) | |
| } | |
| } |
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 editBody(original string) string { | |
| tmpfile, err := ioutil.TempFile(os.TempDir(), "myapp") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| name := tmpfile.Name() | |
| tmpfile.WriteString(msg) | |
| tmpfile.Sync() | |
| tmpfile.Close() |
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 getNode(nid string, cookie *http.Cookie) (title String, body BodyField) { | |
| resp := get("node/" + nid, cookie) | |
| rawbody := getBody(resp) | |
| var node Node | |
| if err := json.Unmarshal(rawbody, &node); err != nil { | |
| log.Fatal(err) | |
| } | |
| if len(node.Body[node.Language]) > 0 { | |
| return node.Title, node.Body[node.Language][0] |
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
| type BodyField struct { | |
| Format string | |
| Value string | |
| } | |
| type Node struct { | |
| Title string | |
| Body map[string][]BodyField | |
| Language string | |
| } |
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 getBody(resp *http.Response) []bytes { | |
| respbody, _ := ioutil.ReadAll(resp.Body) | |
| defer resp.Body.Close() | |
| return respbody | |
| } |
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 login(username, password string) *http.Cookie { | |
| resp := post("user/login", fmt.Sprintf("username=%s&password=%s", url.QueryEscape(username), url.QueryEscape(password)), nil) | |
| if resp.StatusCode != http.StatusCodeOK { | |
| log.Fatal(resp.Status) | |
| } | |
| jsondata := getBody(resp) | |
| var lr LoginResponse | |
| if err := json.Unmarshal(jsondata, &lr); err != nil { | |
| log.Fatal(err) |
NewerOlder