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
type NullableString string | |
func (n NullableString) MarshalJSON() ([]byte, error) { | |
sn := string(n) | |
if sn == "" { | |
var i interface{} | |
return json.Marshal(i) | |
} | |
return json.Marshal(sn) | |
} |
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
type Foo struct { | |
MandatoryString string | |
OptionalUInt64 uint64 | |
OptionalString string | |
} | |
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
;; blog.jazzychad.net/2012/08/01/array-iteration-problem.html | |
(use srfi-1) | |
(: f ((list-of number) number number -> (list-of number))) | |
(define f | |
(lambda (arr n i) | |
(cond [(< n 0) | |
;; if we are going right-to-left, reverse the list and use the abs count | |
(reverse (f (reverse arr) (abs n) i))] |
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
$ run-exclusive.sh ./testlock t.lock |
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
#!/bin/zsh | |
# call like: | |
# $ run-exclusive.sh /path/of/progname /path/of/lockfile | |
# e.g. | |
# $ run-exclusive.sh ./testlock t.lock | |
# clearly you want progname to be something that will only match once. | |
# don't use a short string that is a substring match of something else running | |
export PROGNAME=$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 main | |
import ( | |
"os" | |
"fmt" | |
"time" | |
"github.com/bradclawsie/golock" | |
) | |
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
#lang typed/racket | |
(define-type T (U String Integer)) | |
(: fizzbuzz : ((Listof Integer) -> (Listof T))) | |
(define fizzbuzz | |
(lambda (l) | |
(cond [(null? l) '()] | |
[else (let* ([x (car l)] | |
[xs (cdr l)] | |
[mod3 (eq? 0 (modulo x 3))] |
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 ( | |
"bufio" | |
"compress/gzip" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"net/http" |
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
module Main where | |
import qualified Data.Conduit as C | |
import qualified Network.HTTP.Conduit as HC | |
main :: IO () | |
main = do | |
manager <- HC.newManager HC.def | |
request' <- HC.parseUrl "https://www.google.com/" | |
let request = request' { HC.checkStatus = \_ _ -> Nothing } | |
response <- C.runResourceT $ HC.httpLbs request manager |
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
extern mod std; | |
fn main() { | |
let mut i = 1; | |
while i <= 100 { | |
let mod3 = ((i % 3) == 0); | |
let mod5 = ((i % 5) == 0); | |
if ! (mod3 || mod5) { | |
io::println(fmt!("%d",i)); | |
} else { |