Skip to content

Instantly share code, notes, and snippets.

@liconti
liconti / install_dep.sh
Last active August 8, 2017 08:00
plone install dependiences
apt install python-setuptools python-dev build-essential libssl-dev libxml2-dev libxslt1-dev libbz2-dev libjpeg62-dev libreadline-dev
@liconti
liconti / folder_full_tabular_view.pt
Last active August 29, 2015 14:22
Tutto il contenuto (nascondi esclusi)
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="plone">
<body>
@liconti
liconti / sublime-text-2-python.md
Created December 21, 2012 08:40
Sublime text 2 python setup on Ubuntu linux 12.04

install Sublime text 2 via PPA or manually

install pythonbrew from https://github.com/utahta/pythonbrew (as root if you wish)

curl -kL http://xrl.us/pythonbrewinstall | bash

install python 2.6.6 enabling 4 bytes unicode

pythonbrew install -C --enable-unicode=ucs4 2.6.6
@liconti
liconti / find-previous-dir.sh
Created November 27, 2012 12:06
search backward for a directory from current path
#!/bin/bash
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "1 argument required, $# provided"
DIRNAME=$1
@liconti
liconti / gen_htpasswd.sh
Created May 2, 2012 15:17
htpasswd usernames generator
#!/bin/bash
num=${1:-10}
prefix=${2:-provRC_}
passwords=(`apg -n $num -m 8 -x8 -M sNC -E \/\*\(\)\/\&\%\$\£\"\!\,\?\;.JKWXYO -c cl_seed`)
for ((i=0;i<$num;i+=1))
do
users[$i]=$prefix`printf "%03d" $i`
htpass[$i]=`htpasswd -nb ${users[$i]} ${passwords[$i]}`
@liconti
liconti / extract_zip_subdir.php
Last active November 3, 2022 22:17
PHP extract a subdirectory contained in a ZIP file to a destination path
<?php
function extract_zip_subdir($zipfile, $subpath, $destination, $temp_cache, $traverse_first_subdir=true){
$zip = new ZipArchive;
echo "extracting $zipfile... ";
if(substr($temp_cache, -1) !== DIRECTORY_SEPARATOR) {
$temp_cache .= DIRECTORY_SEPARATOR;
}
$res = $zip->open($zipfile);
if ($res === TRUE) {
if ($traverse_first_subdir==true){
@liconti
liconti / download_file.php
Created April 20, 2012 06:33
PHP dowload file (following redirects)
<?php
function download_file($url, $filename){
$ch = curl_init($url);
if (is_writable(dirname($filename))) {
$fp = fopen($filename, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
@liconti
liconti / rrmdir.php
Created April 20, 2012 06:26
PHP recursive rmdir
<?php
function rrmdir($path){
if (is_dir($path)) {
array_map( "rrmdir", glob($path . DIRECTORY_SEPARATOR . '{,.[!.]}*', GLOB_BRACE) );
@rmdir($path);
}
else {
@unlink($path);
}
}