Skip to content

Instantly share code, notes, and snippets.

View DrGo's full-sized avatar
💭
Palm oil. know the facts!

DrGo

💭
Palm oil. know the facts!
View GitHub Profile
@infogulch
infogulch / multisort.go
Last active May 6, 2016 23:59
How to design a Go slice type that needs to be sortable in many ways.
// How to design a Go slice type that needs to be sortable in many ways.
package main
import (
"fmt"
"sort"
)
type data struct {
i int
@tmaiaroto
tmaiaroto / pre-commit
Last active July 30, 2016 22:29
A Go Commit Hook for Less Future Headaches
#!/bin/bash
#
# Check a "few" things to help write more maintainable Go code.
#
# OK, it's fairly comprehensive. So simply remove or comment out
# anything you don't want.
#
# Don't forget to install (go get) each of these tools.
# More info at the URLs provided.
#
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@albulescu
albulescu / download.go
Created March 25, 2016 09:44
golang download file with progress
package main
/**
* @website http://albulescu.ro
* @author Cosmin Albulescu <cosmin@albulescu.ro>
*/
import (
"bytes"
"fmt"
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 23, 2024 06:15
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@jpillora
jpillora / csrand.go
Last active April 12, 2016 23:46
Hash DRBG implementation in Go (Golang) from the TOR project
/*
* Copyright (c) 2014, Yawning Angel <yawning at torproject dot org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
@iamralch
iamralch / searchr.go
Created July 11, 2015 11:50
searchr - a sample application that works with pipes
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"strings"
)
@JeffPaine
JeffPaine / i3-cheat-sheet.md
Last active March 6, 2024 08:07
i3 Window Manager Cheat Sheet

i3 Window Manager Cheat Sheet

$mod refers to the modifier key (alt by default)

General

  • startx i3 start i3 from command line
  • $mod+<Enter> open a terminal
  • $mod+d open dmenu (text based program launcher)
  • $mod+r resize mode ( or to leave resize mode)
  • $mod+shift+e exit i3
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 16, 2024 12:16
Golang landmines

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@josephspurrier
josephspurrier / bitmask.go
Last active March 13, 2021 04:44
Golang - Determine if bitmask is set
/*
fmt.Println(Bitmask(0x6).IsSet(0x2))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListDescriptions(charValues))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListValues(charValues))
*/
type Bitmask uint16
// BitValue is a value and a description
type BitValue struct {