Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@rogersguedes
rogersguedes / eth0IP.sh
Last active November 11, 2015 14:29
Get the eth0 ip
ip addr|grep -i "eth0:" -A2|grep "inet"|sed "s/^\s*inet\s\([0-9\.]\+\).*/\1/ig"|tr -d "\n"
cat ~/.ssh/id_rsa.pub|cut -d ' ' -f 2 | base64 -d|md5sum -b|sed 's/../&:/g; s/: .*$//'
@rogersguedes
rogersguedes / youTubeVideoSpeedControl.js
Last active November 11, 2015 16:25
This snippet controls the video playback speed on YouTube.
document.getElementsByClassName("video-stream")[0].playbackRate = 1.0;
#!/bin/bash
qrencode -s 20 -o aff.png $1 && convert aff.png aff.jpg && jp2a aff.jpg && eog aff.png && rm aff.png aff.jpg
@rogersguedes
rogersguedes / data_uri.php
Last active March 28, 2016 17:02
Data URI’s can be useful for embedding images into HTML/CSS/JS to save on HTTP requests and consequently enhance your site loading time. The following function will create a Data URI based on $file for easier embedding.
<?php
//Original source: https://css-tricks.com/snippets/php/create-data-uris/
function data_uri($file, $mime){
$contents=file_get_contents($file);
$base64=base64_encode($contents);
echo "data:$mime;base64,$base64";
}
?>
find . -type f -ipath "./*.jpg" -print0 | du --files0-from=- -ch
<?php
function buildSelect($tableStruct){
$queryString = "SELECT ";
$queryBinds = array();
$sqlQueryFields = array(
"states.id",
"states.code",
"states.name"
);
#!/usr/bin/bash
let dlStart="$(date +%s)"
# do something
let dlEnd="$(date +%s)"
let diffe="$dlEnd-$dlStart"
echo $diffe