Skip to content

Instantly share code, notes, and snippets.

View montanaflynn's full-sized avatar

Montana Flynn montanaflynn

View GitHub Profile
package main
import (
"fmt"
)
func main() {
println()
defer println()
@montanaflynn
montanaflynn / gif.go
Created October 13, 2017 23:08
Turn uploaded images into a gif
package main
import (
"bytes"
"fmt"
"html/template"
"image"
"image/color"
"image/draw"
"image/gif"
@montanaflynn
montanaflynn / output.txt
Last active April 4, 2017 04:20
Output of `man hier` on OSX
$ man hier
HIER(7) BSD Miscellaneous Information Manual HIER(7)
NAME
hier -- layout of filesystems
DESCRIPTION
A historical sketch of the filesystem hierarchy. The modern OS X filesystem is documented in the ``File System Programming Guide'' available on Apple Developer.
/ root directory of the filesystem
@montanaflynn
montanaflynn / main.go
Last active July 31, 2017 19:24
Dealing with errors in an http server by implementing the error interface with a status field
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
)
@montanaflynn
montanaflynn / setup.md
Last active September 16, 2021 12:10 — forked from fortunto2/setup.md
Setup Amazon AWS EC2 g2.2xlarge instance with OpenCV 3.1, Cuda 7.5, ffmpeg, OpenFace
@montanaflynn
montanaflynn / shell.sh
Last active January 12, 2017 07:14
failed attempt to open a url from the terminal
# works as expected
$ open "https://gifs.com/gif/2RXRAW"
# this prints the same url as expected by reading from stdin since it's being piped from jq
$ cat 2RXRAW.json | jq .success.page | echo $(</dev/stdin)
"https://gifs.com/gif/2RXRAW"
# this also works just to demonstrate that open should be able to open from the piped stdin
$ cat 2RXRAW.json | jq .success.page | echo $(echo $(</dev/stdin))
"https://gifs.com/gif/2RXRAW"
@montanaflynn
montanaflynn / concurrency.go
Last active October 26, 2023 13:35
A simple example of bounded concurrency and wait groups in Golang
package main
import (
"fmt"
"sync"
"time"
)
func main() {
@montanaflynn
montanaflynn / pget.go
Last active January 17, 2025 17:07
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
@montanaflynn
montanaflynn / README.md
Last active December 1, 2016 22:02
Committing portions of a file rather than the entire file

You can use git add --patch file.ext (or -p for short), and git will begin to break down your file into hunks.

Stage this hunk [y,n,q,a,d,/,j,J,g,s,e,?]?

Here is a description of each option:

  • y stage this hunk for the next commit
  • n do not stage this hunk for the next commit
  • q quit; do not stage this hunk or any of the remaining hunks
  • a stage this hunk and all later hunks in the file
@montanaflynn
montanaflynn / README.md
Last active March 9, 2021 00:45
Docker logs to ELK stack

Three steps to viewing docker logs in kibana

1) Save this to ./logstash.conf:

# Docker can send logs in gelf format
input {
  gelf { }
}