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 ( | |
"encoding/base64" | |
"fmt" | |
) | |
type User struct { | |
name, pass 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
// Taken from https://github.com/mdempsky/maligned/blob/master/maligned.go#L227. | |
// Corrected for the negative x. | |
// align returns the smallest y >= x such that y % a == 0. | |
func align(x, a int64) int64 { | |
sign := int64(1) | |
if x < 0 { | |
x = -x | |
sign = -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 ( | |
"fmt" | |
) | |
func IsLeapYear(y int) bool { | |
return y%4 == 0 && y%100 != 0 || y%400 == 0 | |
} |
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 "fmt" | |
type Rule func(int) string | |
func filter(div int, tag string) Rule { | |
return func(n int) string { | |
if n%div == 0 { | |
return tag |
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
" Install additional plugins | |
execute pathogen#infect() | |
" Basic configs | |
syntax on | |
filetype plugin indent on | |
set nu | |
hi CursorLine cterm=bold ctermbg=233 | |
set cursorline |
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 ( | |
"fmt" | |
"math/rand" | |
"reflect" | |
"testing/quick" | |
) | |
type Point struct { |
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 "fmt" | |
// board | |
type Board struct { | |
NailsIn, NailsNeeded int | |
} | |
// fasets |
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
// Implementation of merge task from http://raganwald.com/2015/11/03/a-coding-problem.html | |
package main | |
import ( | |
"fmt" | |
"sort" | |
) | |
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
package main | |
import "fmt" | |
func nextPermutation(x byte) byte { | |
a := x & -x | |
b := x + a | |
c := b ^ x | |
a <<= 2 | |
c /= a |
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 "fmt" | |
type F1 func(int) int | |
type F2 func(int, int) int | |
func apply(f F2, n int) F1 { | |
return func(x int) int { | |
return f(n, x) |