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
@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;
cat ~/.ssh/id_rsa.pub|cut -d ' ' -f 2 | base64 -d|md5sum -b|sed 's/../&:/g; s/: .*$//'
#!/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"
#!/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 / astahExport.py
Last active February 7, 2017 10:19
This script generate, for while, PHP classes files from a CSV exported from Astah Professional.
#!/usr/bin/python
import re
import sys
import getopt
import csv
import json
def to_snake_case(name):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
@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
<!DOCTYPE html>
<html lang="[yourLangHere]">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="[yourDescriptionHere]"/>
<meta name="author" content="[yourNameHere]"/>
<link rel="stylesheet" type="text/css" href="[yourCssSourceHere]"/>
<script src="[yourJSsourceHere]"></script>