Skip to content

Instantly share code, notes, and snippets.

View mmarcon's full-sized avatar
👋

Massimiliano Marcon mmarcon

👋
View GitHub Profile
tasks:
- name: install nginx
apt: name=nginx state=present update_cache=yes
notify:
- start nginx
- name: configure nginx
copy: src={{ item }} dest=/etc/nginx/sites-available/
with_fileglob:
- ./nginx/*
notify:
- name: link to Keymetrics
command: pm2 link {{ keymetrics_secret_key }} {{ keymetrics_public_key }}
when: keymetrics
become: yes
become_user: apps
ignore_errors: yes
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
# No need to sync the vagrant folder, everything gets deployed
# with the ansible playbook
@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 / 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);
find . -name "*.php" | while read line; do expand -t 4 $line > $line.new; mv $line.new $line; done
@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());
@mmarcon
mmarcon / MFArrayList.java
Created September 22, 2013 10:18
An extension of the ArrayList class that allows mapping and filtering similarly to Array.prototype.map and Array.prototype.filter in JavaScript.
package es.cloudey.webanalyzer.util;
import java.util.ArrayList;
import java.util.Collection;
public class MFArrayList<E> extends ArrayList<E> {
private static final long serialVersionUID = 7281673743494991943L;
public MFArrayList(){
@mmarcon
mmarcon / youtube-helium.js
Last active November 11, 2016 09:18
A bookmarklet to convert youtube video links into links that can be opened with Helium on macOS (http://heliumfloats.com/)
[].slice.apply(document.querySelectorAll('.yt-lockup-title a.spf-link')).forEach(l => {const h = l.getAttribute('href'); l.setAttribute('href', `helium://https://www.youtube.com${h}`)})
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('mongodbVSCodePlaygroundDB');
// The drop() command destroys all data from a collection.
// Make sure you run it against proper database and collection.