Skip to content

Instantly share code, notes, and snippets.

View AlexisTM's full-sized avatar
🤠

Alexis Paques AlexisTM

🤠
View GitHub Profile
@AlexisTM
AlexisTM / itohex.c
Last active September 5, 2018 06:55
The clever integer to ASCII hexadecimal conversion !
#include <stdio.h>
char *itohex(int n) {
int i = 2*sizeof (int);
char *str = malloc(i + 1);
str[i] = '\0';
for ( ; i > 0; n >>= 4)
str[--i] = "0123456789ABCDEF"[n&0xF];
return str;
@AlexisTM
AlexisTM / PCA9633.ros.py
Last active May 29, 2018 14:08
ROS version of the PCA9633 LED controller library for Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
PCA9633.py
Author : Alexis PAQUES (@AlexisTM)
"""
import rospy
import wiringpi2 as wpi
import time
@AlexisTM
AlexisTM / PCA9633.py
Created May 29, 2018 14:05
PCA9633 LED Python library
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
PCA9633.py
Author : Alexis PAQUES (@AlexisTM)
"""
import wiringpi2 as wpi
import time
@AlexisTM
AlexisTM / install.wiringpi.xu4.sh
Last active October 3, 2019 06:19
WiringPi for Odroid XU4
sudo apt update
sudo apt install python-dev python-setuptools swig3.0
git clone --recursive https://github.com/hardkernel/WiringPi2-Python.git
cd WiringPi2-Python
swig3.0 -python -threads wiringpi.i
sudo python setup.py build install
### PYTHON 3
@AlexisTM
AlexisTM / rootless.gpio.odroid.sh
Last active May 29, 2018 14:15
Rootless GPIO/I2C access for odroid XU4 C1 and C2
# See https://wiki.odroid.com/troubleshooting/gpiomem
sudo apt-get install i2c-tools python-smbus
sudo addgroup gpio
sudo usermod -a -G gpio odroid
# meson-gpiomem is for C1/C2
# exynos-gpiomem is for XU4
echo """SUBSYSTEM==\"exynos-gpiomem\", GROUP=\"gpio\", MODE=\"0660\"
SUBSYSTEM==\"meson-gpiomem\", GROUP=\"gpio\", MODE=\"0660\"
<?php
include 'json.php';
function cache_get($key) {
@include "/tmp/$key";
return isset($val) ? $val : false;
}
$response = new \Simple\json();
@AlexisTM
AlexisTM / cache_set.php
Last active January 31, 2018 15:57
cache_set.php for Medium post
<?php
include "json.php";
use \Simple\json;
function cache_set($key, $val) {
 $val = var_export($val, true);
 $val = str_replace("stdClass::__set_state", "(object)", $val);
 $tmp = "/tmp/$key." . uniqid("", true) . ".tmp";
 file_put_contents($tmp, "<?php $val = " . $val . ";", LOCK_EX);
 rename($tmp, "/tmp/$key");