Skip to content

Instantly share code, notes, and snippets.

View roberto-butti's full-sized avatar
🚀

Roberto Butti roberto-butti

🚀
View GitHub Profile
db.tollbooth.find().forEach(function (item) {
name = item.name
mysplit = name.split(" - ")
item.route = mysplit[0]
db.tollbooth.save(item)
})
@roberto-butti
roberto-butti / update loc (lng lat) on mongodb.js
Last active September 23, 2016 16:54
update loc (lng lat) on mongodb
db.tollbooth.find().forEach(function (item) {
loc = [item.lng, item.lat]
// print(loc)
item.loc= loc
print(item)
db.tollbooth.save(item)
})
@roberto-butti
roberto-butti / .htaccess
Created March 3, 2016 15:50
.htaccess for mod_expires and mod_deflate
<IfModule mod_expires.c>
ExpiresActive on
# Your document html
ExpiresByType text/html "access plus 1 month"
# Media: images, video, audio
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
@roberto-butti
roberto-butti / send_json_post_auth_with_guzzle.php
Created February 22, 2016 11:35
Send a JSON in a POST, with HTTP Basic Auth (Guzzle Version)
<?php
$endpoint_url="your_url_here";
$string_json = "your_json_string";
$username="username";
$password ="password";
$client = new Client();
$options= array(
'auth' => [
$username,
@roberto-butti
roberto-butti / send_curl_json_post_auth.php
Last active February 22, 2016 10:40
Send a JSON in a POST, with HTTP Basic Auth
<?php
$endpoint_url="your_url_here";
$string_json = "your_json_string";
$username="username";
$password ="password";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@roberto-butti
roberto-butti / merge_image_multilayer.sh
Created February 12, 2016 10:03
How to flat N png images (with trasparency) in 1 layer in jpg format (with 50% quality) #imagemagick #confert #flatten
convert images_*.png -layers flatten image.png ; convert image.png -quality 50 image.jpg
@roberto-butti
roberto-butti / stats_2016_01.json
Last active February 2, 2016 19:53
Statistiche utilizzo Browser gennaio 2016
{
"Chrome 47.0": "23.69",
"Chrome for Android": "16.39",
"Safari iPhone": "7.03",
"IE 11.0": "6.23",
"Firefox 43.0": "5.76",
"Android 0": "4.83",
"Opera 0": "4.04",
"Safari iPad": "3.22",
"Chrome 48.0": "2.41",
@roberto-butti
roberto-butti / merge_image.sh
Created January 15, 2016 15:21
Script per la sovrapposazione di N immagini con trasparenza
COUNTER=1
for currentfile in $(ls Productname*.png); do
if [ $COUNTER == 1 ]; then
cp $currentfile prova_$COUNTER.png
else
composite $currentfile prova_$(expr $COUNTER - 1).png prova_$COUNTER.png
fi
COUNTER=$(expr $COUNTER + 1)
done
@roberto-butti
roberto-butti / upgrade.sh
Last active September 16, 2019 09:27
upgrading php7 with MacPorts
#!/bin/bash
#update ports index
sudo port selfupdate
# install php version 7.0 :)
sudo port install php70
# install php 7 as apache module
sudo port install php70-apache2handler
cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php7 mod_php70.so
cd
@roberto-butti
roberto-butti / Preferences.sublime-settings
Created May 8, 2015 08:27
Preferences.sublime-settings
{
"auto_indent": true,
"detect_indentation": true,
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"indent_to_bracket": false,
"smart_indent": true,