Skip to content

Instantly share code, notes, and snippets.

Avatar
Electrifying my brain

Patrice Ferlet metal3d

Electrifying my brain
View GitHub Profile
View gist:835543
<canvas>
<simplelayout />
<rtmpconnection objectencoding="3" name="mainconnect" src="rtmp://127.0.0.1/live" autoconnect="true" >
<method name="hello">
Debug.write("server said hello...")
</method>
</rtmpconnection>
<rtmpstatus />
<text>Orange light: warning and mybe error on server, Green OK, Red: Error</text>
<button>Test
View example for avahi and wol
#!/bin/sh
#
#Script de Démarrage des Ordinateurs sur l'interface réseau eth1
#
MACADDR=00:50:BA:CB:CD:B8
/usr/bin/wol -i 192.168.1.255 $MACADDR
#Maintenant on tourne en boucle et on attend que le pc annonce qu'il existe
notalive=1
@metal3d
metal3d / nat-traversal.js
Created Aug 9, 2011
NAT Traversal with node (0.5.x)
View nat-traversal.js
/*
NAT traversal system to let 2 computers behind firewall to communicate.
Example:
Client A (your machine) has public ip 1.1.1.1
Client B (distant machine) has public ip 2.2.2.2
You want to bind port 5556 on your machine
Distant Client want to bind port 5557
@metal3d
metal3d / exemple1
Last active Dec 10, 2015
Exemples PlantUML
View exemple1
@startuml
A -> B: le label de mon appel
B -> A: autre label...
@enduml
@metal3d
metal3d / bayesian.py
Last active Dec 11, 2015
Bayesian class that train datas and compute bayesian calculation.
View bayesian.py
# -*- encoding: utf-8 -*-
""" Simple Bayesian calculation
After training datas by categories, you can use Bayes.bayes method to compute
bayesian calculation to find probality for a content
matches some categories
Example:
>>> b = Bayes()
@metal3d
metal3d / threadpool.py
Last active Dec 15, 2017
ThreadPool is an asynchrone Pool thread that doesn't block when adding a thread to Queue.
View threadpool.py
# -*- encoding: utf-8 -*-
""" threadpool module, export ThreadPool class that is a non blocking
Thread Queue. Most important is that ThreadPool.add_task runs
asychroniousally. This method doesn't block process.
Example:
p = ThreadPool(2)
p.add_task(f1, arg1, arg2, test=False)
p.add_task(f1, arg2, arg3, test=False)
p.add_task(f1, arg4, arg5, test=True)
@metal3d
metal3d / github-dl-count.py
Last active Aug 29, 2015
A simple script that gives me number of download for github project release
View github-dl-count.py
import requests
import json
import sys
# use argv... example:
# python github-dl-count MyUserName MyRepoName
user = sys.argv[1]
repo = sys.argv[2]
url="https://api.github.com/repos/%s/%s/releases" % (user, repo)
@metal3d
metal3d / gh_latest.go
Last active Aug 29, 2015
Go client to github to get latest release and assets for a given repository
View gh_latest.go
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
View PythonDIArticle.md

Python et l'injection de dépendance

Ah, ça... quand on parle d'injection et de dépendance, on s'attend tout de suite à se prendre une flopée de visiteurs en manque de substance plus ou moins illicites. En réalité, on va parler "pattern". Et surtout, je vais lancer un vieux pavé dans la marre en disant qu'en Python c'est pas super utile, ou du moins que le langage permet déjà de le gérer sans se faire mal.

Piqure de rappel

Conversation un matin au travail:

@metal3d
metal3d / deploy_coreos_libvirt.sh.patch
Created Feb 1, 2016
Patch to change SELinux context of CoreOS libvirt deployment script
View deploy_coreos_libvirt.sh.patch
diff -up ./deploy_coreos_libvirt.sh.friend ./deploy_coreos_libvirt.sh
diff -up ./deploy_coreos_libvirt.sh.friend ./deploy_coreos_libvirt.sh
--- ./deploy_coreos_libvirt.sh.friend 2016-01-25 14:18:15.431503583 +0100
+++ ./deploy_coreos_libvirt.sh 2016-01-25 14:24:35.942741966 +0100
@@ -51,6 +51,12 @@ for SEQ in $(seq 1 $1); do
sed "s#%HOSTNAME%#$COREOS_HOSTNAME#g;s#%DISCOVERY%#$ETCD_DISCOVERY#g" $USER_DATA_TEMPLATE > $LIBVIRT_PATH/$COREOS_HOSTNAME/openstack/latest/user_data
+
+ if [[ selinuxenabled ]] ;then
You can’t perform that action at this time.