Skip to content

Instantly share code, notes, and snippets.

View hfogelberg's full-sized avatar

Henrik Fogelberg hfogelberg

View GitHub Profile
@hfogelberg
hfogelberg / Mongo connection Go
Last active September 19, 2017 08:54
Create Mongo connection from Go
package main
import "gopkg.in/mgo.v2"
type Connection struct {
DB *mgo.Database
}
const MongoDb = "test"
@hfogelberg
hfogelberg / Python Notebook Shortcuts
Created July 18, 2017 13:37
Python Notebook Shortcuts
Shift-Enter run cell
Ctrl-Enter run cell in-place
Alt-Enter run cell, insert below
Ctrl-m x cut cell
Ctrl-m c copy cell
Ctrl-m v paste cell
Ctrl-m d delete cell
Ctrl-m z undo last cell deletion
Ctrl-m – split cell
Ctrl-m a insert cell above
@hfogelberg
hfogelberg / Docker
Last active October 26, 2017 13:40
## Installing
$ docker version
$ docker run hello-world // Runs the Hello World sample. Downloads from Dockerhub if it isn't available locally
$ docker ps -a // Prints out all available containers on local machine
$ docker ps // Prints out all running containers on local machine
## Searching and runing
$ docker search whalesay | grep docker // Searches docker hub and filters with grep
$ docker run docker/whalesay cowsay Hello
Start mysql
$ mysql.server start
Login as root
$ mysql -u root -p
Show databases
mysql> SHOW DATABASES
Create database
# Postgres cheat sheet
Note on prompts:
$ The command is run from the unix shell
# The command is run from psql, logged in as the default user.
=> The command is run from psql, logged in as a specific user.
Make sure that psql will auto start
$ pg_ctl -D /usr/local/var/postgres start && brew services start postgresql
# Data Preprocessing Template
# Importing the libraries
import numpy
import matplotlib.pyplot
import pandas
from sklearn.preprocessing import Imputer
from sklearn.preprocessing import LabelEncoder, OneHotEncoder, StandardScaler
from sklearn.cross_validation import train_test_split
package main
import (
"fmt"
)
type person struct {
fname string
lname string
}
// Print header
func myFunc(w http.ResponseWriter, r *http.Request) {
for k, v := range r.Header {
log.Println("key:", k, "value:", v)
}
}
// A. Print type of variable
fmt.Printf("Type of x %T\n", x)
## Navigation
### Switch panes
ctrl-w, then arrow
ctrl-F Move to next screen
## NERDTree
m: Access menu
ctrl-k b Open NERDTree
## Run Unix command
mongo 199.124.1.2:12128/dbname -u dbusername -p dbpassword
1 2 3 4 5
Explanation for those who are struggling
1. you server static IP address
2. you exposed port no (any in one of the four user B when A->B)
3. your databasename this is what you enter while you run this command dokku mongo:create dbname
4 & 5. you will get this when running dokku mongo:info