Skip to content

Instantly share code, notes, and snippets.

View Phyks's full-sized avatar

Lucas Verney Phyks

View GitHub Profile
@Phyks
Phyks / gist:7609044
Last active December 29, 2015 03:39
void serialEvent() {
//serialEvent est appelée à la fin de la boucle si des données sont dispos sur le RX
while(Serial.available()) {
incoming_byte = (byte) Serial.read();
if(highByte(incoming_byte)) {
// Header
serial_i = incoming_byte & B00011111; // serial_i = compteur
// Note: serial_i = 0 => à traiter
local wibox = require("wibox")
local awful = require("awful")
brightness_widget = wibox.widget.textbox()
brightness_widget:set_align("right")
function round(num, idp)
return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end
@Phyks
Phyks / Un point
Last active August 29, 2015 13:57
Une mesure pour Citoyens Capteurs NO2
{
"type": "NO2",
"coordinates": [30, 10],
"spatial_validity": 10,
"measure": 150,
"timestamp": TIMESTAMP,
"time_validity": 3600,
}
def parsed2Bibtex(parsed):
"""
Convert a single bibtex entry dict to bibtex string
"""
data = parsed.get_entry_dict()
bibtex = ''
for entry in data.keys():
bibtex += '@'+data[entry]['type']+'{'+data[entry]['id']+",\n"
for field in [i for i in sorted(data[entry]) if i not in ['type', 'id']]:
def function_toute_prete(y):
return y
def operation(n):
"""
operation(n) is a function that adds n to its argument if n = 0 [2] or multiply n by its two arguments if n = 1 [2].
For instance, add(3) : x -> x * 3
"""
functions = [
#!/usr/bin/env python2
# -*- coding: utf8 -*-
# -----------------------------------------------------------------------------
# "THE NO-ALCOHOL BEER-WARE LICENSE" (Revision 42):
# Phyks (webmaster@phyks.me) wrote or updated these files for hackEns. As long
# as you retain this notice you can do whatever you want with this stuff
# (and you can also do whatever you want with this stuff without retaining it,
# but that's not cool...).
#
# If we meet some day, and you think this stuff is worth it, you can buy us a
def notifs_emprunts(self, serv):
"""Notifications when borrowing is over"""
now = datetime.datetime.now()
1h_later = now + datetime.timedelta(hours=1)
query = ("SELECT borrower, tool, until FROM borrowings " +
"WHERE until BETWEEN %s AND %s")
try:
self.bdd_cursor.execute(query, (now, 1h_later))
except mysql.connector.errors.Error:
serv.say(serv,
<?php
//$thumbdir = str_replace('/..', '', $thumbdir); // Prevent directory traversal attacks.
if(strstr($thumbdir, '..') !== FALSE) {
$requestedDir = '';
$thumbdir = rtrim('photos/','/');
}
?>
@Phyks
Phyks / Diaspora init script
Created August 6, 2014 18:32
Diaspora init script. Stop() is not fully working…
#!/bin/sh
### BEGIN INIT INFO
# Provides: diaspora
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts diaspora
# Description: starts diaspora using start-stop-daemon
### END INIT INFO
@Phyks
Phyks / FreederAPI
Last active August 29, 2015 14:12
FreederAPI
## Open questions
* Right endpoint to tag an entry ? a feed ? (in /feed, resp /entry, or in /tag)
* Right endpoint to share an entry ? (in /entry or in /share)
## Feeds endpoint
* GET /feeds
* Get a list of all the available feeds.