Commit 7473526c authored by Daniel Stan's avatar Daniel Stan

Merge branch 'master' of gitlab.crans.org:dstan/scripts-perso

Conflicts:
	.config/apt-dater/hosts.conf
parents 8655170b 1e0ebefa
......@@ -8,6 +8,6 @@
[push]
default = simple
[merge]
ff = false
ff = true
[pull]
ff = true
......@@ -3,10 +3,39 @@ LOGFILE=$HOME/procmail.log
#DEFAULT=$MAILDIR/.INBOX/
DEFAULT=$MAILDIR/
# Généralités
# Généralités
INBOX=${DEFAULT}.INBOX
LISTDIR=$MAILDIR/MLs
# SA
:0fw: spamassassin.lock
* < 256000
| /usr/bin/spamassassin
# Mails with a score of 15 or higher are almost certainly spam (with 0.05%
# false positives according to rules/STATISTICS.txt). Let's put them in a
# different mbox. (This one is optional.)
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
$INBOX.almost-certainly-spam/
# All mail tagged as spam (eg. with a score higher than the set threshold)
# is moved to "probably-spam".
:0:
* ^X-Spam-Status: Yes
$INBOX.probably-spam/
# Work around procmail bug: any output on stderr will cause the "F" in "From"
# to be dropped. This will re-add it.
:0
* ^^rom[ ]
{
LOG="*** Dropped F off From_ header! Fixing up. "
:0 fhw
| sed -e '1s/^/F/'
}
# Pas vraiment une ML
:0
* ^X-Phabricator-Sent-This-Message: Yes
......
autocmd FileType latex,tex,md,markdown setlocal spell
set spelllang=en
syntax on
set nu
set autoindent
......
......@@ -8,4 +8,4 @@
#Hosts=apt-dater@localhost;
[Tudor]
Hosts=apt-dater@localhost;apt-dater@gigapudding.crans.org;apt-dater@localhost:2222;apt-dater@gladys.home;apt-dater@cupcake.tudo.re
Hosts=apt-dater@localhost;apt-dater@gigapudding.crans.org;apt-dater@localhost:2222;apt-dater@home.b2moo.fr;apt-dater@cupcake.tudo.re
......@@ -4,3 +4,6 @@
[submodule "arduino/libraries/IRLib"]
path = arduino/libraries/IRLib
url = https://github.com/cyborg5/IRLib.git
[submodule "arduino/Adafruit_NeoPixel"]
path = arduino/libraries/Adafruit_NeoPixel
url = https://github.com/adafruit/Adafruit_NeoPixel.git
Host kugel.tudo.re
ForwardAgent yes
# kugel n'a pas d'ipv4 publique dans ses records, on tente une connexion
# quand-même en ipv6 directe, avec un fallback d'un tunnel par un
# serveur qui possède de l'ipv6.
ProxyCommand bash -c 'nc %h %p || ssh -4 dstan@pimeys.fr -i ~/.ssh/gladys_open -W %h:%p'
Host *.tudo.re
ForwardAgent yes
#ProxyCommand bash -c 'nc -6 %h %p || ssh -4 dstan@home.b2moo.fr -i ~/.ssh/gladys_open -W %h:%p'
ProxyCommand bash -c 'nc -6 %h %p 2> /dev/null || ssh -4 dstan@pimeys.fr -i ~/.ssh/gladys_open -W %h:%p'
Host gigapudding.crans.org gigapudding
HostName gigapudding.crans.org
......
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
#define TOTAL 60
#define LED(X) (71-X)%TOTAL
#define REFRESH 10
#define PIEZO_PIN A0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(TOTAL, PIN, NEO_GRBW + NEO_KHZ800);
const uint32_t c_ms = strip.Color(0, 0, 0, 120);
const uint32_t c_second = strip.Color(0, 10, 0, 0);
const uint32_t c_minute = strip.Color(0, 0, 127, 0);
const uint32_t c_hour = strip.Color(127, 0, 0, 0);
const uint32_t c_quad = strip.Color(0,0,120,0);
const uint32_t c_night = strip.Color(60,0,60,0);
void setup() {
Serial.begin(9600);
Serial.println("Hello");
pinMode(PIEZO_PIN, INPUT);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
int hours = 0;
int minutes = 0;
int seconds = 0;
int ms = 0;
int last = 0;
void loop() {
uint32_t col;
unsigned long start = millis();
unsigned long delta;
if( Serial.available()){
Serial.println("Reading hour...");
hours = Serial.parseInt();
minutes = Serial.parseInt();
seconds = Serial.parseInt();
Serial.println("Hour set to");
Serial.print(hours); Serial.print(":");
Serial.print(minutes); Serial.print(":");
Serial.print(seconds); Serial.println(".");
}
for( int i = 0; i < 60; ++i) {
col = 0;
if( i < seconds)
col = c_second;
if( i%5 == 0) {
if( hours >= 12)
col = c_night;
else
col = c_quad;
}
if( i <= 5*(hours%12) + minutes/12)
col |= c_hour;
/*if( i < minutes)
col |= c_minute;*/
if( i*100 >= ms*6 && (i-1)*100 < ms*6)
col = c_ms;
if( (60-i)*100 <= ms*6 && (61-i)*100 > ms*6)
col = c_ms;
strip.setPixelColor(LED(i), col);
}
strip.show();
if(last != seconds) {
last = seconds;
Serial.println(analogRead(PIEZO_PIN));
}
//update
ms += REFRESH;
seconds += ms/1000;
ms %= 1000;
if(seconds >= 60) {
seconds = 0;
minutes++;
if(minutes > 60){
minutes = 0;
hours = (hours+1)%24;
}
}
delta = millis() - start;
if(delta > REFRESH) {
Serial.print("We're late by ");
Serial.println(((long) delta)-REFRESH);
}
else {
delay(REFRESH-delta);
}
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(LED(i), c);
strip.show();
delay(wait);
}
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(LED(i), Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(LED(i), Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(LED(i+q), c); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(LED(i+q), 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(LED(i+q), Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(LED(i+q), 0); //turn every third pixel off
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
Subproject commit 9cd8de7c92cf1a017d5660fa16ae7383931eeefe
......@@ -33,19 +33,30 @@ void setup()
digitalWrite(RF_M_DRV2, LOW);
}
void move(bool going_up, int target=0, int timeout=0) {
void move(bool going_up, int target=0, int timeout=8000) {
int comp;
int val;
if(target) {
unsigned long deadline;
deadline = millis() + timeout;
if(target)
{
target = min(max(target, POS_LOW), POS_HIGH);
going_up = get_position() < target;
}
else
{
target = going_up?POS_HIGH:POS_LOW;
}
Serial.print("Move:");
Serial.print(going_up?"Up":"Down");
Serial.print(",Target:");
Serial.print(target);
Serial.print(",Timeout:");
Serial.println(timeout);
if(going_up) {
comp=1;
digitalWrite(RF_M_DRV1, HIGH);
......@@ -56,23 +67,17 @@ void move(bool going_up, int target=0, int timeout=0) {
digitalWrite(RF_M_DRV2, HIGH);
}
digitalWrite(RF_M_CONT, HIGH);
if(target) {
do {
delay(1);
val = get_position();
}
while(val *comp < target*comp);
Serial.print("Endmove:");
Serial.print(val);
Serial.print(",");
Serial.print(comp);
Serial.print(",");
Serial.println(target);
report_pos();
do {
delay(1);
val = get_position();
}
if(timeout)
delay(timeout);
while(val *comp < target*comp && millis() < deadline);
// End of move
Serial.print("Done:");
report_pos();
digitalWrite(RF_M_CONT, LOW);
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, LOW);
......
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIEZO_PIN A0
void setup() {
Serial.begin(9600);
pinMode(PIEZO_PIN, INPUT);
}
int count = 0;
void loop() {
int val = 0;
val = analogRead(PIEZO_PIN);
if( val > 30) {
Serial.print("Triggered: ");
Serial.println(val);
delay(1000);
}
delay(10);
if( count ++ > 100) {
Serial.println("alive");
count = 0;
}
}
#!/bin/sh
DIR=$HOME/mail/.INBOX.GPG/cur
DIR=$HOME/sshfs/cupcake/mail/.INBOX.GPG/cur
process() {
gpg -d $1 | sed '/-----BEGIN PGP PUBLIC KEY BLOCK-----/!d; : proc {n; /-----END PGP PUBLIC KEY BLOCK-----/!b proc}' | gpg --import
if echo "$1" | grep -vq ',S$'; then
......
#!/bin/bash
KEY=$HOME/.ssh/id_rsa_procmail
(/usr/bin/ssh cupcake.tudo.re -i $KEY /usr/bin/procmail) || (cat >> $HOME/Mail/rates)
......@@ -3,6 +3,7 @@
import bs4
import decimal
import re
def parse_decimal(txt):
"""Parse a decimal seen as an amount in €"""
......@@ -12,26 +13,59 @@ def parse_decimal(txt):
doc = bs4.BeautifulSoup(open('1.example', 'r').read())
# Replace expenses with payback, for second form
r = doc.find(attrs={'id': 'expenses_accordion'})
depenses = r.findAll(attrs={'class': 'panel panel-default'})
# On va parser une dépense donnée
def parse_depense(dep):
txt = dep.find(attrs={'class': 'panel-body'}).text.split('\n')[1].strip()
buyer, parts = parse_participants(txt)
return {
'title': dep.find(attrs={'class': 'col-xs-6'}).text,
'value': parse_decimal(dep.findAll(attrs={'class':'col-xs-3'})[0].text),
'id': int(dep.findAll('a')[-1].attrs['href'].split('=')[-1]),
'participants': dep.find(attrs={'class': 'panel-body'}).text.split('\n')[1],
'participants': parts,
'buyer': buyer,
}
def parse_participants(txt):
"""Take a participant list, and returns a dictionnary whose keys are
participants names and values are the integral number of shares they
take in the bill"""
raise NotImplementedError
fmatch = re.match('^Payé par ([^ ]*) ; participants :(.*)\.$', txt)
if fmatch is None:
print(txt)
raise ValueError
buyer = fmatch.group(1)
res = {}
for part in fmatch.group(2).split(','):
part = part.strip()
pmatch = re.match('^([^ ]*)(?: \(([0-9]+) parts\))?$', part)
res[pmatch.group(1)] = int(pmatch.group(2) or 1)
return (buyer, res)
#print(parse_depense(depenses[0]))
def parse_depenses(doc):
r = doc.find(attrs={'id': 'expenses_accordion'})
depenses = r.findAll(attrs={'class': 'panel panel-default'})
for depense in depenses:
yield parse_depense(depense)
def parse_paybacks(doc):
r = doc.find(attrs={'id': 'paybacks_accordion'})
paybacks = r.findAll(attrs={'class': 'panel panel-default'})
for payback in paybacks:
yield parse_payback(payback)
print(parse_participants('Payé par PEB ; participants : 20-100, b2moo (2 parts), Chopopope (2 parts), PEB.'))
def parse_payback(pb):
title = pb.find(attrs={'class': 'panel-body'}).text.strip().split('\n')[0]
entries = pb.findAll(attrs={'class':'col-xs-4'})
return {
'title': title,
'value': parse_decimal(entries[2].text),
'id': int(pb.find(attrs={'name': 'expense_id'}).attrs['value']),
'participants': {entries[1].text: 1},
'buyer': entries[0].text.strip(),
}
for p in parse_paybacks(doc):
print(p)
break
......@@ -12,6 +12,10 @@ case $(/bin/hostname) in
DOMAINS="$DOMAINS -d home.b2moo.fr"
;;
cupcake)
DOMAINS="$DOMAINS -d cupcake.tudo.re"
;;
kugel)
DOMAINS="$DOMAINS -d kugel.tudo.re"
;;
......
......@@ -41,9 +41,8 @@ server {
index index.html index.htm;
ssl on;
# todo: replace /tmp/ by /etc/letsencrypt/live
ssl_certificate /tmp/www.tudo.re/fullchain.pem;
ssl_certificate_key /tmp/www.tudo.re/privkey.pem;
ssl_certificate /etc/letsencrypt/live/www.tudo.re/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.tudo.re/privkey.pem;
location / {
# First attempt to serve request as file, then
......
......@@ -15,7 +15,7 @@ server {
client_max_body_size 10G;
fastcgi_buffers 64 4K;
root /var/www/owncloud/;
root /var/www/nextcloud/;
# Disable gzip to avoid the removal of the ETag header
gzip off;
......
......@@ -16,5 +16,15 @@ server {
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment