Skip to content

Instantly share code, notes, and snippets.

// ActiveTable - a bookmarklet to make tables sortable and editable
function init() {
var aHrows = getHrows();
var numHrows = aHrows.length;
var aHidden = getHiddenColumns();
ATpopup = document.createElement("div");
ATpopup.style.cssText = "position: absolute; visibility: hidden; padding: 0; font-family: Arial; background-color: rgba(255, 255, 255, 0.9); border-radius: .5em; text-align: center; box-shadow: .05em .05em .5em #00C;";
ATpopup.innerHTML = "<a href='sort' title='sort' onclick='sortColumn(); return false'><img border=0 src='http://stevesouders.com/images/sort_up_down.png' style='padding-top: 0.2em;'></a><br><a href='hide' style='color: #C00; font-family: monospace; font-size: 1.5em; text-decoration: none;' title='hide' onclick='hideColumn(); return false'>x</a>"; // TODO - use protocol-less URL for img
<?php
/**
* Ranking Library
* contains alogrithms for story ranking
* Basically a PHP Implementation of reddits algorithms
*
* @author Lucas Nolte <lnolte@i.biz>
* @since 0.1
* @package Polska Wiadomosc
* @subpackage Libraries
@kafene
kafene / gist:6856361
Created October 6, 2013 16:55
Repulsion-Force (Colomb's Law)
#!/usr/bin/env php
<?php
# From: http://www.reddit.com/r/dailyprogrammer/comments/1ml669/091713_challenge_138_easy_repulsionforce/
function calculate_repulsion_force($mass1, $mass2, $distance) {
$divisor = bcmul($mass1, $mass2);
$dividend = bcpow($distance, 2);
return bcdiv($divisor, $dividend);
}
#!/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
@kafene
kafene / reactivetable-bookmarklet.js
Created February 23, 2014 02:16
reactivetable-bookmarklet
/*http://www.phpied.com/reactivetable-bookmarklet/*/
(function(){
var styles =
'#reactive-table-overlay {\
background: rgba(0, 0, 0, 0.7);\
position: fixed;\
width: 100%;\
height: 100%;\
top: 0;\
left: 0;\
@kafene
kafene / dnscrypt-installation.md
Last active July 30, 2017 20:09
DNSCrypt Installation

Create and enter a working directory

mkdir -p ~/dnscrypt-working-directory && cd ~/dnscrypt-working-directory

Become root

sudo -s
@kafene
kafene / comast-webmail-adblock.user.js
Created June 10, 2014 12:47
Comcast Webmail Adblock Userscript
// I don't always read my Comcast webmail, but when I do, I do it without ads 8-)
/web.mail.comcast\.net/i.test(location.hostname) &&
(function () {
var selectors = [
'#table_adsrvc',
'#comcast-adsrvc',
'#comcast-skyscrapperad',
'iframe[title=Advertisement]',
'#skin_td_tree_bottom_ad',
@kafene
kafene / rename.md
Last active August 29, 2015 14:02
Finding and renaming all images with bash

Here's the use case:

I have an exported website that has images deeply nested throughout it in various folders. I want to find all of them, and copy them into a single directory. I don't care about the filenames so for the sake of both dedupliacting the results and making sure no filename collisions occur, I want to name the resulting images $(sha1sum $image).jpg.

So I wrote a small script to do this and I felt like sharing:

shopt -s globstar # Enable `**` for globbing
shopt -s extglob # Enable extended glob matching
shopt -s nocaseglob # Enable case-insensitive globbing
@kafene
kafene / rebuild_db.py
Created June 23, 2014 01:13
iPod shuffle Database Builder
#!/usr/bin/env python2
# -*- coding: iso-8859-1
# iPod shuffle Database Builder
# =============================
# @usage Copy rebuild_db.py to your iPod's root directory and run it.
# @url http://shuffle-db.sourceforge.net
# @author Martin J. Fiedler <martin.fiedler@gmx.net>
# @license GPL 2 <http://www.gnu.org/licenses/gpl-2.0.html>