Skip to content

Instantly share code, notes, and snippets.

View mmarcon's full-sized avatar
👋

Massimiliano Marcon mmarcon

👋
View GitHub Profile
@mmarcon
mmarcon / DateUtil.java
Last active December 23, 2015 14:58
milliseconds to pretty date in Java
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class DateUtil {
public static String getDate(long milliSeconds) {
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
find . -name "*.php" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done
@mmarcon
mmarcon / fetch.php
Created April 30, 2012 11:57
Download and unarchive a whole Github repository
<?php
function unzip($file) {
$zip = zip_open($file);
if (is_resource($zip)) {
$tree = "";
while (($zip_entry = zip_read($zip)) !== false) {
echo "Unpacking " . zip_entry_name($zip_entry) . "\n";
if (strpos(zip_entry_name($zip_entry), DIRECTORY_SEPARATOR) !== false) {
$last = strrpos(zip_entry_name($zip_entry), DIRECTORY_SEPARATOR);
$dir = substr(zip_entry_name($zip_entry), 0, $last);
@mmarcon
mmarcon / sUpload.js
Created December 21, 2011 07:16
Draft of a simple jQuery plugin to upload files asynchronously via AJAX
(function($) {
var settings = {
hoverClass: 'sUpload-hover',
dropAreaClass: 'sUpload-drop',
dropMessage: 'Drop file here!',
dropAreaHeight: 200, uploadURL: null,
fileReaderCallback: null,
fileUploadCallback: null,
errorCallback: null
},
@mmarcon
mmarcon / gist:1323584
Last active December 7, 2022 17:15
iOS extend SQLite by adding functions
/*
Target: iOS, iOS5
Let's say you have a SQLite DB to index a number of files, resources, or items in general.
You want to perform a full-text search on this item. Example:
TABLE: Item
----------------------------------------------------------------------
ID | Name | Description