Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
@mircobabini
mircobabini / get-latest-netbeans-version.sh
Last active December 18, 2015 14:58
Obtain the last netbeans version available on the official website
#!/bin/bash
# @author Mirco Babini <mirkolofioⓐgmail.com>
HTML="`wget -qO- http://dlc.sun.com.edgesuite.net/netbeans/`"
versions=(`echo $HTML | grep -oE '[0-9]+\.[0-9]+\.?[0-9]?+' | uniq`)
echo "${versions[${#versions[@]}-1]}"
@mircobabini
mircobabini / dl-mixcloud.php
Last active December 18, 2015 17:28
Download mp4 undownloadable from mixcloud. Not so lawful, use with care.
<?
/**
* Prints the 'wget' cmd you must run into a shell in order to direct download the mp4 track
* @author Mirco Babini <mirkolofioⓐgmail.com>
*/
$uris = array ('http://www.mixcloud.com/a-long-track/on-mixcloud/');
$cmd = '';
foreach ($uris as $uri) {
list (,,,, $filename) = explode ('/', $uri);
@mircobabini
mircobabini / get-latest-hplip-version.sh
Last active December 16, 2016 22:38
Obtain the last hplip version available on the official sourceforge repository
#!/bin/bash
# @author Mirco Babini <mirkolofioⓐgmail.com>
LOCALV=(`dpkg -s hplip | grep 'Version'| cut -d' ' -f2| cut -d'-' -f1`)
type hp-info >/dev/null 2>&1 || LOCALV=0
HTML="`wget -qO- http://sourceforge.net/api/file/index/project-id/149981/mtime/desc/limit/20/rss`"
versions=(`echo $HTML | grep -oE '[0-9]+\.[0-9]+\.?[0-9]?+' | uniq`)
readarray -t versions < <(for a in "${versions[@]}"; do echo "$a"; done | sort -r)
REMOTEV=${versions[0]}
float_test() { echo | awk 'END { exit ( !( '"$1"')); }'; }
RSS: http://www.rcp-vision.com/eclipse/eclipseMirror/technology/epp/downloads/release/release.xml
get <present> tag: RELEASENAME/RELEASECODE
32b: http://www.rcp-vision.com/eclipse/eclipseMirror/technology/epp/downloads/release/kepler/R/eclipse-standard-kepler-R-linux-gtk.tar.gz
64b: http://www.rcp-vision.com/eclipse/eclipseMirror/technology/epp/downloads/release/kepler/R/eclipse-standard-kepler-R-linux-gtk-x86_64.tar.gz
filepath: [..]/release/RELEASENAME/RELEASECODE/eclipse-standard-RELEASENAME-RELEASECODE-linux-gtk[-x86_64].tar.gz
@mircobabini
mircobabini / facebook-select-all.js
Created July 1, 2013 12:56
Working Select-All Script for Facebook Events Invites.
javascript:var inputs = document.getElementsByTagName("input");var cbs = [];for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "checkbox") { inputs[i].click(); } }
@mircobabini
mircobabini / wordpress-parents.php
Last active December 19, 2015 09:48
Work-with-parents functions for Wordpress.
<?php
function get_topmost_parent_id ($post_id) {
if ($post_id === null)
$post_id = get_the_ID();
$parent_id = get_parent_id ($post_id);
if ($parent_id == 0){
return $post_id;
} else {
return get_topmost_parent_id ($parent_id);
<?
function str_keep ($needle, $haystack, $howManyTimes = 1) {
while ($howManyTimes--) {
if (($pos = strpos ($haystack, $needle)) === false) {
return false;
}
$kaystack = substr ($haystack, 0, $pos);
}
@mircobabini
mircobabini / git.sh
Created July 9, 2013 10:26
git commodities up, down, reset
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "usage: ./git up|down|reset";
else
if [ "$1" = "up" ]; then
read -p "Commit description: " desc
git add . && \
git add -u && \
git commit -m "$desc" && \
git push origin master
@mircobabini
mircobabini / facebook-select-all-console.js
Created July 10, 2013 13:20
Working Select-All Script for Facebook Events Invites.
var inputs = document.getElementsByTagName("input");var cbs = [];for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "checkbox") { inputs[i].click(); } }
@mircobabini
mircobabini / w3-clean-pass.php
Created July 31, 2013 16:50
Uncache files containing passwords cached by W3 Total Cache Plugin for Wordpress.
<?
/**
* Uncache files containing passwords cached by W3 Total Cache Plugin for Wordpress.
*
* @author Mirco Babini <[email protected]>
*/
// check if the plugin exists
if (defined ('W3TC_CACHE_DIR')) {
$dir = W3TC_CACHE_DIR;