Skip to content

Instantly share code, notes, and snippets.

View elecnix's full-sized avatar

Nicolas Marchildon elecnix

View GitHub Profile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.sparkline.js"></script>
<script type="text/javascript">
$(function() {
for (row = 0; row < 80; row++) {
var myvalues = [];
for (i = 0; i < 500; i++) {
#include "SparkIntervalTimer/SparkIntervalTimer.h"
//SYSTEM_MODE (MANUAL);
volatile int i = 0; // Variable to use as a counter volatile as it is in an interrupt
volatile boolean zero_cross = 0; // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = D7; // Output to Opto Triac
int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff
int inc = 1; // counting up or down, 1=up, -1=down
#!/bin/sh
INDEX="index.html"
echo "<html>" > $INDEX
if [ -d thumbnails ] ; then
echo "Deleting existing thumbnails directory"
rm -rf thumbnails
fi
@elecnix
elecnix / dups
Created December 16, 2013 02:15
Find duplicate files
#!/bin/bash
# Find duplicate files
RECURSIVE="no"
TEMPFILE=`mktemp`
DIRECTORY=.
LAST_IS_OPTION="no"
This file has been truncated, but you can view the full file.
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
#!/usr/bin/env ruby
require 'csv'
poste = nil
district = nil
bureau = nil
candidats = []
puts "CREATE TABLE district (code varchar(1000), primary key (code));"
puts "CREATE TABLE poste (poste_no varchar(6), district varchar(1000) references district(code), primary key (poste_no));"
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<form>
<fieldset>
<legend>Legend</legend>
<label>Label name</label>
@elecnix
elecnix / co-contra-variance
Created November 7, 2013 21:44
Demonstrating compatibility between different generic types.
List<Sub> listOfSub = null;
List<Super> listOfSuper = null;
List<? extends Super> listOfExtendsSuper = null; // Co-variant list
List<? extends Sub> listOfExtendsSub = null; // Contra-variant list
List<? super Super> listOfSuperSuper = null;
List<? super Sub> listOfSuperSub = null;
listOfSub = listOfSuper;
listOfSub = listOfExtendsSuper;
listOfSub = listOfExtendsSub; // Why?
@elecnix
elecnix / collection-element-ajax.js
Created September 23, 2013 17:36
Generates an HTTP POST when one element of an array has one of its properties modified, using AngularJS and Restangular.
// controller
var UsersCtrl = [ '$scope', '$http', 'Restangular',
function($scope, $http, Restangular) {
$scope.users = Restangular.all('users').getList();
$scope.toggleActive = function(user) {
Restangular.one('users', user.UserId).all('active').post({
active : user.Active
});
}
@elecnix
elecnix / prune-old-files.sh
Last active December 17, 2015 12:29
Delete old files until the disk usage target is reached. The objective is to keep the disk filled to a maximum value, while leaving some free space. The script was made to manage webcam images, and it always keep "snapshots", which are kept for very long time-lapses, and moved off the disk by an other script.
#!/bin/bash
function used_percent {
df -m "$MOTION_PATH" | tail -n 1 | sed -e 's/.* \(.*\)% .*/\1/'
}
function log {
echo "[$(date +%c)] $@"
}
MOTION_PATH="$1"
USED_PERCENT_TARGET=${USED_PERCENT_TARGET:-90}