Skip to content

Instantly share code, notes, and snippets.

View ioggstream's full-sized avatar

Roberto Polli ioggstream

View GitHub Profile
@ioggstream
ioggstream / git-https-switch.sh
Last active April 20, 2016 08:06
Switch git url between https and ssh via networkmanager
#!/bin/bash
export LANG=C
progname=$0
interface=$1
status=$2
case "$status" in
up|down|vpn-up|vpn-down)
@ioggstream
ioggstream / tablet-mode-sensor.py
Last active August 1, 2016 20:44
Use sklearn to decide whether the computer is in tablet or laptop mode.
"""
Use sklearn to decide whether the computer is in tablet or laptop mode.
To play:
#tablet-mode-sensor.py gather # gather data in 2 csv files
#tablet-mode-sensor.py fit # create and store with pickle the predictor
#tablet-mode-sensor.py check # read the sensors and predict the laptop mode
To disable keyboard|touchpad get your device_ids with xinput and uncomment the
xinput lines.
@ioggstream
ioggstream / Vagrantfile
Created August 24, 2016 09:38
DigitalOcean Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Define machine specs
boxes = [
{ :name => "e1" },
{ :name => "e2" },
]
# All Vagrant configuration is done below. The "2" in Vagrant.configure
import flask
import flask_sqlalchemy
from sqlalchemy.dialects.mysql import JSON
# A simple flask app connected to a db
app = flask.Flask('app')
app.config['SQLALCHEMY_DATABASE_URI']='mysql+mysqlconnector://root:secret@localhost:3306/test'
db = flask_sqlalchemy.SQLAlchemy(app)
@ioggstream
ioggstream / tinyproxy.conf
Created April 8, 2017 15:19
tinyproxy with
User tinyproxy
Group tinyproxy
Port 8888
Timeout 600
DefaultErrorFile "/usr/share/tinyproxy/default.html"
StatFile "/usr/share/tinyproxy/stats.html"
LogFile "/var/log/tinyproxy/tinyproxy.log"
LogLevel Info
PidFile "/var/run/tinyproxy/tinyproxy.pid"
upstream 172.49.191.63:8123 "172.23.177.2"
@ioggstream
ioggstream / storageclass.yaml
Created April 19, 2017 13:39
Openshift storage classes
# A storage class provision volumes from
# different provisioners, eg. cinder.
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: ssd
annotations:
storageclass.beta.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/cinder
@ioggstream
ioggstream / openshift_loadbalancer_meta_main.yml
Last active May 2, 2017 13:52
Open firewall ports openshift loadbalancer
openshift_loadbalancer_additional_frontends:
- name: openshift-api-fe-80
mode: tcp
options: tcplog
binds: [ "*:80" ]
default_backend: openshift-api-be-80
- name: openshift-api-fe-443
mode: tcp
options: tcplog
#!/usr/bin/python
"""Get ips from nova hosts. Quick and dirty.
"""
from re import findall
from subprocess import check_output
from shlex import split
from json import dumps
def sh(cmd):
return check_output(split(cmd))
@ioggstream
ioggstream / openshift_lbaasv2.yaml
Created May 4, 2017 17:29
Stub for LBaaSv2 for openshift-on-openstack
heat_template_version: 2016-04-08
description: |
Auto-Scaling Group for Apache servers.
Uses the apache-poolmember and apache templates.
parameters:
external:
type: string
@ioggstream
ioggstream / heat-ternary-yaql.yaml
Created May 18, 2017 17:11
Ternary operator with heat and yaql
heat_template_version: newton
parameters:
one:
type: string
default: one
two:
type: string
default: two