Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexis Metaireau almet

View GitHub Profile
@almet
almet / nginxconfig.ini
Last active Jun 24, 2020
Nginx reverse proxy to add CORS support to an API. Tested and working with Firefox 68.9 and Chrome 80.0
View nginxconfig.ini
server {
server_name xxx
location / {
# Activer le proxy
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://yourapi;
proxy_redirect off;
@almet
almet / snippet.js
Created Jun 17, 2020
Export google timeline info as text.
View snippet.js
javascript:(function(){
var distance = document.getElementsByClassName('top-activity-text')[0].innerText;
var date = document.getElementsByClassName('timeline-subtitle')[0].innerText;
var locations = Array.from(document.getElementsByClassName('place-visit-title')).map(e => e.innerText);
var markup = `
<div id="output">
<h1>Livraisons du ${date}</h1>
<input type="text" />
<p>${distance}</p>
<p><em>Lieux : ${ locations.join(', ')}</em>
@almet
almet / __init__.py
Last active Mar 10, 2020
roll split views
View __init__.py
from roll.extensions import simple_server
from .core import app
from . import view1, view2 # So that routes are scanned
simple_server(app, port=7777)
@almet
almet / gunicorn.conf.py
Created Aug 3, 2011
Or how to deploy a django application using nginx + gunicorn + supervisord
View gunicorn.conf.py
backlog = 2048
daemon = False
debug = True
workers = 3
logfile = "/usr/local/www/lolnet.org/reader/reader.gunicorn.log"
loglevel = "info"
bind = "unix:/usr/local/www/lolnet.org/reader/reader.gunicorn.sock"
@almet
almet / install.rst
Last active Jun 11, 2019
Glowing Bear + Weechat relay
View install.rst

Here's how to have a similar setup to irccloud, using any ssh-enabled host (this works with people.mozilla.com)

Running weechat on the server side

$ tmux
$ weechat
@almet
almet / ihatemoney-stats.py
Last active Jan 13, 2019
ihatemoney stats
View ihatemoney-stats.py
# IHATEMONEY_SETTINGS_FILE_PATH=/home/ihatemoney/ihatemoney.org/ihatemoney.cfg ./ihatemoney.org/venv/bin/ihatemoney shell
>>> # To know the number of projects with more than 10 bills and less than 3 months old.
>>> from ihatemoney.models import *; import datetime
>>> projects = [pr for pr in Project.query.all() if pr.get_bills().count() > 10 and pr.get_bills()[0].date > datetime.date.today() - datetime.timedelta(days=90)]
>>> len(projects)
>>> # To get the email of the contacts
>>> ", ".join(set([pr.contact_email for pr in projects]))
View Gestion de stock.md

Gestion de stock brasserie

A la brasserie, on gère pas mal de demande en fûts. Une commande ressemble à:

  • date
  • nombre de fûts pour chaque bière
  • mise à disposition de tireuse ? oui/non

Par exemple:

@almet
almet / instructions.md
Created Oct 23, 2017
Ardour setup on linux
View instructions.md

Ardour setup on linux

  1. Install ardour
  2. adduser alexis audio
  3. log-out and log-in again (no need to reboot)
  4. Dans une console, lancer la detection du micro avec la commande alsa_in -dhw:H2n

Il est possible d'éviter cette étape manuelle en faisant comme suit:

Vous pouvez utiliser la fonctionnalité de lancement de script de QjackCtl : dans qjackctl -> réglage -> options -> activer "Exécuter un script au démarrage" et y mettre votre ligne. Il ne vous reste qu'à redémarrer qJackCtl, et le tour est joué.

View kinto2csv.py
# -*- coding: utf-8 -*-
import unicodecsv as csv
import sys
import json
def json_to_csv(source, destination):
loaded_json = json.load(source)['data']
writer = csv.writer(destination)
# First row contains the titles
View foo.diff
diff --git a/formbuilder/components/AdminView.js b/formbuilder/components/AdminView.js
index 8de0b88..c81795e 100644
--- a/formbuilder/components/AdminView.js
+++ b/formbuilder/components/AdminView.js
@@ -25,19 +25,19 @@ export default class AdminView extends Component {
content = (
<div>
<h3>Results for {title}</h3>
- <DropdownButton title="Download as..." id="bg-nested-dropdown" className="pull-right">
- <MenuItem>
You can’t perform that action at this time.