Skip to content

Instantly share code, notes, and snippets.

View andete's full-sized avatar

Joost Yervante Damad andete

View GitHub Profile
@andete
andete / gist:7612927
Created November 23, 2013 10:16
Checking if my lab Philips Hue lamp is on and turning it on if needed:
#!/usr/bin/env python
import json
import requests
from settings import host, key
data = requests.get('http://%s/api/%s/lights/2' % (host, key)).json()
lamp_on = data['state']['on']
print data
if not lamp_on:
@andete
andete / gist:8440992
Created January 15, 2014 17:53
hello.js faulty javascript generated by coffee -c ?
--- hello.js 2014-01-15 18:42:39.446944705 +0100
+++ hello.js.fix 2014-01-15 18:20:23.099359963 +0100
@@ -1,8 +1,6 @@
(function() {
- var http;
-
- require(http = 'http');
+ var http = require('http');
http.createServer(function(req, res) {
@andete
andete / proxy.coffee
Created January 15, 2014 18:30
simple (future partial) http proxy in node.js
http = require 'http'
url = require 'url'
http_proxy = require 'http-proxy'
proxy = new http_proxy.RoutingProxy()
http.createServer (req, res) ->
console.log 'Incoming Request from: ' +
req.connection.remoteAddress +
@andete
andete / plant_label.openscad
Last active August 29, 2015 13:56
minkowski is cool
$fn=10;
minkowski() {
difference() {
cube(size=[100,13,0.5], center=true);
union() {
translate(v=[50,10,0]) rotate(a=[0,0,-30]) cube(size=[30,20,4], center=true);
translate(v=[50,-10,0]) rotate(a=[0,0,30]) cube(size=[30,20,4], center=true);
}
}
sphere(r=0.5, center=true);
@andete
andete / mocp-minishift.py
Last active August 29, 2015 14:00
show current playing media server song on the minishift display array
#!/usr/bin/env python
import subprocess, time, requests
last_line = ""
while True:
try:
lines = subprocess.check_output(["mocp", "-i"])
lines2 = lines.split('\n')
artist = ""
@andete
andete / mcp1650.py
Last active August 29, 2015 14:00
mcp1650 inductor calculation DCM mode
#!/usr/bin/env python
import time
from math import log10
Vin = 5.0
if Vin < 3.8:
D = 0.8
else:
module circlet(diameter, thickness, height) {
inner = diameter/2;
difference() {
cylinder(r=inner+thickness, h=height, $fn=256);
cylinder(r=inner, h=height*3, center=true, $fn=256);
translate(v=[0,20,0])
cube(size=[inner*2-6, inner*2, height*3], center=true);
}
@andete
andete / mpd-minishift.py
Created October 19, 2014 12:01
checks current playing song on mpd server with mpc client and displays it on minishift
#!/usr/bin/env python
import subprocess, time, requests, sys
last_line = ""
while True:
try:
lines = subprocess.check_output(["mpc", "current", "-f", "%artist%_%album%_%title%"])
artist = ""
song = ""
@andete
andete / Makefile
Created November 16, 2014 08:07
EFM32 bootloader automatic xmodem upload using screen
xmodem: exe/$(PROJECTNAME).bin
screen -d -m -S 'serial' /dev/ttyACM4 115200
sleep 0.1
screen -x "serial" -X eval '!!!| echo u'
sleep 0.1
screen -x "serial" -X eval "exec !! sx -vv $<"
sleep 2
screen -x "serial" -X eval '!!!| echo b'
@andete
andete / gist:71b531b081fbc3ac0671
Created May 25, 2015 09:02
KiCad BOM script example
#!/usr/bin/env python
# (c) 2015 Productize <joost@productize.be>
import sys, copy, collections, codecs
from bs4 import BeautifulSoup
soup = BeautifulSoup(open(sys.argv[1]))
date = soup.design.date.contents[0]