Skip to content

Instantly share code, notes, and snippets.

@frantzmiccoli
frantzmiccoli / check-ovh-sold-out.sh
Last active December 29, 2015 13:09
OVH Sold Out helper. A 2 cents bash script to help you monitor when OVH sold-out will finally end. It works on Mac OSX Mountain Lion, it needs to be tested/adapted for other OS.
#!/bin/bash --
# To use it
# watch -n 15 check-ovh-sold-out.sh
if r=`curl http://www.ovh.com/fr/serveurs_dedies/|grep mSP|grep -s -m 1 "Sold Out"`
then
echo "Found this wonderful sold out message!"
else
message="OVH is back in business"
@frantzmiccoli
frantzmiccoli / imgccsearch
Last active July 6, 2016 12:56
Looking at creative commons pictures and tired of switching doing the same things to test all licenses and all sites? This small script is for you. It looks on 500px, Flickr and many cool other ones
#!/usr/bin/env zsh
# Usage: 'imgccsearch "beautiful pictures"'
term=$1
open "https://500px.com/search?q=$term&type=photos&ccLicense=by&sort=relevance"
open "https://500px.com/search?q=$term&type=photos&ccLicense=by-nc&sort=relevance"
open "https://500px.com/search?q=$term&type=photos&ccLicense=by-sa&sort=relevance"
open "https://500px.com/search?q=$term&type=photos&ccLicense=by-nd&sort=relevance"
open "https://500px.com/search?q=$term&type=photos&ccLicense=by-nc-sa&sort=relevance"
@frantzmiccoli
frantzmiccoli / extractdatafrombiggestcities in the world
Last active August 29, 2015 14:05
A small script that extract population and data from Wikipedia's list of biggest cities, it can be easily adapted for other pages and other informations.
// Run me in your console on http://en.wikipedia.org/wiki/List_of_cities_proper_by_population
// from http://stackoverflow.com/questions/298750/how-do-i-select-text-nodes-with-jquery
var getTextNodesIn = function($el) {
return $($el.find(":not(iframe)").addBack().contents().filter(function() {
return this.nodeType == 3;
}).get(0)).text();
};
var rowsSelector = '#bodyContent .sortable.wikitable.jquery-tablesorter tr',
@frantzmiccoli
frantzmiccoli / richvspoorurbanareas.js
Last active August 29, 2015 14:05
Splitting world's biggest urban area between rich and poor to compute a sum of those population.
// Run me on http://en.wikipedia.org/wiki/List_of_metropolitan_areas_by_population
// from http://stackoverflow.com/questions/298750/how-do-i-select-text-nodes-with-jquery
var getTextNodesIn = function($el) {
return $($el.find(":not(iframe)").addBack().contents().filter(function() {
return this.nodeType == 3;
}).get(0)).text();
};
var rowsSelector = '#bodyContent .sortable.wikitable.jquery-tablesorter tr',
@frantzmiccoli
frantzmiccoli / filtered-cities.zsh
Last active August 29, 2015 14:05
Cities filtered by size
# Data source https://www.maxmind.com/en/worldcities
# Using https://github.com/Russell91/pythonpy
# We first extract the cities with more than 500000 inhabitants
# We then filter those in relevant countries
# We generate a string close to json from the output
cat worldcitiespop.txt|py -fx --i '(int(x.split(",")[4]) > 500000)'|\
py -fx "x.split(',').pop(0) in ['us', 'it', 'es', 'pt', 'gb', 'ie', 'is', 'it', 'fr', 'ca', 'be', 'de', 'at', 'dk', 'se', 'fi', 'nl', 'no', 'ch', 'en','lu', 'pl']" |\
py -x "json.dumps({'name': x.split(',')[2], 'latitude': float(x.split(',')[5]), 'longitude': float(x.split(',')[6])}, indent=4, sort_keys=True)+','"

Keybase proof

I hereby claim:

  • I am frantzmiccoli on github.
  • I am frantzmiccoli (https://keybase.io/frantzmiccoli) on keybase.
  • I have a public key ASAiqAa7ifmI-TxwqgucIKM8TbsMEkNDJwDaGPuzmtzMZwo

To claim this, I am signing this object:

@frantzmiccoli
frantzmiccoli / associative-sort.php
Created December 10, 2018 15:25
Just a quick demo highlighting that PHP doesn't preserve same-value keys order while running an associative sort
<?php
$a = [];
$threshold = 120;
while (count($a) < 400) {
$v = count($a) > $threshold ? 'a' : 'b';
$a[] = $v;
}
@frantzmiccoli
frantzmiccoli / localsync
Last active May 30, 2019 08:16
Dirty little script
#!/usr/local/bin/python --
# -*- coding: utf-8 -*-
from paver.easy import sh
import os
import sys
clear_flag = '--clear'
def local_sync():
echo "<?php echo password_hash('hello', PASSWORD_DEFAULT); echo \"\n\";" > test.php; php test.php; php test.php
@frantzmiccoli
frantzmiccoli / Duplicate a template folder in Google Drive using Google Apps Script
Last active February 11, 2020 07:37
Funnily enough you can't duplicate a folder which contains Google Documents
function duplicateRootFolder() {
var templateFolder = DriveApp.getFolderById('PUT YOUR TEMPLATE FOLDER ID HERE (FROM YOUR BROWSER URL)');
var targetParent = DriveApp.getFolderById('PUT YOU PARENT FOLDER ID HERE (FROM YOUR BROWSER URL)');
duplicateFolder(templateFolder, targetParent, false);
}
function duplicateFolder(templateFolder, targetParent, useTemplateName) {
var newFolderName = templateFolder.getName();