Skip to content

Instantly share code, notes, and snippets.

@raed667
raed667 / Hanoï.go
Created October 11, 2014 22:02
Simple recursive try to solve Hanoï in go. The output displays the steps and the total number of iterations
package main
import "fmt"
func main() {
fmt.Print("Number of iterations: " , move((uint64)(3), "1", "2", "3", (uint64)(0)))
}
func move(n uint64, a, b, c string,x uint64) uint64 {
if n > 0 {
@raed667
raed667 / fibonacci.go
Created October 11, 2014 22:18
This is a test in Go for Fibonacci in an iterative way. The algorithm disolays the entire suite to provided 'n' and the time it took to compute
package main
import "fmt"
import (
"time"
"log"
)
func main() {
fibonacci(1000)
@raed667
raed667 / IRCbot.go
Created November 2, 2014 00:51
Simple IRC BOT written in Go
package main
import (
"fmt"
"github.com/thoj/go-ircevent"
"strings"
)
var roomName = "#botwartest2"
@raed667
raed667 / ArduinoJava.java
Last active August 29, 2015 14:11
Read from serial and print
package arduinojava;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.util.Enumeration;
import datetime
import sqlite3
import time
import dateutil.parser
import grovepi
'''
TODO: Finir Bguthness Management
getFromDB
import datetime
import os
import sqlite3
import warnings
import glob
import requests
warnings.filterwarnings("ignore", category=UnicodeWarning)
import datetime
import os
#crontab -e
#0 12 * * * /usr/bin/python /path/to/file.py > /path/to/log.txt
with open('/path/to/file.txt', 'a') as file:
file.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")+"\n")
print "run ssh"
#!/bin/bash
timestamp() {
date +"%T"
}
if (( RANDOM % 2 ))
then
cd /path/to/directory/
@raed667
raed667 / message_rate.js
Last active December 21, 2016 23:04
MQTT messages/second
const mqtt = require('mqtt');
const client = mqtt.connect('mqtt://iot.eclipse.org');
let start = null,
count = 0,
topicAverage = 0,
payloadAverage = 0;
const topics = [],
payloads = [];
@raed667
raed667 / insert_in_es.js
Created December 21, 2016 23:31
Simple (& dumb) insert in ES
const mqtt = require('mqtt');
const ES = require('esta');
const INDEX = 'mqtt',
TYPE = 'eclipse';
ES.CONNECT(INDEX, function(response) {
// When DB is on => connect to mqtt
const client = mqtt.connect('mqtt://iot.eclipse.org');