Skip to content

Instantly share code, notes, and snippets.

@kafene
kafene / insertAdjacentElement.md
Last active August 29, 2015 14:18
Element.prototype.insertAdjacentElement shim

This is a shim for Element.prototype.insertAdjacentElement, which is supported all major browsers except Firefox.

Example: https://jsfiddle.net/kafene/s6Lweg5k/

if ("undefined" === typeof (Element.prototype.insertAdjacentElement)) {
    Object.defineProperty(Element.prototype, "insertAdjacentElement", {
        enumerable: false,
        writable: true,
        configurable: true,
###
####### HISTIGNORE #######
###
# examples from interwebs, noob dot file notes
#export HISTIGNORE='pwd:exit:fg:bg:top:clear'
# (if try to erasedups do not ignore things want 2 pune but on OSX it no workie)
# ignore things that start with a space, and ignore the exit command
#HISTIGNORE='[ \t]*:exit'
# some slashdot dudes says
#export HISTIGNORE="&:ls:[bf]g:exit:pwd:clear:mount:umount:[ \t]*"
@kafene
kafene / monolog-pimple-whoops-examples.php
Last active September 24, 2021 20:51
Set up some Monolog handlers, a Pimple Container, and Whoops
<?php
/**
* Various configurations of Monolog and Whoops
* using a Pimple Container as service locator
*
* Monolog: https://github.com/Seldaek/monolog
* Pimple: https://github.com/fabpot/Pimple
* Whoops: https://github.com/filp/whoops
* Swift Mailer: https://github.com/swiftmailer/swiftmailer
@kafene
kafene / ifsetor.md
Created August 2, 2014 15:35
PHP 5.6+ ifsetor/coalesce userspace implementation

Ref: https://wiki.php.net/rfc/ifsetor

So I found out something sad: the variadics RFC implementation was altered so that ...$arg can only come last.

And since we can't pass a non-variable default value by reference, it can go first, just kind of confusing looking, unfortunately.

<?php

function coalesce($default, &amp;...$args) {
@kafene
kafene / distances_slc_haversine.php
Created July 25, 2014 06:56
distance calculations using Spherical Law of Cosines and Haversine Formula
<?php
# Spherical Law of Cosines
function distance_slc($lat1, $lon1, $lat2, $lon2) {
$a = sin(deg2rad($lat1)) * sin(deg2rad($lat2));
$b = cos(deg2rad($lat1)) * cos(deg2rad($lat2));
$c = cos(deg2rad($lon2 - $lon1));
$distance = rad2deg(acos($a + $b * $c));
return round($distance * 60 * 1.1515, 4);
}
@kafene
kafene / com.ubuntu.desktop.pkla
Created July 24, 2014 10:12
/var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla (see: policykit-desktop-privileges)
[Mounting, checking, etc. of internal drives]
Identity=unix-group:admin;unix-group:sudo
Action=org.freedesktop.udisks.filesystem-*;org.freedesktop.udisks.drive-ata-smart*;org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.encrypted-unlock-system;org.freedesktop.udisks2.filesystem-fstab;
ResultActive=yes
[Change CPU Frequency scaling]
Identity=unix-group:admin;unix-group:sudo
Action=org.gnome.cpufreqselector
ResultActive=yes
@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 / LICENSE
Last active August 29, 2015 14:04
openbox pipemenu for xrandr
Copyright (c) 2009, Seth House <seth@eseth.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation