Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Tatsh / cleanup-kernel-src.py
Created April 15, 2015 01:29
Gentoo: Clean up old kernel sources in /usr/src
#!/usr/bin/env python
from os import chdir, listdir
from os.path import basename, islink, realpath
from shutil import rmtree
import re
import subprocess as sp
import sys
if __name__ == '__main__':
@Tatsh
Tatsh / public-keys.start.sh
Created June 22, 2015 16:07
`/etc/local.d/public-keys.start` fixed for systemd
max_tries=10
i=0
while ((i < max_tries)); do
wget -q -r --retry-connrefused --tries=10 --timeout=60 -O /tmp/my-key http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key
if (($? == 0)); then
break
fi
((i++))
done
@Tatsh
Tatsh / php-config.sh
Created June 29, 2015 08:23
Windows PHP configure arguments (old)
configure --enable-cgi --enable-cli --enable-cli-win32 --enable-intl --enable-mbstring --enable-mbregex --with-mysqlnd --enable-zip --enable-tokenizer --enable-zlib --with-libxml --with-dom --enable-phar --with-simplexml --with-xml --enable-xmlreader --enable-xmlwriter --with-curl --enable-bcmath --with-bz2 --enable-calendar --with-gd --with-mcrypt --enable-exif --enable-json --with-iconv --with-gmp --enable-fileinfo --with-gettext --with-mysqli --with-mysql --with-pdo-mysql --with-pdo-sqlite --with-pspell --with-sqlite3 --enable-phar-native-ssl --with-openssl --enable-tokenizer --with-xsl --enable-pdo --enable-session --enable-markdown
@Tatsh
Tatsh / older-ie-js-limit-fix.reg
Created June 29, 2015 08:25
Registry edit to allow 0xffffffff statements (per script?) in IE 6, 7 (maybe 8?).
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles]
"MaxScriptStatements"=dword:ffffffff
@Tatsh
Tatsh / ie7gc.js
Created October 12, 2011 21:10
Fix memory leak in IE7 jQuery.remove()
if ($.browser.msie && $.browser.version <= 7) {
(function () {
$.fn.originalRemove = $.fn.remove;
$.fn.remove = function (selector) {
this.originalRemove(selector);
for (var k in this) {
delete this[k];
}
};
})(jQuery);
@Tatsh
Tatsh / isIE.js
Created December 13, 2011 18:12
Detect IE using conditional comments
var isIEStatic = null;
var isIE = function () {
if (isIEStatic === null) {
var div = document.createElement('div');
div.style.display = 'none';
div.innerHTML = '<!--[if IE]><div id="ie-find"><[endif]-->';
document.body.appendChild(div);
if (document.getElementById('ie-find')) {
isIEStatic = true;
@Tatsh
Tatsh / winecho.c
Created May 10, 2012 03:37
Echo win32
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@Tatsh
Tatsh / winecho.c
Created May 10, 2012 03:37
Echo win32
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@Tatsh
Tatsh / add-labels.js
Last active October 4, 2015 14:38
Add labels based on data-label attribute , handle LTR/RTL
var addLabels = function (form) {
// Thanks to yorick
var collections = ['input', 'textarea', 'select'].map(form.getElementsByTagName.bind(form));
var labelText, labelEl;
var d = document, i, j, ilen;
var dir = (!form.dir ? (!d.dir ? 'ltr' : d.dir) : form.dir).toLowerCase();
var insertLabel = function (labelEl, inputEl) {
var ref = dir === 'ltr' ? inputEl : inputEl.nextSibling;
ref.insertBefore(labelEl, ref);
@Tatsh
Tatsh / isync-ratings.py
Created January 29, 2013 09:51
Import iTunes ratings from an iPhone database into Clementine's database. Get the database file from your iPhone (including non-jailbroken) by mounting your iPhone via ifuse, and grabbing a copy of `$MOUNTPOINT/iTunes_Control/iTunes/MediaLibrary.sqlitedb` (note how I said *copy*; I will not be held responsible if you have to restore your iDevice…
#!/usr/bin/env python
import sqlite3
import os
import subprocess as sp
import signal
from time import sleep
home = os.environ['HOME']