Skip to content

Instantly share code, notes, and snippets.

@guylaor
guylaor / pprof.sh
Created June 29, 2017 19:59
Commands to use Go pprof
# command to export the profiling info as an svg graph
go tool pprof -svg name_of_executable_program_file /Users/g.laor/profile.dev.pg.gz > profile.dev.svg
func connectionString() string {
conn := fmt.Sprintf("%s:%s@(%s:3306)/%s?charset=utf8", config["db_user"], config["db_pass"], config["db_host"], config["db_name"])
return conn
}
func authenticateUser(username string, password string) string {
db, err := sql.Open("mysql", fmt.Sprintf("%s", connectionString()))
checkError(err)
@guylaor
guylaor / go-on-elasticbeanstalk.txt
Created April 11, 2017 20:42
Get Go to run on elasticbeanstalk
Create 3 files.
/build.sh ---> remember to chmod +x this file
go get github.com/gorilla/mux
go build -o bin/application *.go
/Buildfile
make: ./build.sh
/Procfile
@guylaor
guylaor / proxy.go
Created November 29, 2016 16:03 — forked from vmihailenco/proxy.go
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
@guylaor
guylaor / gist:3eb9e7ff2ac91b7559625262b8a6dd5f
Created November 23, 2016 20:27
Installing Selenium with Python 3 on mac
Install python 3
create a virtualenv and then
pip install selenium
then install chrome driver:
brew install chromedriver
to test, run this script - notice the location of the chrome driver
@guylaor
guylaor / installing python 3.5
Last active June 3, 2016 21:30
installing python 3.5
brew install pyenv
pyenv install 3.5.0
virtualenv -p /Users/Guy/.pyenv/versions/3.5.0/bin/python3.5 mypy3
. ./mypy3/bin/activate
python --version
# installing tensor flow
pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py3-none-any.whl
@guylaor
guylaor / ReactJS_transform_CSS_example.js
Last active August 20, 2022 18:24
Using CSS transform: translate(...) with ReactJS
render: function() {
var cleft = 100;
var ctop = 100;
var ctrans = 'translate('+cleft+'px, '+ctop+'px)';
var css = {
transform: ctrans
}
return (