Skip to content

Instantly share code, notes, and snippets.

View sescobb27's full-sized avatar
🇨🇴
sisas parce

Simon Escobar Benitez sescobb27

🇨🇴
sisas parce
View GitHub Profile
@dcadenas
dcadenas / missing_heroku_config_vars
Created June 6, 2015 01:37
Shows ENV vars in the Rails app that can't be found in the heroku config
#!/bin/bash
echo "These ENV variables only exist in the rails app but not in the heroku config"
echo
envs_in_rails() {
git grep "ENV\[" | sed "s/.*ENV\[['\"]\(.*\)['\"]\].*/\1/" | sort | uniq
}
envs_in_heroku() {
@michiwend
michiwend / limited_wait_group.go
Created May 31, 2015 17:13
Limited wait group in Go (Golang)
type LimitedWaitGroup struct {
limit int
count int
countChan chan int
}
func NewLimitedWaitGroup(limit int) *LimitedWaitGroup {
wg := LimitedWaitGroup{limit: limit}
wg.countChan = make(chan int)
return &wg
@taotetek
taotetek / encode.go
Created May 24, 2015 16:59
ReadWriter support in goczmq
package main
import (
"encoding/gob"
"fmt"
"github.com/zeromq/goczmq"
)
// person is an example type we will encode, send, and decode
require 'objspace'
class A
# When we include a module, it makes an invisible "included class" (T_ICLASS),
# and places it in the inheritance hierarchy, as the superclass.
# Hence A the inclusion, A no longer has a direct reference to Object,
# it now has a direct reference to the included class
ObjectSpace.reachable_objects_from(self) # => [#<InternalObject:0x007f8cd29343b8 T_CLASS>, "A", Object]
m = Module.new
include m
Just some stuff you might like to read / watch on the plane if you are interested.
OP-ED:
http://www.evanmiller.org/four-days-of-go.html
Video:
https://youtu.be/elu0VpLzJL8 -- Go for pythonista's -- 51m
https://youtu.be/woCg2zaIVzQ -- Concurrency + Composition -- 14m
https://youtu.be/B-r3Wf_I2Lk -- General stuff -- 18m
https://www.youtube.com/playlist?list=PLMW8Xq7bXrG58Qk-9QSy2HRh2WVeIrs7e -- Others
@twotwotwo
twotwotwo / sorts.md
Last active December 9, 2023 08:41
Sorting 5x faster with Go: how it's possible, what didn't work so well, and what I learned

github.com/twotwotwo/sorts is a Go package with parallel radix- and quicksorts. It can run up to 5x faster than stdlib sort on the right kind of large sort task, so it could be useful for analysis and indexing/database-y work in which you have to sort millions of items. (To be clear, I don't recommend most folks drop stdlib sort, which is great, and which sorts depends on.)

While the process of writing it's fresh on my mind, here are some technical details, some things that didn't make the cut, and some thoughts about the process:

Concretely, what this looks like inside:

  • Both number and string versions are in-place MSD radix sorts that look at a byte at a time and, once the range being sorted gets down to 128 items, call (essentially) the stdlib's quicksort.

  • The [parallelization code

@Mistobaan
Mistobaan / context_example.go
Created May 4, 2015 19:29
context Example
// Default HTTP handler
type Handler func(ctx *Context, w http.ResponseWriter, r *http.Request) error
// ServeHTTP implements http.Handler for our custom type Handler
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx = NewContext(r)
defer ctx.Cancel()
err := h(ctx, w, r)
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@zabirauf
zabirauf / ROP.ex
Created March 26, 2015 07:48
Railway Oriented Programming macros in Elixir
defmodule ROP do
defmacro try_catch(args, func) do
quote do
(fn ->
try do
unquote(args) |> unquote(func)
rescue
e -> {:error, e}
end
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
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) }