Skip to content

Instantly share code, notes, and snippets.

@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 / server-rss.js
Created October 13, 2011 20:44
Crawl a site and make an RSS feed
var http = require('http');
var select = require('soupselect').select;
var htmlparser = require('htmlparser');
var ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.83 Safari/535.2';
var updateFromTheSite = function (callback) {
var cookies = 'uid=0000; pass=0000000000000000';
var siteName = 'The Site name';
@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 / phpdocs.conf
Last active July 13, 2020 22:26
nginx configuration for mirroring PHP.net
server {
server_name php.sutralib.com;
access_log /var/log/nginx/php.sutralib.com.access_log main;
error_log /var/log/nginx/php.sutralib.com.error_log info;
root /home/tatsh/dev/php-doc;
index index.php;
error_page 401 /error.php;
error_page 403 /error.php;
@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 / screenshot-win32.c
Created May 10, 2012 03:52
Make a screen shot (Win32)
#include <windows.h>
#include <stdio.h>
void errhandler(char *msg) {
printf("%s\n", msg);
}
PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp)
{
BITMAP bmp;
@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']
@Tatsh
Tatsh / get-cydia-debs.sh
Last active April 8, 2020 00:14
Get the debs for everything installed
#!/bin/sh
# Get the debs for everything installed
test $UID -ne 0 && echo "Must be run as root" && exit 1
AUTO_INSTALL_DIR="/var/root/Media/Cydia/AutoInstall"
cd
dpkg --get-selections | grep -v -E 'gsc|cy\+|base|bash|dpkg|cydia|firmware|evasi0n|corona|racoon' | awk '{ print $1 }' > packages