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/bash | |
count=1.414 | |
limit=1000 | |
while : ; | |
do | |
out=$(bc -l<<< "$count<$limit") | |
[[ $out == 0 ]] && { echo "done" ; exit 0; } | |
printf -v index "%020d" ${count//./} |
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/sh | |
# USE: | |
# git update-ref -d refs/original/refs/heads/master | |
# ...or: | |
# git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d | |
# If you see: | |
# Cannot create a new backup. | |
# A previous backup already exists in refs/original/ | |
# Force overwriting the backup with -f |
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 junk | |
import ( | |
"flag" | |
"fmt" | |
"strconv" | |
) | |
type Junk int64 |
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" | |
"os" | |
) | |
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
package main | |
import "fmt" | |
func main() { | |
s := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} | |
fmt.Println(split(s, 3)) | |
} | |
func split(s []int, width int) [][]int { |
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
// bitvec is a bit vector (also known as bit array, bit map, bit set, or bit string) compactly stores bits. | |
// It can be used to implement a simple set data structure. A bit array is effective at exploiting bit-level | |
// parallelism in hardware to perform operations quickly. A typical bit array stores kw bits, where w is the | |
// number of bits in the unit of storage, such as a byte or word, and k is some nonnegative integer. If w | |
// does not divide the number of bits to be stored, some space is wasted due to internal fragmentation. | |
package bitvec | |
import ( | |
"fmt" | |
"strings" |
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" | |
type SomeThing struct { | |
Msg string | |
} | |
func (t SomeThing) SomeNamedReciever(msg string) { | |
t.Msg = msg |
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" | |
"sync" | |
) | |
var cache = struct { | |
sync.Mutex // Mutex is embedded so its methods are promoted to the unnamed struct type | |
mapping map[string]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
package main | |
import "fmt" | |
type IntList struct { | |
Value int | |
Next *IntList | |
} | |
// A nil `IntList` represents the empty list |
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" | |
"math" | |
) | |
type Point struct { | |
X, Y float64 | |
} |