Skip to content

Instantly share code, notes, and snippets.

View dansku's full-sized avatar
🌮
Focusing on tacos

Daniel Andrade dansku

🌮
Focusing on tacos
View GitHub Profile
/*------------------------------------------------------------------------------------------------------------------------
Open Hardware Mood Lamp
By: Daniel Spillere Andrade - www.DanielAndrade.net - [email protected] - https://github.com/dansku
https://github.com/dansku/Open-Hardware-Mood-Lamp
Based on the code from Arkadian: http://www.arkadian.eu/pages/219/arduino-controlled-ikea-lamp
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Code version: 0.9
/*------------------------------------------------------------------------------------------------------------------------
Open Hardware Mood Lamp
By: Daniel Spillere Andrade - www.DanielAndrade.net - [email protected] - https://github.com/dansku
https://github.com/dansku/Open-Hardware-Mood-Lamp
Based on the code from Arkadian: http://www.arkadian.eu/pages/219/arduino-controlled-ikea-lamp
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Code version: 0.9
@dansku
dansku / gist:2868858
Created June 4, 2012 14:53
PicPlz Download Script
#-----------------------------------------------------------------------------
# Script to Backup all your photos from PicPlz
#
# Daniel Spillere Andrade - www.DanielAndrade.net
#-----------------------------------------------------------------------------
import urllib2
import simplejson
import os
from datetime import datetime
import urllib
import urllib2
from bs4 import BeautifulSoup
import re
import time
#---[ Functions ]---#
def isTimeFormat(input):
try:
@dansku
dansku / geo-distance.php
Last active December 17, 2015 22:29
Measuring distance from two Geo-Points in PHP
function distance($lat1, $long1, $lat2, $long2) {
$R = 6371; // Earth Radius in Km
$dLat = deg2rad($lat2-$lat1);
$dLong = deg2rad($long2-$long1);
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);
$a = sin($dLat/2)*sin($dLat/2) + sin($dLong/2)*sin($dLong/2)*cos($lat1)*cos($lat2);
$c = 2 * atan2(sqrt($a),sqrt(1-$a));
$d = $R * $c;
@dansku
dansku / geo-distance.py
Created May 31, 2013 01:23
Measuring distance from two Geo-Points in Python
import math
def distance(lat1, long1, lat2, long2):
R = 6371 # Earth Radius in Km
dLat = math.radians(lat2 - lat1) # Convert Degrees 2 Radians
dLong = math.radians(long2 - long1)
lat1 = math.radians(lat1)
lat2 = math.radians(lat2)
a = math.sin(dLat/2) * math.sin(dLat/2) + math.sin(dLong/2) * math.sin(dLong/2) * math.cos(lat1) * math.cos(lat2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
@dansku
dansku / renaming.py
Created May 31, 2013 01:26
Renaming JPEGmini files with Python
import os
for filename in os.listdir("."):
if filename.endswith('_mini.jpg'):
mini = filename.find('_mini.jpg')
name = filename[:mini] + '.jpg'
os.rename(filename, name)
@dansku
dansku / arduino-temperature.ino
Created May 31, 2013 03:26
Arduino LM35 Example
/*
An open-source LM35DZ Temperature Sensor for Arduino. This project will be enhanced on a regular basis
(cc) by Daniel Spillere Andrade , http://www.danielandrade.net
http://creativecommons.org/license/cc-gpl
*/
int pin = 0; // analog pin
int tempc = 0,tempf=0; // temperature variables
int samples[8]; // variables to make a better precision
int maxi = -100,mini = 100; // to start max/min temperature
@dansku
dansku / Breathalyzer.ino
Last active October 19, 2016 05:40
Breathalyzer made with Arduino
/*
@ Code for interfacing Alcohol Gas Sensor MQ-3 with Arduino
@ Code by Daniel Spillere Andrade and Daniel Amato Zabotti
@ [email protected] / [email protected]
@ www.DanielAndrade.net
*/
@dansku
dansku / dotklok.ino
Created May 31, 2013 05:59
Adding temperature to Dotklok
// temperature()
// Temperature Sensor + Clock - by Daniel Spillere Andrade - www.DanielAndrade.net
// Should Change the Temperature Only when minutes change, to prevent floating on temperature
// Based on http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/ - Daniel Spillere Andrade - daniel [a] danielandrade.net
void temperature(){
ht1632_clear();