Skip to content

Instantly share code, notes, and snippets.

View MarcosBL's full-sized avatar
:octocat:
Github Advocate

MarcosBL MarcosBL

:octocat:
Github Advocate
View GitHub Profile
@MarcosBL
MarcosBL / Simple AJAX form controller with jQuery
Last active December 20, 2015 20:09
Simple AJAX form controller with jQuery. It takes care of AJAX stuff, cache busting, avoiding double submit, visual clues and returning values in a few lines of code. You can check it live at http://marcosbl.com/gifsound/?#new
<form method="POST" data-async data-target=".result_div" data-cache="false" action="/process">
<input type="text" id="field1" name="field1" placeholder="Field 1">
<input type="text" id="field2" name="field2" placeholder="Field 2">
<button type="submit" data-processing="¡ OK, SENDING !" data-processing-class="btn-warning" class="btn">¡ Go !</button>
</form>
@MarcosBL
MarcosBL / jsping.js
Created August 12, 2013 09:35
Ping function implemented in pure Javascript
function ping(ip) {
var img = new Image();
var start = new Date().getTime();
var flag = false;
var isCloseWifi = true;
var hasFinish = false;
img.onload = function() {
if ( !hasFinish ) {
@MarcosBL
MarcosBL / sort.php
Created August 13, 2013 01:10
Sorting Images based on Exif data
<?php
$filetypes = array('jpg','jpeg','png','gif','bmp','tiff');
$source = './images_unsorted';
$target = './images_sorted';
$iterator = new RecursiveDirectoryIterator($source);
$bytestotal = 0;
$nbfiles = 0;
@MarcosBL
MarcosBL / bootstrap-gradient-buttons-back.less
Last active December 21, 2015 09:48
Recover the Bootstrap v2 buttons gradients with this LESS mixin
.pretty-buttons(@color, @background, @text-shadow: none) {
color: @color;
#gradient > .vertical(lighten(@background, 5%), 0%, darken(@background, 5%), 100%);
border-color: darken(@background, 10%);
border-bottom-color: darken(@background, 20%);
text-shadow: @text-shadow;
.box-shadow(inset 0 1px 0 rgba(255, 255, 255, .1));
&:hover,
@MarcosBL
MarcosBL / deploy.rb
Created August 31, 2013 02:48
Capistrano sample
def prompt_with_default(var, default)
set(var) do
Capistrano::CLI.password_prompt "#{var} [#{default}] : "
end
set var, default if eval("#{var.to_s}.empty?")
end
namespace :misc do
desc "Remove problematic packages"
task :remove do
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@MarcosBL
MarcosBL / gist:7178549
Last active July 15, 2023 21:41
Use Dropbox as a Free Webseed for your Torrents

Use Dropbox as a Free Webseed for your Torrents

So, what exactly are we doing?

We are going to upload the file we want to distribute in the "public" Dropbox folder, then use that file's URL as the webseed for a new torrent. Then shut off our computer knowing that our file is well looked-after and you will not receive a stern email from Dropbox.

How to get started

@MarcosBL
MarcosBL / sample.sh
Created November 28, 2013 14:36
Descomprimir los tipos de archivos más conocidos desde consola
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
@MarcosBL
MarcosBL / issu.sh
Created December 27, 2013 17:52
Download contents from ISSUU in PDF format
TMP_DIR="/tmp/issud/"
TMP_FILE="issuufile"
KONT=1
I_MAGICK=0
TITLE=""
if [ -z "$1" ]; then
echo "Script para descargar documentos de ISSUU"
echo "Usage: `basename $0` URL"
echo ""
@MarcosBL
MarcosBL / mysqloptimizator.sh
Created January 20, 2014 17:01
Simple MyISAM tables optimization - Just put it on a cron
#!/bin/bash
# Get a list of all fragmented tables
FRAGMENTED_TABLES="$( mysql -e ';use information_schema; SELECT TABLE_SCHEMA,TABLE_NAME FROM TABLES WHERE ENGINE="MyISAM" AND TABLE_SCHEMA NOT IN ("information_schema","mysql") AND Data_free > 0' | grep -v "^+" | sed 's,\t,.,' )"
for fragment in $FRAGMENTED_TABLES; do
database="$( echo $fragment | cut -d. -f1 )"
table="$( echo $fragment | cut -d. -f2 )"
[ $fragment != "TABLE_SCHEMA.TABLE_NAME" ] && echo "Optimizando $fragment" && mysql -e "USE $database; OPTIMIZE TABLE $table;" > /dev/null
done