Skip to content

Instantly share code, notes, and snippets.

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

Keybase proof

I hereby claim:

  • I am jheth on github.
  • I am jheth (https://keybase.io/jheth) on keybase.
  • I have a public key ASDDKUcgCopBv1edZ1pM1dKLxO6FRZ719jWdYQa3d4JEmwo

To claim this, I am signing this object:

docker pull swaggerapi/swagger-ui
docker tag swaggerapi/swagger-ui registry.heroku.com/outdoorsy-swagger/web
docker push registry.heroku.com/outdoorsy-swagger/web
heroku container:release web --app outdoorsy-swagger
^[^iIoOqQ'-]{10,17}$
@jheth
jheth / MarshalJSON.go
Created March 22, 2018 13:37
NullInt64 MarshalJSON
// 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
jheth / update-from-sub-query.sql
Last active January 24, 2018 16:00
sql update from sub-query
-- 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
jheth / go-clean-string.go
Last active January 3, 2018 17:58
GoLang CleanString
// 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 {
# Default 1 MB
show variables like 'max_allowed_packet'
# 10 MB
set global max_allowed_packet=10485760
@jheth
jheth / bulk_delete_redis.sh
Created November 29, 2016 19:16
Bulk Redis Delete
redis-cli KEYS "Proposal*" | xargs redis-cli DEL
# 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
#end