This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Export to shp file with select. Create a start and end date (weekly)*/ | |
pgsql2shp -f "./test.shp" -h localhost -p 5432 -u **** -P ******* myDataBase "select table2.gid,table2.geom,data.* from (select id,survey_date,extract('week'from date) as dow ,date_trunc('week', date) as start_week,(date_trunc('week', date)+ '7 days'::interval) as end_week, value from table1) as data left join table2 on data.gid=table1.gid;" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import xml.etree.ElementTree | |
e = xml.etree.ElementTree.parse('listaStazioni.xml').getroot() | |
with open('./codiceStazioni.csv',newline="") as csvfile: | |
id_stazioni=csv.reader(csvfile,delimiter=",") | |
with open('./outputStazione.csv','w',newline="") as outFile: | |
out=csv.writer(outFile,delimiter=",") | |
header = ('codice', 'nome', 'nomebreve', 'quota','latitudine','longitudine','est','nord') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Capsule\Manager as DB; | |
/* | |
*Init eloquent illuminate | |
* | |
*DBDRIVER => "pgsql","sqlite","mysql" | |
* | |
*DBNAME is the complete path of the file if the driver is sqlite. | |
*/ | |
$capsule = new DB(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint node:true */ | |
'use strict'; | |
var gulp = require('gulp'); | |
var argv = require('yargs').argv; | |
var $ = require('gulp-load-plugins')(); | |
var angularTemplatecache = require('gulp-angular-templatecache'); | |
var del = require('del'); | |
var jshint = require('gulp-jshint'); | |
var jscs = require('gulp-jscs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import csv | |
immagine = Image.open(my_tiff_FILE) | |
pixels = list(map(lambda i: i*2,list(immagine.getdata()))) | |
width, height = immagine.size | |
pixels = [pixels[i * width:(i + 1) * width] for i in range(height)] | |
print(pixels[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//rename | |
rename 's/pattern/new_string/' <files> | |
//upper-to-lower | |
for i in *; do mv $i `echo $i | tr [:upper:] [:lower:]`; done | |
//get apache user name | |
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd' | grep -v root | head -1 | cut -d\ -f1` | |
//set permission | |
sudo chmod g+rw "$APACHEUSER allow delete,write,append,file_inherit,directory_inherit" ./logs | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_field_to_layer(layer, string_value, int_value, real_value): | |
for v in string_value: | |
print(v) | |
field_name = ogr.FieldDefn(v, ogr.OFTString) | |
field_name.SetWidth(24) | |
layer.CreateField(field_name) | |
for v in int_value: | |
print(v) | |
f=ogr.FieldDefn(v, ogr.OFTInteger) | |
layer.CreateField(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_request_to_json(url, user_name, user_password): | |
auth_string = '%s:%s' % (user_name, user_password) | |
base64string = base64.b64encode(auth_string.encode('ascii')) | |
headers = {'Authorization': "Basic %s" % bytes.decode(base64string)} | |
try: | |
req = urllib.request.Request(url, None, headers) | |
response = urllib.request.urlopen(req) | |
return json.loads(bytes.decode(response.read())) | |
except IOError as e: | |
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 --" |