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 ( | |
"os" | |
"fmt" | |
"time" | |
"github.com/bradclawsie/golock" | |
) | |
func main() { |
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
#!/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 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
$ run-exclusive.sh ./testlock t.lock |
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
;; 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 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 Foo struct { | |
MandatoryString string | |
OptionalUInt64 uint64 | |
OptionalString 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
{ "MandatoryString":"somestring", "OptionalUInt64":1, "OptionalString":"anotherstring" } | |
{ "MandatoryString":"somestring", "OptionalUInt64":1, "OptionalString":null } | |
{ "MandatoryString":"somestring", "OptionalUInt64":null, "OptionalString":"anotherstring" } | |
{ "MandatoryString":"somestring", "OptionalUInt64":null, "OptionalString":null } | |
{ "MandatoryString":"somestring", "OptionalUInt64":1 } |
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 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 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 Foo struct { | |
MandatoryString string | |
OptionalUInt64 NullableUInt64 | |
OptionalString NullableString | |
} |
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 org.b7j0c.puzzles; | |
import java.util.EnumMap; | |
import java.util.Map; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.ArrayList; | |
// the Hex class represents an id with six neighbors. the orientation of the neighbors is irrelevant | |
// but it is useful to describe them with compass directions as such: |
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 org.b7j0c.puzzles; | |
// http://programmingpraxis.com/2013/11/15/twitter-puddle/ | |
public final class Puddles { | |
public static void main(String[] args) { | |
int[] c = {2,5,1,2,3,4,7,7,6,1,1,9,8,8,9,1,1}; | |
int cl = c.length; | |
int w = -1; | |
int sub = 0; |