Skip to content

Instantly share code, notes, and snippets.

@kafene
kafene / refresh-css.js
Created March 7, 2020 22:24
Refresh / reload CSS bookmarklet
javascript:(function () {
const now = Date.now().toFixed(2);
/* Append timestamp to all linked stylesheet urls */
for (const link of document.querySelectorAll('link[rel~="stylesheet"][href]')) {
const url = new URL(link.href);
url.searchParams.set('_cssrefresh', now);
link.href = url.href;
}
@kafene
kafene / handlers.js
Created July 24, 2014 06:57
protocol and content handlers for web services
/**
* Sadly neither Chrome or Firefox fully support the functionality herein.
* Chrome supports only registerProtocolHandler, and Firefox supports
* a limited set of content handlers - at the moment it's pretty much
* just RSS feeds. These do work great in the older Opera 12 though.
*
* I've moved on from the abandoned Opera to Firefox but I put these
* here for future reference, hopefully browsers implement both
* navigator.registerProtocolHandler and navigator.registerContentHandler
* fully in the near future.
@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

Keybase proof

I hereby claim:

  • I am kafene on github.
  • I am kafene (https://keybase.io/kafene) on keybase.
  • I have a public key ASB-7DLvRLALGUox5XxuLBTf9ZYVHPekMdL3Fp2fist-Wwo

To claim this, I am signing this object:

@kafene
kafene / README.md
Last active February 24, 2017 22:48 — forked from EmanueleMinotto/README.md
PHP Microframework

Microframework

This is a PHP (5.3+) microframework based on anonymous functions.

Features

  • requested URLs matched using regular expressions
  • request methods (matches using regular expressions too)
  • differenced FIFO queues for each $priority
  • command line usage
  • backward compatibility
  • integrated Dependency Injection and settings system
  • named patterns
@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);
}
<?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
// 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
@kafene
kafene / cmd.md
Created September 11, 2013 18:00 — forked from KenMacD/cmd.md