Skip to content

Instantly share code, notes, and snippets.

View bubbobne's full-sized avatar
🏠
Working from home

Daniele Andreis bubbobne

🏠
Working from home
View GitHub Profile
@bubbobne
bubbobne / angular_snippest.js
Last active May 24, 2016 13:55
localForage, separe by filtering an input array and store in localforage
/*
Split an array in several sub-array by id.
*/
var separeArrayById = function (data) {
var valueById = {};
for (var i = 0; i < data.length; i++) {
if (!valueById.hasOwnProperty(data[i].id)) {
valueById[data[i].id] = data.filter(function (el) {
return el.id === data[i].id;
@bubbobne
bubbobne / wfs_marker_example.js
Created November 4, 2016 15:54
Test to load a geojson in leaflet with WFS
//collect marker already plotted on the map
var markers_already_show = [];
var max_n_markers = 30;
//icon for the marker
var myIcon = L.icon({
iconUrl: 'img/myIcon.svg',
iconSize: [38, 43],
iconAnchor: [16, 37],
popupAnchor: [0, -28]
<?php
/**
*Crea thumb.
*/
function make_thumb($src, $dest,$type, $desired_width) {
try{
if($type=="png"){
$source_image =imagecreatefrompng($src);
$width = imagesx($source_image);
$height = imagesy($source_image);
library('ckanr')
ckanr_setup()
ckanr_setup(url = "http://dati.trentino.it")
#packageTrentoOD = package_list(as = "json")
packagesTrentoOD = package_list(as = "table",
offset = 0,
limit = 100)
summary(packagesTrentoOD)
@bubbobne
bubbobne / controller.js
Last active June 20, 2017 11:23
Ionic double filter on list (leaflet)
angular.module('doublefilter.example', []).controller('doubleFilterCtrl', function ($scope, $cordovaGeolocation) {
$scope.geom=new L.Point(12, 12);
$scope.items=[{"lat":10,"lng":5,"property1":"a"},{"lat":0,"lng":6,"property1":"a"},{"lat":14,"lng":5,"property1":"b"}];
$scope.filterValue="a";
}).filter("propertyFilter", function () {
return function (items, propertyValue) {
var filtered = [];
for (var i = 0; i < items.length; i++) {
if (items[i].hasOwnProperty("property1") && items[i].property1 == propertyValue) {
filtered.push(items[i]);
@bubbobne
bubbobne / ExampleSlimTest.php
Created June 29, 2017 14:30
slim phpunit test
<?php
use myAppNameSpace\App;
use Slim\Http\Environment;
use Slim\Http\Request;
/**
* Description of ExampeSlimTest
*
* @author daniele andreis
@bubbobne
bubbobne / stringUtilities.py
Last active July 2, 2017 18:51
Example to use of string method in python
'''
A collection of method to manipulate string object in python.
The str object is a sequence, other example of sequence are: bytes, bytesarray, list, tuple, range
'''
def loToUpAndUpToLo(inputString):
'''
Switch the lowercase character to uppercase and uppercase to lowercase.
@bubbobne
bubbobne / bashrc
Created July 11, 2017 08:07
bash color e alias
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
#
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
#
case "$TERM" in
xterm-color)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
;;
@bubbobne
bubbobne / utility.js
Created July 13, 2017 08:56
utility per javascript
/**
* Add the time zone offset to a data.
*
*
* @param {Date} data - The Date to transform.
*/
function getDataWithOffset(data){
var tzoffset = (new Date()).getTimezoneOffset() * 60000;
return new Date(data - tzoffset);
#git config --global core.editor nano
git config --global user.name ""
git config --global user.email ""
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
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 --"