Skip to content

Instantly share code, notes, and snippets.

@eusonlito
eusonlito / update.sh
Last active July 1, 2022 01:14
Upgrade a GNU/Linux Debian or Ubuntu system with only one command
#/bin/sh
if [ "`whoami`" != 'root' ]; then
echo ''
echo 'Only root can execute this script'
echo ''
exit 1
fi
@eusonlito
eusonlito / svn-add.sh
Last active December 12, 2015 08:48
Add all new files (no directories) to the next svn commit
#! /bin/sh
add=`svn status |\
grep ? |\
grep '\.[a-z]\{2,4\}$' |\
grep -v '\.sql$' |\
grep -v '\.sh$' |\
grep -v '\.gz' |\
grep -v '\.tar' |\
grep -v '\.swp' |\
@eusonlito
eusonlito / svn-del.sh
Created February 9, 2013 17:43
Remove from svn repository all deleted files
#! /bin/sh
del=`svn status | grep ! | grep -v localhost | awk -F' ' '{print $2}'`
if [ "$del" != '' ]; then
svn del $del
fi
@eusonlito
eusonlito / foldersize.php
Last active July 25, 2023 12:50
PHP function to get the folder size including subfolders
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
;(function ($, window, document, undefined) {
var pluginName = 'name', defaults = {};
function Plugin (element, options) {
this.element = element;
this.settings = $.extend({}, defaults, options);
this.init();
}
@eusonlito
eusonlito / partial-html-repair.php
Last active November 7, 2020 17:45
This function allow to repair bad partial HTML (without DOCTYPE, html, head or body tags).
<?php
function fixHtml ($html)
{
libxml_use_internal_errors(true);
$DOM = new \DOMDocument;
$DOM->recover = true;
$DOM->preserveWhiteSpace = false;
$DOM->substituteEntities = false;
$DOM->loadHtml('<?xml encoding="UTF-8">'.$html, LIBXML_NOBLANKS | LIBXML_ERR_NONE);
#!/bin/bash
echo ''
case "$1" in
'bootstrap')
alias="$1"
url='https://github.com/twbs/bootstrap/trunk/dist'
;;
'fontawesome'|'font-awesome')
@eusonlito
eusonlito / xvfb
Last active October 29, 2019 15:24
Based on https://coderwall.com/p/tog9eq but with SCREEN auto detect and some minor fixes
#!/bin/bash
echo ''
XVFB=`which Xvfb`
if [ "$XVFB" == '' ]; then
echo 'Xvfb is not installed'
echo ''
exit 1;
@eusonlito
eusonlito / generate-bootanimation
Last active January 2, 2016 11:49
Bulk pictures processing to fit it into a canvas
#!/bin/bash
# Put this file into a folder with PNG pictures with transparent background
# ----- Default values ----- #
ext='.png' # Original pictures have this extension
prefix='frame-' # Final pictures name with this prefix
background='white' # Final pictures background color
padding=100 # Do not fit to max width/height, leave some padding
<?php
$urls = array(
'http://google.com/',
'https://google.com/',
'https://google.com?q=Google',
'https://google.com/search?q=Google',
'https://google.com/search/?q=Google&limit=10',
'https://google.com/search/?q=Google#results',
);