Skip to content

Instantly share code, notes, and snippets.

View victorfsf's full-sized avatar
🕵️‍♂️
Exploring

Victor Ferraz victorfsf

🕵️‍♂️
Exploring
View GitHub Profile
#!/usr/bin/env sh
sudo apt-get install -y \
git \
g++ \
libgtk-3-dev \
gtk-doc-tools \
gnutls-bin \
valac \
intltool \
@victorfsf
victorfsf / mj-ws-flask-mock.py
Last active March 26, 2018 18:48
Mocking WS for MJ
from flask import Flask
from flask import request
from flask import Response
from functools import wraps
import json
app = Flask(__name__)
def login_required(f):
#!/usr/bin/env zsh
sleep 10 &!
pid=$! # Process Id of the previous running command
spin='⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓'
i=0
while kill -0 $pid 2>/dev/null; do
i=$(((i + 1) % 10))
printf "$fg[magenta]\r${spin:$i:1}"
@victorfsf
victorfsf / config
Last active October 21, 2017 13:31
Terminator config (~/.config/terminator/)
[global_config]
suppress_multiple_term_dialog = True
[keybindings]
[layouts]
[[default]]
[[[child1]]]
parent = window0
type = Terminal
[[[window0]]]
parent = ""
# Base code from: https://iamtrask.github.io/2015/11/15/anyone-can-code-lstm/
import copy
import numpy as np
np.random.seed(1)
def sigmoid(x):
output = 1/(1+np.exp(-x))
#!/bin/bash
if [ $# != 2 ]
then
echo "minify takes exactly 2 arguments ($# given)"
exit 1
fi
case ${1} in
-f)
@victorfsf
victorfsf / 00-venv-sitepackages.py
Last active January 16, 2017 11:53
IPython startup scripts
"""IPython startup script to detect and inject VIRTUAL_ENV's site-packages dirs. # noqa
IPython can detect virtualenv's path and injects it's site-packages dirs into sys.path.
But it can go wrong if IPython's python version differs from VIRTUAL_ENV's.
This module fixes it looking for the actual directories. We use only old stdlib
resources so it can work with as many Python versions as possible.
References:
http://stackoverflow.com/a/30650831/443564
@victorfsf
victorfsf / .cd.sh
Last active January 20, 2017 16:21
# @victorfsf - custom cd v0.1
function cd() {
if [ "$1" == "-i" ]
then
shift 1
builtin cd "$@"
return 0
fi
builtin cd "$@" && gital

Setting up Jupyter to run Django with an enviroment variables file.

Run (the file must include a DJANGO_SETTINGS_MODULE env variable):
export $(cat .env | grep -v ^# | xargs) 
# variables
dbname=$1
dumpfile=$2
dbbk=$dbname"_bk"
# defaults
usebk=${3:-false}
host=${4:-localhost}
port=${5:-5432}
username=${6:-postgres}