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 / gulpfile.js
Last active May 11, 2018 12:55
Simple gulpfile to livereload angular project (dev mode) and build for production
/* 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');
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])
@bubbobne
bubbobne / usefullcmd.sh
Last active October 4, 2018 08:17
bash
//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
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)
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)
@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 --"
@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 / 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 / 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