Skip to content

Instantly share code, notes, and snippets.

package main
import (
"encoding/base64"
"fmt"
)
type User struct {
name, pass string
}
// 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
}
package main
import (
"fmt"
)
func IsLeapYear(y int) bool {
return y%4 == 0 && y%100 != 0 || y%400 == 0
}
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
@caelifer
caelifer / .vimrc
Created October 20, 2015 22:41
Minimal VIM resource file with nice colorscheme
" Install additional plugins
execute pathogen#infect()
" Basic configs
syntax on
filetype plugin indent on
set nu
hi CursorLine cterm=bold ctermbg=233
set cursorline
package main
import (
"fmt"
"math/rand"
"reflect"
"testing/quick"
)
type Point struct {
package main
import "fmt"
// board
type Board struct {
NailsIn, NailsNeeded int
}
// fasets
@caelifer
caelifer / merger.go
Last active November 20, 2015 18:03
// Implementation of merge task from http://raganwald.com/2015/11/03/a-coding-problem.html
package main
import (
"fmt"
"sort"
)
func main() {
package main
import "fmt"
func nextPermutation(x byte) byte {
a := x & -x
b := x + a
c := b ^ x
a <<= 2
c /= a
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)