Skip to content

Instantly share code, notes, and snippets.

View lidio601's full-sized avatar

Fabio Cigliano lidio601

View GitHub Profile
@lidio601
lidio601 / plist_rootelement_fix.m
Last active August 29, 2015 14:01
I was trying to load fixed-structure plist file by changing his text content ad adding a dictionary as root element.
/**
* I was trying to load fixed-structure plist files like this:
* \code{.xml}
* <?xml version="1.0" encoding="UTF-8"?>
* <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
* <plist version="1.0">
* <array>
* <dict>
* <key>id</key>
* <string>ID-0</string>
@lidio601
lidio601 / mjpeg_video_output.php
Last active August 29, 2015 14:01
PHP script to output an mjpeg video from a jpeg file directory
<?php
$photos = array();
// $photos comes with a list of files (maybe with their absolute path)
// of images (here they are jpeg files!) to output
// http://en.wikipedia.org/wiki/Motion_JPEG
// https://github.com/berak/netcam/blob/master/netcam/main.cpp
@lidio601
lidio601 / python_handler.py
Last active August 29, 2015 14:01
Apache+mod_python+Python MJPEG output handler. Here I needed a MJPEG video output by a web URI. In this case I used the mod_python to handle a web request by the Apache webserver. The Python script was simply loading a list of images contained in a certain directory and that have been named in a numeric progressive way.
import httplib
import cgi
from mod_python import apache
import mod_python
import string
import os.path
import sys
import time
from time import gmtime
from time import strftime
@lidio601
lidio601 / convertMOD.py
Last active August 29, 2015 14:01
convert MOD+MOI video to AVI. In this case I need to convert my video camera output files (*.MOD + *.MOI) to AVI files to save disk space and have a more useful video format.
#!/usr/bin/python
# Script to import video from Panasonic SDR-H20 Camera
# This script is the same as SDCopy.exe utility in Windows
# Script copies mod files, renames them to "YYYY-MM-DD HH-MM.mpg" pattern, where "YYYY-MM-DD HH-MM" is creation time
# Script also can optionally set aspect ratio flag
# Made by m0sia (m0sia@plotinka.ru)
# Modified by lidio601
import os
#!/usr/bin/python
from random import random
dadi = 4
# array >>> [1, 2, 3, 4]
ncol = 3
sol = []
@lidio601
lidio601 / iTunes_esporta.py
Last active August 29, 2015 14:01
Python script + AppScript python binding to export an iTunes Music Playlist to an Android phone directory or a car USB key.
#!/opt/local/bin/python2.4
from appscript import *
import shutil
import os
itunes = app('itunes')
# nome della playlist da copiare
playlist_name = "toUSB"
UserInterfaceState.xcuserstate
Thumbs.db
*~
.git
.DS_Store
*.xcuserdatad
UserInterfaceState.xcuserstate
@lidio601
lidio601 / split_database.py
Last active August 29, 2015 14:01
Split MySQL DB Dump file. I needed a script to get a MySQL database dump given by the PHPMyAdmin dbms and split it up in different .sql files, one for each SQL Database.
#!/usr/sbin/python
#encoding=utf8
import string, os, sys
SEPARATOR = """-- Current Database: `"""
def sep(str0):
if not str0.startswith(SEPARATOR) and SEPARATOR in str0:
return (str0,'','')
@lidio601
lidio601 / google_doodle_download.php
Last active August 29, 2015 14:01
PHP look for doogle image on Google web page
$ch = curl_init("http://www.google.it/") ;
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
$str = curl_exec($ch);
curl_close($ch);
$str = substr($str,strpos(str_replace("\"","",$str),'id=logo')-100);
$str = substr($str,strpos($str,'<img '));
@lidio601
lidio601 / do_htdocs_backup.sh
Last active August 29, 2015 14:01
Bash Script to backup or make a snapshot of your website
#!/bin/bash
cd "/path/to/your/backup/directory"
mysqldump -u "<DATABASE-USER>" -p "<DATABASE-NAME>" >"`date +%Y%m%d`_database.sql"
tar czvf "`date +%Y%m%d`_htdocs.tar.gz" "/path/to/your/htdocs/directory"