Skip to content

Instantly share code, notes, and snippets.

View LeoCBS's full-sized avatar
👨‍👩‍👧‍👧

Leonardo Cesar Borges LeoCBS

👨‍👩‍👧‍👧
  • Florianópolis - SC / Brazil
View GitHub Profile
@topherPedersen
topherPedersen / strip_newline.go
Created February 3, 2020 20:56
How to Strip Newline Characters from a String in Golang
package main
import (
"fmt"
"strings"
)
func main() {
var string_a string = "My super \nsweet \nstring has \nmany newline\n characters"
import urllib.request
import json
api_key = '7ba14b76dcea0086a03f8eca5a3a801f:1:74295566'
category = 'editorial'
for i in range(5):
url = "http://api.nytimes.com/svc/search/v2/articlesearch.json?" \
"q={0}&api-key={1}&page={2}".format(category, api_key, i)
h = urllib.request.urlopen(url)
result = json.loads(h.read().decode('utf-8'))
@tamoyal
tamoyal / gist:2ea1fcdf99c819b4e07d
Last active February 13, 2020 11:24
Upgrade Postgres 9.3 to 9.4 on Ubuntu
# Be sure to save your config files. Optional but I do:
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~
# Package repo (for apt-get)
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Also probably optional but I like to update sources and upgrade
sudo apt-get update
@kkdai
kkdai / mgo-go-query-sample.go
Created August 6, 2014 16:15
go- mongoDB mgo insert and query greater than sample
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type msg struct {
// Msg string `bson:"msg"`
@sloria
sloria / bobp-python.md
Last active June 26, 2024 15:54
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@border
border / mgoExample.go
Created August 27, 2012 15:33
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: