Skip to content

Instantly share code, notes, and snippets.

View rm3l's full-sized avatar
💭
I may be slow to respond.

Armel Soro rm3l

💭
I may be slow to respond.
View GitHub Profile
@ctoestreich
ctoestreich / gist:1337772
Created November 3, 2011 21:02
Custom Number Encoder Memory Storage Size Test
def r = new Random()
def num = r.nextInt(12000000).toString()
println num
println num.bytes.length
println encodeNumber(num, getEncoder())
println encodeNumber(num, getEncoder()).bytes.length
def getEncoder(){
['1','2','3','4','5','6','7','8','9','0','-','=','!','@','#','$','%','^','&','*','(',')','_',
'+','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
@StefanScherer
StefanScherer / swarm-rpi.sh
Last active November 15, 2015 23:14
Raspberry Pi Swarm with overlay network
# Create a RPi with consul running on it
docker-machine-hypriot create -d hypriot --hypriot-ip-address=192.168.1.3 swl-consul
docker $(docker-machine config swl-consul) run -d --restart=always -p 8500:8500 -h consul nimblestratus/rpi-consul -server -bootstrap
# Create a RPi swarm with consul discovery
docker-machine-hypriot create -d hypriot --hypriot-ip-address=192.168.1.4 --swarm --swarm-master --swarm-discovery="consul://$(docker-machine ip swl-consul):8500" --engine-opt="cluster-store=consul://$(docker-machine ip swl-consul):8500" --engine-opt="cluster-advertise=eth0:0" swl-demo0
docker-machine-hypriot create -d hypriot --hypriot-ip-address=192.168.1.5 --swarm --swarm-discovery="consul://$(docker-machine ip swl-consul):8500" --engine-opt="cluster-store=consul://$(docker-machine ip swl-consul):8500" --engine-opt="cluster-advertise=eth0:0" --engine-label "storage=ssd" swl-demo1
# Connect to the RPi swarm
eval $(docker-machine env --swarm swl-demo0)
@kasperhartwich
kasperhartwich / speedtest.php
Last active October 24, 2017 21:49
Test by ookla speedtest servers. Needs a cleanup. ;D
#!/usr/bin/php5
<?php
/*
* Speedtest.net linux terminal client.
* This is free and open source software by Alex based on a script from Janhouse
* Script uses curl, executes ifconfig commands in shell and writes temporary files in temp_down folder. Make sure you have everything set up before using it.
*/
header("content-type: text/plain");
/* * * Configuration * * */
$iface="eth0";
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#ifdef NDEBUG
#define debug(M, ...)
#else
@pditommaso
pditommaso / sync.groovy
Created August 2, 2017 23:18
Prevent multiple JVM to access concurrently the same file
import java.nio.channels.FileLock
final file = new RandomAccessFile(new File("foo.lock"), "rw")
println "<Entering in critical section>"
try {
/*
* wait to acquire a lock
*/
def secs = 0
FileLock lock
@zsmb13
zsmb13 / publish-mavencentral.gradle
Last active April 21, 2021 07:25
Basic MavenCentral script
apply plugin: 'maven-publish'
apply plugin: 'signing'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
@rm3l
rm3l / mid_circle_radial_gauge.dart
Last active June 17, 2021 14:32
Sample code for creating a mid-circle radial gauge widget with Flutter. See https://rm3l.org/creating-a-mid-circle-radial-gauge-in-flutter/ for more details.
import 'dart:math';
import 'package:flutter/material.dart';
class MyCustomRadialGauge extends StatefulWidget {
@override
_MyCustomRadialGaugeState createState() => _MyCustomRadialGaugeState();
}
class _MyCustomRadialGaugeState extends State<MyCustomRadialGauge>

How to use this code

  1. Add the build_pull_request.sh to the root of your git repository;
  2. Add the android.yml file to .github/workflows/;
  3. Make build_pull_request.sh executable using: chmod +x build_pull_request.sh;
  4. Commit your code and push the changes

LICENSE

# MIT License
@ctoestreich
ctoestreich / gist:1337648
Created November 3, 2011 20:08
Testing storage of millions of keys in Redis using Custom Number Encoder
@Grapes([
@Grab('redis.clients:jedis:1.5.1'),
@GrabConfig(systemClassLoader=true)
])
import redis.clients.jedis.*
performTest("unencoded", null) {n, e->
n.toString()
}
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(