Skip to content

Instantly share code, notes, and snippets.


Andrew Kehrig Andrewpk

View GitHub Profile
Andrewpk / allowPaste.js
Created Nov 17, 2021
Allow paste in Chrome/Safari when websites decide to block it.
View allowPaste.js
var allowPaste = function(e) {
return true;
document.addEventListener('paste', allowPaste, true);
View NSURLWeirdness.m
// main.m
// NSURLWeirdness
// Created by Andrew Kehrig on 6/24/16.
// Copyright © 2016 dudid llc. All rights reserved.
#import <Foundation/Foundation.h>
Andrewpk / interviewLulz.php
Last active Mar 31, 2016
Silly craptastic interview question
View interviewLulz.php
* I was given a really silly sorting question to write out in pseudo code once after spending 9 hours traveling
* to the HQ of the employer and running on about 3 hours of sleep.
* I figured I'd do poorly, and I did, but I explained my method.
* I just wasn't able to get the code on the board without constantly erasing and not having a clear head so I was
* passed over for another candidate.
* I named this interviewLulz because I find it lulzworthy when an employer uses sorting questions as their test when
* the sorting requested is:
* A) Ridiculous.
Andrewpk /
Last active Aug 29, 2015
String + Uri.parse() vs Uri.parse().buildUpon(). I'm probably missing something, but why does Android 2.3 have problems with using Uri.parse().buildUpon() when every one of these methods has been around since api v1?
* Works great on Android 4, and likely 3 but causes Android 2.3 to build a Uri
* with a string value of "geo:?q=" + zipCode
Uri geoUri = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", zipCode).build();
* Works great on Android 2.3+
View angularChainedSelect.html
<script src=""></script>
/** setup simple styling **/
.ng-invalid { border: 1px solid red; }
body { font-family: Arial,Helvetica,sans-serif; }
body, td, th { font-size: 14px; margin: 0; }
table { border-collapse: separate; border-spacing: 2px; display: table; margin-bottom: 0; margin-top: 0; -moz-box-sizing: border-box; text-indent: 0; }
a:link, a:visited, a:hover { color: #5D6DB6; text-decoration: none; }
Andrewpk / gist:25bbc40c2f1ab9985eda
Created Mar 6, 2015
Simple grunt-contrib-connect options to modify cross-domain policy.
View gist:25bbc40c2f1ab9985eda
grunt.config(['connect'], {
options: {
port: 9000,
hostname: '*',
keepalive: true,
middleware: function (connect) {
return [
function (request, response, next) {
response.setHeader('Access-Control-Allow-Origin', '*');
return next();
Andrewpk /
Created Jan 8, 2015
Ports being listened to on my machine
netstat -an | grep LISTEN | awk '{ print $4 }' | rev | cut -d: -f1 | rev
Andrewpk / mehRandomString.php
Last active Aug 29, 2015
PHP: pseudo-random string of defined length
View mehRandomString.php
function randString($length, $charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789')
$str = '';
$count = strlen($charset) - 1;
while ($length--) {
$str .= $charset[mt_rand(0, $count)];
return $str;
Andrewpk /
Created Oct 3, 2014
If you're running a synology with dsm v4 (you have a /var/log/synolog directory) and you have lots of traffic, your connection log will probably get full. For some reason this doesn't rotate, so put this script somewhere or add these commands to a scheduled task. If your connection log fills up your filesystem (all of /tmp is used) you won't be …
rm /var/log/synolog/synoconn.log
rm /tmp/synolog*
/usr/syno/etc/rc.d/ restart
/usr/syno/etc/rc.d/ restart
Andrewpk / Monolog\Handler\PDOHandler.php
Last active Aug 29, 2015
A PDO monolog handler implementation. Almost done (it needs tests). It also works with Postgres' json data type.
View Monolog\Handler\PDOHandler.php
namespace AK\Monolog\Handler;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
use Monolog\Formatter\JsonFormatter;
class PDOHandler extends AbstractProcessingHandler