Skip to content

Instantly share code, notes, and snippets.

View carlozamagni's full-sized avatar
🎯
Focusing

Carlo Zamagni carlozamagni

🎯
Focusing
  • Technogym
  • Bologna
View GitHub Profile
# -*- coding: utf-8 -*-
# Based on https://github.com/ikasamah/withings-garmin/blob/master/withings.py
import urllib
from datetime import datetime
import urlparse
import oauth2 as oauth
try:
import json
@carlozamagni
carlozamagni / readme_install_node
Last active January 1, 2016 13:39 — forked from x-Code-x/readme_install_node
NodeJs setup for Debian Weezy
#Quick cp from http://sekati.com/etc/install-nodejs-on-debian-squeeze
#
#Needed to install TileMill from MapBox
#
#Installs node.js which has npm bundled
#
#Build Dependencies
sudo apt-get update && apt-get install git-core curl build-essential openssl libssl-dev
@carlozamagni
carlozamagni / adler32.cs
Last active January 3, 2016 07:59
Adler32 checksum: .NET implementation
public class Adler32
{
public uint checksum = 1;
/// <summary>Performs the hash algorithm on given data array.</summary>
/// <param name="bytesArray">Input data.</param>
/// <param name="byteStart">The position to begin reading from.</param>
/// <param name="bytesToRead">How many bytes in the bytesArray to read.</param>
public void ComputeHash(byte[] bytesArray, int byteStart, int bytesToRead)
{
@carlozamagni
carlozamagni / gps_track_compression.py
Last active January 4, 2016 02:39
Algorithm to "compress" gps tracks by excluding points not relevants for drawing it to a map
__author__ = 'cazamagni'
import math
def haversine_distance(origin, destination):
'''
http://en.wikipedia.org/wiki/Haversine_formula
Wayne Dyck's implementation
'''
'''Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
'''
def encode_coords(coords):
'''Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
@carlozamagni
carlozamagni / mongo_logging_handler.py
Last active August 29, 2015 13:56
Handler for logging module; can be used to redirect logs to a mongodb collection (see configuration example in code comments).
import logging
import datetime
from pymongo import MongoClient
__author__ = 'cazamagni'
'''
Configuration example:
logging.basicConfig(level=logging.INFO)
from lib import xlwt
__author__ = 'cazamagni'
class ExcelDumper(object):
def __init__(self):
self.workbook = xlwt.Workbook(encoding='utf-8')
self.sheet = self.workbook.add_sheet('Sheet1')
@carlozamagni
carlozamagni / pseudo_aop_decorators_collection.py
Last active August 29, 2015 13:57
A collection of (not really) AOP python decorators.
'''
Intended to be used like this:
'''
@After(my_after_func) # my_after_func gets called with the same arguments passed to 'sut_func'
@Before(my_before_func) # as above
@SendResultTo(my_related_func) # my_related_func gets invoked after 'sut_func': my_related_func(**sut_result)
def sut_func(*args, **kwargs):
return 'blah blah'
[
{
"class": "sidebar_container",
// $base01: #586e75
"layer0.tint": [88,110,117],
"layer0.opacity": 1.0,
"layer0.draw_center": false,
"layer0.inner_margin": [0, 0, 1, 0],
"content_margin": [0, 0, 1, 0]
var App = angular.module('App', []);
App.controller('TodoCtrl', function($scope, $http) {
$http.get('todos.json')
.then(function(res){
$scope.todos = res.data;
});
});