Skip to content

Instantly share code, notes, and snippets.

View aeris's full-sized avatar

aeris aeris

View GitHub Profile
@aeris
aeris / migrate.rb
Created October 14, 2018 15:42
Migrate PrivateBin from filesystem to PostgreSQL
#!/usr/bin/env ruby
require 'awesome_print'
require 'pg'
require 'json'
con = PG.connect host: 'localhost', user: 'postgres', password: 'postgres', dbname: 'privatebin'
files = Dir['**/*.php'].sort
con.exec 'TRUNCATE TABLE paste'
[42] pry(main)> f = Hash.new { [] }
=> {}
[43] pry(main)> f[:foo] << :bar
=> [:bar]
[44] pry(main)> f
=> {}
[45] pry(main)> f.keys
=> []
[46] pry(main)> f[:bar]
=> []
@aeris
aeris / .env
Created April 16, 2018 07:41
cozy-docker-https
COMPOSE_PROJECT_NAME=cozy-https
@aeris
aeris / gpgit.py
Last active April 11, 2018 12:11
Automatically GPG encrypt all possible incoming email.Don't encrypt plain-text or clear-sign GPG sign to avoid breaking the sign
#!/usr/bin/env python
# GPGIt : Automatically GPG-encrypt incoming email
# Aeris <aeris@imirhil.fr>
# Licensed under AGPLv3 or later
import email
import sys, os
import re
from pyme.core import Data, Context
from email.mime.base import MIMEBase
@aeris
aeris / dice.ino
Last active February 18, 2018 20:41
Arduino dice (based on HelioxLab work : https://www.youtube.com/watch?v=S-oBujsoe-Q)
// Pour les LED
#define LED_PIN_1 2
#define LED_PIN_2 3
#define LED_PIN_3 4
#define LED_PIN_4 5
// Pour le capteur d’inclinaison
#define BUTTON_PIN 6
#define BUTTON_ACTIVE_LEVEL LOW
@aeris
aeris / kitten.ino
Last active February 17, 2018 00:17
Kitten laser tower
// License: AGPLv3
#include <Servo.h>
#define MIN_DURATION 200
#define MAX_DURATION 500
#define MIN_FREEZE 100
#define MAX_FREEZE 200
#define LASER_PIN 9
class PanTilt {
@aeris
aeris / gpgit-rspamc-learn
Last active November 4, 2017 11:08
rspamc spam learn with gpgit encrypted email
#!/usr/bin/env ruby
# License AGPLv3 (https://www.gnu.org/licenses/agpl-3.0.txt)
IMAPS_SERVER = 'xxx'
IMAPS_USER = 'xxx'
RSPAMC_HOST = 'xxx'
AKONADI_ACCOUNT = 'xxx'
KWALLET_APP = 'gpgit-rspamc-learn'
require 'awesome_print'
require 'net/imap'
@aeris
aeris / export-photo.rb
Created November 2, 2017 21:04
Export photo Cozy v2
#!/usr/bin/env ruby
require 'typhoeus'
require 'oj'
require 'base64'
require 'fileutils'
def get(url, params = {})
res = Typhoeus.get url, params: params, headers: {'Accept' => 'application/json'}
Oj.load(res.body)
end
@aeris
aeris / uncommitted
Created October 11, 2017 16:54
Detect uncommitted git changes
#!/usr/bin/env ruby
require 'find'
require 'open3'
require 'optparse'
require 'ostruct'
options = OpenStruct.new
OptionParser.new do |opts|
opts.on('-u', '--[no-]untrack', 'Include untracked files') { |v| options.untrack = v }
end.parse!
@aeris
aeris / concat
Created July 3, 2017 21:59
Montage vidéo pour PSES & Ubuntu Party
#!/usr/bin/env ruby
require 'tempfile'
require 'open3'
class Args
def initialize
@args = []
end
def <<(args)