Skip to content

Instantly share code, notes, and snippets.

View SkypLabs's full-sized avatar
💭
💻🎧☕📖

Skyper SkypLabs

💭
💻🎧☕📖
View GitHub Profile
@SkypLabs
SkypLabs / signal.c
Last active January 5, 2017 16:03
Example of how to manipulate UNIX signals in C
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#define SIGTERM 15
#define SIGKILL 9
#define SIGINT 2
void signal_handler(int signal)
{
@SkypLabs
SkypLabs / is_ipv4.sh
Last active January 6, 2017 01:12
Bash function for testing an IPv4 address
is_ipv4() {
local -r regex='^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'
[[ $1 =~ $regex ]]
return $?
}
@SkypLabs
SkypLabs / Keybase.md
Created February 3, 2017 14:28
Keybase Proof

Keybase proof

I hereby claim:

  • I am skyplabs on github.
  • I am skyplabs (https://keybase.io/skyplabs) on keybase.
  • I have a public key ASCWCei4GtX0zKqBRc8JkNBZ8K8gI8JFCmhl3mTtd-gHNwo

To claim this, I am signing this object:

@SkypLabs
SkypLabs / go2deb.sh
Created May 25, 2018 19:56
Script used to chroot into a Debian system from an Android system - See https://blog.skyplabs.net/2012/01/20/allier-android-en-gui-et-debian-en-cli-sur-la-asus-transformer-prime/ (French)
ROOT=/data/local/tmp/mydebian
BB=/system/xbin
if ! ls $ROOT/proc/1 > /dev/null
then
$BB/mount --bind /dev $ROOT/dev
$BB/mount --bind /proc $ROOT/proc
$BB/mount --bind /sys $ROOT/sys
$BB/mount --bind /dev/pts $ROOT/dev/pts
fi
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
#!/bin/bash
# Returns the decimal value of the payload contained in NEC infrared frames.
#
# Uses the ouput of the mode2 tool from the LIRC project as input.
if [ -z "$1" ]
then
echo "Usage: $0 <LIRC decode file>"
exit 0
@SkypLabs
SkypLabs / ATAVRSBIN1_i2c.ino
Last active May 25, 2018 20:01
Sample code used to retrieve measurements from the ATAVRSBIN1's gyroscope - See https://blog.skyplabs.net/2014/10/06/test-de-la-carte-de-developpement-a-capteurs-inertiels-atavrsbin1-datmel/ (French)
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
}
const float gyro_factor = 14.375;
@SkypLabs
SkypLabs / db.php
Last active May 25, 2018 20:02
Sample code to show how to handle database error messages in PHP according to the current user's status - See https://blog.skyplabs.net/2011/03/19/afficher-les-erreurs-sql-de-php-seulement-aux-personnes-concernees/ (French)
<?php
// Connection variables.
$db_type = "";
$db_host = "";
$db_user = "";
$db_password = "";
$db_database = "";
// We test the connection with the database.
try
@SkypLabs
SkypLabs / echo_color.sh
Last active September 20, 2018 09:59
Bash functions to display messages with color
# Green
function echo_ok {
echo -e "\033[32m[OK]\033[0m $@"
}
# Red (using strerr as output)
function echo_err {
echo -e "\033[31m[ERROR]\033[0m $@" 1>&2
}
@SkypLabs
SkypLabs / remove_exited_docker_containers.sh
Last active December 5, 2018 23:40
Scripts for removing untagged Docker images and exited Docker containers
#!/usr/bin/env bash
docker ps -a | grep 'Exit' | awk '{print $1}' | xargs docker rm
@SkypLabs
SkypLabs / Makefile
Created January 6, 2017 12:44
Sample code and its Makefile for Arduino Uno using the AVR library
MCU = atmega328p
TARGET_ARCH = -mmcu=$(MCU)
TARGET = main
CC = avr-gcc
CPPFLAGS = -mmcu=$(MCU)
CFLAGS = -Os -g -Wall -I. -DF_CPU=16000000
LDFLAGS = -g -mmcu=$(MCU) -lm -Wl,--gc-sections -Os
PGMER = -c arduino -b 115200 -P /dev/ttyACM0
PGMERISP = -c avrispv2 -P /dev/ttyACM0
DUDE = /usr/bin/avrdude -V -p $(MCU)