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 / geometry_geojson.yaml
Last active November 2, 2023 19:08
A #swagger #geojson geometry description
#MIT License
#
#Copyright (c) 2017 Daniele Andreis
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
@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]
@bubbobne
bubbobne / postgis.sql
Last active June 11, 2018 11:52
Create geoJSON from postGIS table, and other queries.
/**
*Create geojson
**/
SELECT row_to_json(fc) FROM (
SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM
(SELECT 'Feature' As type,ST_AsGeoJSON(lg.the_geom, 4)::json As geometry ,
row_to_json((SELECT l FROM (SELECT value_1,value_2,value_3) As l
)) As properties
FROM my_table As lg ) As f ) As fc;
<?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\]\$ '
;;