Skip to content

Instantly share code, notes, and snippets.

@vaites
vaites / router.php
Created August 15, 2016 23:04
h5ai router for PHP built-in server
<?php
/**
* h5ai router for PHP built-in server
*
* @link http://php.net/manual/en/features.commandline.webserver.php
*/
// full path of requested file
$path = dirname(__DIR__) . preg_replace('/\?(.*)/', '', $_SERVER['REQUEST_URI']);
@vaites
vaites / kpcli-installer.sh
Last active February 2, 2024 15:08
kpcli installer for Termux
apt install perl
cpan Crypt::Rijndael
cpan Term::ReadKey
cpan Sort::Naturally
cpan File::KeePass
cpan Term::ShellUI
cpan Term::ReadLine::Perl5
wget http://netcologne.dl.sourceforge.net/project/kpcli/kpcli-3.0.pl -N -O /data/data/com.termux/files/usr/bin/kpcli
chmod +x /data/data/com.termux/files/usr/bin/kpcli
perl -pi -e 's/\/usr\/bin\/perl/\/data\/data\/com.termux\/files\/usr\/bin\/perl/g' /data/data/com.termux/files/usr/bin/kpcli
@vaites
vaites / g15daemon.spec
Created April 11, 2015 08:16
Fixed g15daemon spec files by Thomas Pifer (Fedora 21 compatible)
Name: g15daemon
Version: 1.9.5.3
Release: 1%{?dist}
Summary: A daemon that allows use of the G15 keyboard's keys and LCD
License: GPLv2
URL: http://www.g15tools.com/node/180
Source0: http://downloads.sourceforge.net/project/g15daemon/G15Daemon%201.9x/%{version}/%{name}-%{version}.tar.bz2
Group: Applications/System
#Uses a patch derived from the g15daemon-wip folder in trunk:
@vaites
vaites / mysql2sqlite.sh
Created December 13, 2014 10:12
Convert a MySQL database to SQLite
#!/bin/bash
read -p "User: " MYSQL2SQLITE_USER
read -s -p "Pass: " MYSQL2SQLITE_PASS
sqlt -f DBI --dsn dbi:mysql:$1 --db-user $MYSQL2SQLITE_USER --db-pass $MYSQL2SQLITE_PASS -t SQLite > schema.sql
mysqldump -u$MYSQL2SQLITE_USER -p$MYSQL2SQLITE_PASS --compatible=ansi --skip-opt $1 | grep "INSERT" > data.sql
iconv -f ISO-8859-1 -t UTF-8 data.sql > data-iso.sql
perl -pe "s/\\\'/''/g" data-iso.sql > data.sql
cat schema.sql | sqlite3 "$1.db" && cat data.sql | sqlite3 "$1.db"
@vaites
vaites / calibre-upgrade.sh
Created November 29, 2014 16:41
Upgrade Calibre on Mac OS X to latest version
#!/bin/bash
CALIBRE_DOWN="http://status.calibre-ebook.com/dist/osx32"
CALIBRE_LAST=`curl --head --silent ${CALIBRE_DOWN} | grep "Location" \
| awk '{print $2}' | perl -pi -e 's/\r\n//g'`
CURRENT_USER=`whoami`
CALIBRE_NAME=`echo ${CALIBRE_LAST} | awk -F '/' '{print $5}'`
CALIBRE_FILE="/Users/${CURRENT_USER}/Downloads/${CALIBRE_NAME}"
@vaites
vaites / font-face.sh
Created November 18, 2014 19:26
Convert any EOT/OTF/TTF font to all required @font-face and shows a ready-to-use CSS code
#!/bin/bash
# dependencies
FONTFORGE=`which fontforge`
TTFAUTOHINT=`which ttfautohint`
# base checks
if [ "x$1" == "x" ]; then
echo "Usage: ./font-forge.sh [FILE]"
exit