Skip to content

Instantly share code, notes, and snippets.

View cwygoda's full-sized avatar

Christian Wygoda cwygoda

View GitHub Profile
@cwygoda
cwygoda / battery-log.sh
Created March 12, 2019 20:14
Log battery charge (check how fast battery discharges during sleep for example)
#!/bin/sh
_now="date +%s"
_power="cat /sys/class/power_supply/BAT0/charge_now"
full_power=$(cat /sys/class/power_supply/BAT0/charge_full)
last=$($_now)
last_power=$($_power)
while true
@cwygoda
cwygoda / index.js
Created June 17, 2015 13:38
Quick and Dirty Proxy
var http = require('http'),
httpProxy = require('http-proxy');
var targetPort = 5555;
var serverPort = 5050;
var proxy = httpProxy.createProxyServer({});
// To modify the proxy connection before data is sent, you can listen
// for the 'proxyReq' event. When the event is fired, you will receive
@cwygoda
cwygoda / restful.py
Created February 13, 2013 21:08
Flask-Restful error handling without overriding Flask's error handling
from flask import request, Flask
from flask.ext import restful
class Api(restful.Api):
def __init__(self, app, prefix='', default_mediatype='application/json',
decorators=None):
super(Api, self).__init__(app, prefix, default_mediatype, decorators)