Skip to content

Instantly share code, notes, and snippets.

View Pilooz's full-sized avatar

Pierre-Gilles Levallois Pilooz

  • Freelancer
  • France
View GitHub Profile
@Pilooz
Pilooz / model_generator.rb
Last active October 3, 2015 15:37
Sequel model generator for mysql
# Sequel Basic Scafolding Model Generator for MySQL
# Requires sequel-3.34.0 and above.
#
# This routine takes all the table of a database, en generates all Sequel models
# For each table model we put :
# - A header that reminds you the table structure
# - the plugin list you wrote in 'plugin_to_add' array
# - The Sequel referential inegrity : one_to_many, many_to_one
# - A "Validate" method that checks not nullable columnns and unique columns
# - Generates init.rb to be include in the project
@Pilooz
Pilooz / gist:2959750
Created June 20, 2012 12:51
A better git log view
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
in the global config :
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@Pilooz
Pilooz / gist:4275337
Created December 13, 2012 09:43
Rake Task for listing #TODO, #THINK and # FIXME in Ruby projects
desc "show a todolist from all the TODO tags in the source"
task :todo do
underyellow = "\e[4;33m%s\e[0m"
underred = "\e[4;31m%s\e[0m"
undergreen = "\e[4;32m%s\e[0m"
undercolor = ""
color = ""
Dir.glob('{ctrl,model,layout,view,spec}/**/*.{rb,xhtml}') do |file|
@Pilooz
Pilooz / gist:5900307
Created July 1, 2013 12:13
guess mime type from filename extension
# Internal: Lookup mime type for extension.
#
# Returns a MIME::Type
def _mime_type
if defined? @_mime_type
@_mime_type
else
guesses = ::MIME::Types.type_for(extname.to_s)
# Prefer text mime types over binary
@Pilooz
Pilooz / pr.md
Last active August 29, 2015 14:23 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Pilooz
Pilooz / mirror.conf
Created March 9, 2016 10:00 — forked from ctrlaltdylan/mirror.conf
The nginx server configuration file needed to host the MirrorMirror application
server {
listen 80;
server_name localhost;
root /home/pi/projects/MirrorMirror/public;
index index.html index.htm index.php;
charset utf-8;
location / {
@Pilooz
Pilooz / gist:69c71ac1a6c4b745ab7594ba145944f2
Created April 12, 2017 08:32
Launch Chromium on Raspberry in kiosk mode ...and some other cool options
chromium --disable-hang-monitor --kiosk --disable-java --disable-restore-session-state --disable-sync --disable-translate http://localhost
@Pilooz
Pilooz / gist:2160aa4a23838f1383440771a03b5fe8
Last active July 8, 2018 19:19
Clean up Raspberry Raspbian Strech after install
sudo apt-get purge wolfram-engine
sudo apt-get purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
@Pilooz
Pilooz / gist:beefa092499f42f3bddbc44da1819bf6
Created December 11, 2017 10:50
Install openCV3.3.0 on Pi 3 under Raspbian Stretch
Stretch OpenCV 3.3.0...
Following the basic build instructions from http://docs.opencv.org/2.4/doc/tutorial ... stall.html
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local ..
@Pilooz
Pilooz / Running a Python Script AFTER X GUI Starts up
Created December 16, 2017 09:00
Running a Python Script AFTER X GUI Starts up
-> Edit /etc/rc.local
-> put your code before "exit 0"
-> Ensure this file is executable : `sudo chmod +x /etc/rc.local`
exec 2> /tmp/rc.local.log # send stderr from rc.local to a log file
exec 1>&2 # send stdout to the same log file
/home/pi/projets/rfid-video-player/scripts/start.sh