Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
# Je récupère l'adresse IP que ma filé Avahi
LOCAL_AVAHI_AUTO_IP="$( ip addr show | grep "tun0" | grep -o "inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" )"
# Idem, mais celle de raspberrypi-01
REMOTE_AVAHI_AUTO_IP="$( avahi-resolve -4 -n raspberrypi-01.local | cut -d" " -f2 )"
DEFAULT_GATEWAY="92.92.92.254"
@radium226
radium226 / ApplicationController.java
Created March 13, 2018 16:56
Server Side Event in HTML with Spring Boot and Thymeleaf Fragment
package radium226;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@radium226
radium226 / free.scala
Created January 21, 2018 20:11
Free Monad in Scala with Cats
object ImageApp extends App {
import cats._
import cats.free._
import cats.data._
case class Image(bytes: Array[Byte])
sealed trait ImageOp[A] // Image Algebra
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl._
import akka.stream.stage.{ GraphStageLogic, GraphStageWithMaterializedValue, OutHandler}
import scala.concurrent._
import scala.concurrent.duration._
object IntSource {
@radium226
radium226 / emulator-with-fake-webcam.sh
Created April 26, 2017 12:27
Run an Android emulator with a fake webcam
#!/bin/bash
export REAL_DEVICE="/dev/video0"
export FAKE_DEVICE="/dev/video1"
export DURATION="5"
export SIZE="320x240"
export AVD="Nexus_5X_API_25"
@radium226
radium226 / notify-hq.sh
Created April 5, 2017 16:32
5 services que m'a rendu systemd
#!/bin/bash
export RED_COLOR="\033[0;31m"
export DEFAULT_COLOR="\033[0m"
declare message=" ${RED_COLOR}/!\ ${DEFAULT_COLOR}${1}${RED_COLOR} /!\ ${DEFAULT_COLOR}"
declare index=
ls -1 "/dev/pts" | grep -E '[0-9]+' | while read index; do
echo -e "${message}" >>"/dev/pts/${index}"
done
#!/usr/bin/env python3
from rx import Observable, Observer, AnonymousObservable
from time import sleep
from rx.concurrency import NewThreadScheduler
from concurrent.futures import ThreadPoolExecutor
from rx.internal import extensionmethod
@extensionmethod(Observable)
#!/usr/bin/env python3
import time
import random
import queue
import threading
from concurrent import futures
SHORT_DURATION_RANGE = (1, 2)
LONG_DURATION_RANGE = (2, 4)
#!/bin/env python
class Option(object):
def __init__(self, key, name, expects_value):
self.key = key
self.name = name
self.expects_value = expects_value
def format_value(self, value):
package com.github.radium226.gists;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.ClosureSerializer;
import java.io.*;
import java.lang.invoke.SerializedLambda;
import java.util.concurrent.Callable;
import org.objenesis.strategy.StdInstantiatorStrategy;