Skip to content

Instantly share code, notes, and snippets.

View phaberest's full-sized avatar
🌎
On a world tour as digital nomad

Luca Sartori phaberest

🌎
On a world tour as digital nomad
View GitHub Profile
@phaberest
phaberest / helpers.php
Last active September 20, 2016 13:57
[PHP] Array to XML
private function arrayToXML($data, &$xml)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
if (is_numeric($key)) {
$key = 'item'.$key; //dealing with <0/>..<n/> issues
}
$subnode = $xml->addChild($key);
array_to_xml($value, $subnode);
} else {
@phaberest
phaberest / mac_tricks.sh
Last active October 17, 2018 19:42
Mac defaults hacks
# Reduce dock show/hide time
defaults write com.apple.dock autohide-delay -int 0
defaults write com.apple.dock autohide-time-modifier -float 0.4
killall Dock
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 10
# Screeshots in jpg
@phaberest
phaberest / ie_includes_polyfill.js
Created January 18, 2019 17:36
Polyfill for js es2015 includes
// includes() polyfill for strings
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;