This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorial(number) { | |
let result = 0; | |
for(let i = number; i > 0; --i) { | |
result += Math.log10(i); | |
} | |
return result; | |
} | |
function scientific_factorial(number) { | |
let fact = factorial(number); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
""" | |
Minimal heartbeat for a Ground control station in ROS for PX4. | |
It enables STATUS_TEXT streams. | |
Author: AlexisTM | |
""" | |
from threading import Thread | |
import rospy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To be used to set a cookie | |
function setCookie(cname, cvalue, exdays) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (exdays * 86400000)); | |
var expires = "expires="+d.toUTCString(); | |
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; | |
} | |
// Login through an AJAX call | |
function login(username, password) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Express web app | |
const express = require('express'); | |
const app = express() | |
const md5 = require('md5'); | |
// Redis client | |
const redis = require("redis"); | |
const client = redis.createClient({ host: '192.168.178.23' }); | |
// Token generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
users/[username]:token-[token] = { | |
'location': 'Brussels', | |
'origin': 'weblogin', | |
'creation-ip': 'x.x.x.x', | |
'last-use-ip': 'x.x.x.x' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
""" This is a proper debounce function, the way a electrical engineer would think about it. | |
This wrapper never calls sleep. It has two counters: one for successful calls, and one for rejected calls. | |
If the wrapped function throws an exception, the counters and debounce timer are still correct """ | |
class Debounce(object): | |
def __init__(self, period): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
from __future__ import division | |
import os | |
import glob | |
import rospy | |
from pymavlink import mavutil | |
from threading import Thread | |
from mavros_msgs.msg import Mavlink, StatusText | |
from mavros import mavlink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Normal throttle for a normal function call | |
function throttle(func, delay) { | |
let timeout; | |
return function(...args) { | |
if (!timeout) { | |
timeout = setTimeout(() => { | |
func.call(this, ...args) | |
timeout = null | |
}, delay) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adhoc() { | |
if [ -z ${1+x} ]; | |
then echo -e "Run this using: \nadhoc on wlan0\nadhoc off"; | |
return 1 | |
else | |
ACTION=$1 | |
WIFI_INTERFACE=$2 | |
case $ACTION in |