Skip to content

Instantly share code, notes, and snippets.

View fradaloisio's full-sized avatar

Francesco d'Aloisio fradaloisio

View GitHub Profile
@fradaloisio
fradaloisio / restsql.py
Last active August 29, 2015 14:17
Quick and dirty rest DB query with flask and SQLite3
from flask import Flask, request
import sqlite3
import json
app = Flask(__name__)
@app.route('/get')
def get():
conn = sqlite3.connect('my_magic.db')
q = request.args.get('q')
print(q)
@fradaloisio
fradaloisio / jsonTOinfluxdb.py
Created March 29, 2015 22:40
get a JSON from a GET request and create a json to POST in influxdb
import json
import requests
r = requests.get('http://127.0.0.1:5000/get?q=select * from users limit 2')
json_obj = json.dumps(r.json())
jsonfinal = json.loads(json_obj)
for mis in jsonfinal:
col = []
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
@fradaloisio
fradaloisio / errors.conf
Created November 16, 2015 19:08
This apache conf simulate the return code. If you request localhost/error401 , apache return the 401 code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/error100$ 100 [L,R=100]
RewriteRule ^/error101$ 101 [L,R=101]
RewriteRule ^/error102$ 102 [L,R=102]
RewriteRule ^/error200$ 200 [L,R=200]
RewriteRule ^/error201$ 201 [L,R=201]
RewriteRule ^/error202$ 202 [L,R=202]
RewriteRule ^/error203$ 203 [L,R=203]
RewriteRule ^/error204$ 204 [L,R=204]
@fradaloisio
fradaloisio / wicd on Raspbian Raspberry Pi B+
Last active December 3, 2016 10:59
wicd on Raspbian Raspberry Pi B+
sudo apt-get install wicd-curses
sudo systemctl disable dhcpcd
sudo /etc/init.d/dhcpcd stop
sudo wicd-curses
brew cask install osxfuse
brew tap homebrew/fuse
brew install ntfs-3g
sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.bak
sudo ln -s /usr/local/sbin/mount_ntfs /sbin/mount_ntfs
echo 'config.vm.synced_folder ".", "/vagrant", type: "virtualbox"' >> Vagrantfile
vagrant plugin install vagrant-vbguest
vagrant destroy && vagrant up
@fradaloisio
fradaloisio / test_api.py
Last active May 5, 2017 12:45
API Test
from flask import Flask
from flask import jsonify
app = Flask(__name__)
@app.route("/")
def hello():
return jsonify({'message' : 'Hello!'})
@app.route("/date")
def getDate():
import datetime
/// <reference path="angular.d.ts" />
/// <reference path="angular-route.d.ts" />
/// <reference path="angular-sanitize.d.ts" />
/// <reference path="bootstrap.d.ts" />
/// <reference path="moment.d.ts" />
/// <reference path="moment-duration-format.d.ts" />
/// <reference path="d3.d.ts" />
/// <reference path="underscore.d.ts" />
var bosunApp = angular.module('bosunApp', [
'ngRoute',
## BOSUN
RewriteRule /alerting/static/js/bosun.js /var/www/html/my-static/js/bosun.js [L]
<Location /alerting>
AddOutputFilterByType SUBSTITUTE text/html text/plain text/xml text/css text/javascript application/javascript application/json
Substitute "s#href=\"/#href=\"/alerting/#ni"
Substitute "s#ng-href=\"/#ng-href=\"/alerting/#ni"
Substitute "s#src=\"/#src=\"/alerting/#ni"
Substitute "s#data-path=\"/#data-path=\"/alerting/#ni"
Substitute "s#MYHOST/#MYHOST/alerting/#ni"