Skip to content

Instantly share code, notes, and snippets.

View gist:a8766807e5f1b402296b25961d687f61
reader := bufio.NewReader(os.Stdin)
fmt.Print("Skip? ")
text, _ := reader.ReadString('\n')
if strings.HasPrefix(strings.ToLower(text), "y") {

Keybase proof

I hereby claim:

  • I am jheth on github.
  • I am jheth ( on keybase.
  • I have a public key ASDDKUcgCopBv1edZ1pM1dKLxO6FRZ719jWdYQa3d4JEmwo

To claim this, I am signing this object:

View heroku container deploy
docker pull swaggerapi/swagger-ui
docker tag swaggerapi/swagger-ui
docker push
heroku container:release web --app outdoorsy-swagger
jheth / MarshalJSON.go
Created Mar 22, 2018
NullInt64 MarshalJSON
View MarshalJSON.go
// NullInt64 is an alias for sql.NullInt64 data type
type NullInt64 sql.NullInt64
// MarshalJSON for NullInt64
func (ni *NullInt64) MarshalJSON() ([]byte, error) {
if !ni.Valid {
return []byte("null"), nil
return json.Marshal(ni.Int64)
jheth / update-from-sub-query.sql
Last active Jan 24, 2018
sql update from sub-query
View update-from-sub-query.sql
-- great way to batch update using a sub-query in the from clause
update category set catid=100
from (
select event.catid
from event
left join category cat on event.catid = cat.catid
where cat.catid is null
limit 1000
) eventcat
where category.catid = eventcat.catid
jheth / go-clean-string.go
Last active Jan 3, 2018
GoLang CleanString
View go-clean-string.go
// Hacky way to strip unicode characters.
func CleanText(text string, maxLength int) string {
if len(text) < 5 {
return ""
if strings.Contains(text, "\n") {
sections := strings.Split(text, "\n")
newText := sections[0]
for idx, s := range sections {
View gist:8e16a05b9fe71ec78cf3cc129b098e8a
# Default 1 MB
show variables like 'max_allowed_packet'
# 10 MB
set global max_allowed_packet=10485760
redis-cli KEYS "Proposal*" | xargs redis-cli DEL
View .pryrc
# Turn off the automatic pager
Pry.config.pager = false
# Make the prompt silly.
Pry.config.prompt_name = 'oh no!'
# Hit Enter to repeat last command
#Pry::Commands.command(/^$/, 'repeat last command') do
# _pry_.run_command Pry.history.to_a.last