Skip to content

Instantly share code, notes, and snippets.

View natcl's full-sized avatar

Nathanaël Lécaudé natcl

View GitHub Profile
@natcl
natcl / phue.py
Last active March 17, 2020 15:50
Philips Hue Python library
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import os
import platform
import sys
if sys.version_info[0] > 2:
PY3K = True
else:
@natcl
natcl / download.py
Created November 27, 2012 01:24
file download
import urllib
files = ['000.jpg', '001.jpg', '011.jpg','111.jpg', '010.jpg','110.jpg', '101.jpg', '100.jpg']
for f in files:
url = urllib.urlopen('http://ives.psy.umontreal.ca/lights/{0}'.format(f))
with open(f, "wb") as output:
output.write(url.read())
@natcl
natcl / PictureAutomation.py
Last active December 25, 2020 10:38
Light controller for Pythonista
# -*- coding: utf-8 -*-
from scene import *
from phue import Bridge
class PictureAutomation (Scene):
def setup(self):
self.bridge = Bridge()
self.lights = self.bridge.get_light_objects('name')
self.init_state = self.get_current_state()
@natcl
natcl / light_button_control.py
Last active November 16, 2021 14:59
Script to toggle my Philips Hue lights on and off using a Raspberry Pi and a button
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This script toggles lights on and off using the phue library and a physical switch
It is started on boot in /etc/rc.local with this line:
python /home/pi/light_button_control/light_button_control.py &
'''
from time import sleep
{
"Max ToolBox":
{
"version": "15",
"link": "https://github.com/natcl/maxtoolbox/archive/master.zip"
},
"ejies":
{
"version": "3.11",
@natcl
natcl / mxj.sublime-build.json
Last active February 27, 2016 19:55
A sublime build setting for compiling MXJ objects for Max/MSP
{
"cmd": ["javac", "-classpath", "/Applications/Max 6.1/Cycling '74/java/lib/jitter.jar:/Applications/Max 6.1/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar:/Applications/Max 6.1/Cycling '74/java/lib/jython.jar:/Applications/Max 6.1/Cycling '74/java/lib/log4j-1.2.16.jar:/Applications/Max 6.1/Cycling '74/java/lib/max.jar:/Applications/Max 6.1/Cycling '74/java/lib/net.loadbang.jython-1.2.1.jar:/Applications/Max 6.1/Cycling '74/java/lib/net.loadbang.lib-1.8.0.jar:/Applications/Max 6.1/Cycling '74/java/lib/net.loadbang.scripting-1.1.0.jar:/Applications/Max 6.1/Cycling '74/java/classes/", "$file"],
"file_regex": "^ *\\[javac\\] (.+):([0-9]+):() (.*)$"
}
@natcl
natcl / ino.sublime-build.json
Last active December 17, 2015 21:29
A sublime build setting for ino (arduino) files
{
"cmd": ["ino", "build"],
"working_dir": "$file_path",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"variants": [
{ "cmd": ["ino", "upload"],
"working_dir": "$file_path",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"name": "ino upload"
'''
Index à partir de 0 représente le temps en seconde
Chaque groupe de parenthèse représente une lumière
Premier élément est l'index de la lumière (à partir de 1]
Deuxième élément est l'état:
0: Éteint
1: Allumé
2: Clignote
'''
@natcl
natcl / convert_path.py
Last active December 18, 2015 10:39
ffmpeg batch convert script in python
import os
import sys
path = sys.argv[1]
input_format = ['.' + x for x in sys.argv[2].split()]
output_format = '.' + sys.argv[3]
args = sys.argv[4]
files = [os.path.join(path,f) for f in os.listdir(path) if os.path.splitext(f.lower())[1] in input_format]
@natcl
natcl / gist:5818923
Last active December 18, 2015 17:29
Raspberry pi wireless config
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
wpa-ssid "xx"