Skip to content

Instantly share code, notes, and snippets.

View dlion's full-sized avatar
🦁
If you can dream it, you can do it ~

Domenico Luciani dlion

🦁
If you can dream it, you can do it ~
View GitHub Profile
@dlion
dlion / BorderCanny.c
Created August 28, 2012 23:25
A simple snippet for retrieve frames from the webcam and make only the contourn of the image with Canny filter using OpenCV
/*
* Rilevatore di bordi con canny
* Snippet by Domenico Luciani aka DLion
*/
#include <highgui.h>
#include <cv.h>
int main()
{
@dlion
dlion / function.c
Created September 4, 2012 22:23
sizeFile function, return size of a file
long sizeFile(FILE *file)
{
long pos_now,size;
//Posizione attuale
pos_now = ftell(file);
//Mi posiziono alla fine del file
fseek(file,0,SEEK_END);
//Prendo la dimensione
size = ftell(file);
@dlion
dlion / jsPointer.c
Created October 1, 2012 23:38
Simple snippet to move the pointer on the screen using a joystick
/*###############################################################################
*# @Author : Domenico Luciani aka DLion
*# @Description: Simple snippet for move the pointer on the screen using a joystick
*# @How compile: g++ <source> -o <binary> -lplibjs -lplibsl -lplibsm -lplibul -lm -lX11
*# @Copyright : 2012
*# @Site : http://www.about.me/DLion
*# @License : GNU AGPL v3 http://www.gnu.org/licenses/agpl.html
*###############################################################################*/
#include <X11/Xlib.h>
@dlion
dlion / gist:3849963
Created October 7, 2012 23:31
bash function to upload on my filepicker.io space my file from CLI.
#!/bin/bash
# upfile
# Copyright (C) 2012 Domenico Luciani aka DLion
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
@dlion
dlion / .alert-script.sh
Created December 4, 2012 15:01
Script per il controllo della carica e della temperatura della mia slackware
#!/bin/bash
#Script per il controllo della batteria e della temperatura
while :
do
BATT=$(acpitool -b | grep -Po ", (.*)\." | sed -e s/,\ //g | sed -e s/\\.//g)
TEMP=$(cat /sys/class/hwmon/hwmon0/temp1_input)
if [ $BATT -lt 5 ]; then
xmessage "La batteria e' sotto il 5% il pc verra' spento in 8 secondi" -center -timeout 8
halt
@dlion
dlion / robot.js
Created December 7, 2012 00:45
Smagen
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.rotateCannon(360);
@dlion
dlion / wget_thread.sh
Created January 20, 2013 02:51
Allows to download a file with wget using multi-threading.
function wget_thread()
{
for i in {1..4}; do
wget -rnp -c -N $1 &
done
}
@dlion
dlion / conv.c
Last active December 12, 2015 01:08
Programmazione e laboratorio Prova pratica – 29 Gennaio 2013 Compito A 1) Date due successioni numeriche an e bn, la loro convoluzione è una successione il cui termine n-simo cn è dato da: cn = a0bn + a1b(n -1) + ....+ a(n -1)b1 + anb0 Date le successioni an = (n + 1)² e bn = 1 / (n + 2) si scriva una funzione in C che preso in input un intero n…
/*
* Prova d'esame di programmazione e laboratorio by Domenico Luciani aka DLion
* 01/02/13 - 03:17
*/
#include <stdio.h>
#include <stdlib.h>
void convoluzione(int);
@dlion
dlion / heart.c
Last active December 12, 2015 07:09
Because a nerd in love is too smart.
#include <stdio.h>
char*z="ou"; char*(b)="ar";
char*a="Y";char*s=" ";char*c="cfbvujgvm"
;int main(int(argc),char*argv[]){printf("%s",a);
;char(space)[2];(space)[0]=(s)[0];(space)[1]='\0';
;printf("%s",z);printf("%s",space);printf("%se",b)
;char*l=space;printf("%s",l);int(i);char(n)[10];
for(i=0;i<10;i++){n[i]=c[i]-1;}n[9]='\0';
printf("%s",n);printf("%s",".")
;printf(("%s"),("\0"));
@dlion
dlion / BlinkLed.c
Last active May 23, 2017 08:41
A simple source to blink 2 LED when push button is pressed. You can compile it with: gcc BlinkLed.c -o BlinkLed -lwiringPi and you can run it with: sudo ./BlinkLed
/*
Blink 2 Led with push button
By Domenico Luciani aka DLion
http://dlion.it
*/
//Using wiringPi library
#include <wiringPi.h>
#include <stdio.h>
#include <stdlib.h>