Skip to content

Instantly share code, notes, and snippets.

@eusonlito
eusonlito / update.sh
Last active Jul 1, 2022
Upgrade a GNU/Linux Debian or Ubuntu system with only one command
View update.sh
#/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 Dec 12, 2015
Add all new files (no directories) to the next svn commit
View svn-add.sh
#! /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 Feb 9, 2013
Remove from svn repository all deleted files
View svn-del.sh
#! /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 Jul 27, 2022
PHP function to get the folder size including subfolders
View foldersize.php
<?php
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
View jquery.plugin.js
;(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 Nov 7, 2020
This function allow to repair bad partial HTML (without DOCTYPE, html, head or body tags).
View partial-html-repair.php
<?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);
View install-git
#!/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 Oct 29, 2019
Based on https://coderwall.com/p/tog9eq but with SCREEN auto detect and some minor fixes
View xvfb
#!/bin/bash
echo ''
XVFB=`which Xvfb`
if [ "$XVFB" == '' ]; then
echo 'Xvfb is not installed'
echo ''
exit 1;
@eusonlito
eusonlito / generate-bootanimation
Last active Jan 2, 2016
Bulk pictures processing to fit it into a canvas
View generate-bootanimation
#!/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
View entrevista-programador-exercicio1.php
<?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',
);