Skip to content

Instantly share code, notes, and snippets.

View madeindjs's full-sized avatar
💩

Alexandre Rousseau madeindjs

💩
View GitHub Profile
@madeindjs
madeindjs / json.swift
Created April 12, 2019 14:20
Fetch & Parse JSOn from raspberry-cook.fr
import Foundation
let decoder = JSONDecoder()
let uri : String = "http://raspberry-cook.fr/recipes/buddha-bowl-au-thon-cuit.json"
let feedUrl = URL(string: uri)!
struct Recipe : Codable {
var id : Int
var name : String
@madeindjs
madeindjs / wifi_scanner.rb
Last active March 28, 2019 14:27
Scan a Wifi and log each new device connected on it
require 'hooray'
require 'logger'
LOG_FILE = './wifi.log'.freeze
INTERVAL_TIME = 30
DEFAULT_NODE_NAME = 'UNKNOW'.freeze
class Scanner
attr_reader :logger
@madeindjs
madeindjs / oop.rb
Last active January 8, 2019 09:53
A simple of OOP in ruby
# A class who provide access to database
class Record
attr_accessor :title
# Create and return the record
def self.create(title)
record = Record.new
record.title = title
record.save
record
end
@madeindjs
madeindjs / template_benchmark.rb
Created November 10, 2018 19:53
Benchmarking of existing templating libs
require 'erb'
require 'haml'
require 'slim'
require 'benchmark'
class Context
attr_reader :title, :content
def initialize(title, content)
@title = title
#!/bin/bash
green='\e[0;32m'
darkred='\e[1;31m'
lightblue='\e[1;34m'
defaut='\033[0m'
today=$(date +%Y-%m-%d)
foldername_save="pi3"
folder_save="${HOME}/backup/${foldername_save}"
sqldump_filename="_dump_${today}.sql"
@madeindjs
madeindjs / prepare-commit-msg.sh
Last active November 8, 2017 10:20 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@madeindjs
madeindjs / redmine_colors_ticket.js
Last active February 22, 2018 16:19
Color tickets assigned to me
// ==UserScript==
// @name Color Redmine Flow
// @version 1
// @grant none
// ==/UserScript==
var nameToSearch = /Rousseau/;
var unavailableColor = "GhostWhite";
var activeColor = "Gold";
var testColor = "Khaki";
@madeindjs
madeindjs / pre-commit
Last active March 16, 2020 10:47
Git hook to store in .git/hooks/ folder to check commit
#!/bin/bash
# .git/hooks/pre-commit
GREEN='\033[0;32m'
RED='\033[0;31m'
DEFAULT='\033[0m'
# loop on all commited PHP files
echo -e "\n${GREEN}Check PHP files${DEFAULT}\n"
@madeindjs
madeindjs / git_check_php.sh
Created August 9, 2017 13:56
Check git staged PHP files errors
#!/bin/bash
files=`git diff --name-only | grep -E '.php$' `
for file in $files; do
php -l $file > /dev/null
done

Configurer le fichier ssh

$ cat ~/.ssh/config 
Host pi
  Hostname 5.50.77.180
  Port 2812
  User pi
  IdentityFile ~/.ssh/raspberry.id_rsa