Skip to content

Instantly share code, notes, and snippets.

View Andrewpk's full-sized avatar
🐶
wat

Andrew Kehrig Andrewpk

🐶
wat
  • wat
  • Royal Oak, Michigan
View GitHub Profile
@Andrewpk
Andrewpk / OSX-junos_pulse_listenToMe.sh
Last active April 16, 2022 03:01
wtf juniper. Anyone else find it irritating that junos pulse services and pulse tray must always running in OS X regardless of whether or not you're currently connected? Yeah, me too. I added the following as aliases to my shell to fix this problem. Be sure to change your /Library/LaunchAgents/net.juniper.pulsetray.plist file to reflect the `Kee…
#################################################################################
# start and stop the vpn from the command line from now on with these two commands
# or rename the aliases as you see fit.
#################################################################################
alias startvpn="sudo launchctl load -w /Library/LaunchDaemons/net.juniper.AccessService.plist; open -a '/Applications/Junos Pulse.app/Contents/Plugins/JamUI/PulseTray.app/Contents/MacOS/PulseTray'"
alias quitvpn="osascript -e 'tell application \"PulseTray.app\" to quit';sudo launchctl unload -w /Library/LaunchDaemons/net.juniper.AccessService.plist"
@Andrewpk
Andrewpk / allowPaste.js
Created November 17, 2021 23:16
Allow paste in Chrome/Safari when websites decide to block it.
var allowPaste = function(e) {
e.stopImmediatePropagation();
return true;
};
document.addEventListener('paste', allowPaste, true);
@Andrewpk
Andrewpk / Template.php
Last active January 8, 2017 04:46
Simple PHP templates. Remember when PHP was a hypertext preprocessor? You don't need twig, mustache, smarty, etc., to do simple templating.
<?php
namespace AKUtils;
/**
* A simple template class for PHP. Allows you to create templates in pure PHP.
* There are many template systems like it, but this one is simple.
*/
class Template
{
private $_templateDir="";
//
// main.m
// NSURLWeirdness
//
// Created by Andrew Kehrig on 6/24/16.
// Copyright © 2016 dudid llc. All rights reserved.
//
#import <Foundation/Foundation.h>
@Andrewpk
Andrewpk / interviewLulz.php
Last active March 31, 2016 05:45
Silly craptastic interview question
<?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
Andrewpk / Time Machine SMB mount via Automator
Last active December 27, 2015 21:48
Create a new automator application that has a single action of 'Run Shell Script' and add this as the script, replacing 'MOUNTNAME' with what you want the network share mounted as, 'USERNAME' and 'PASSWORD' respectively (if you have neither set on your SMB share [seriously?] remove from 'USERNAME' to '@' from that line), 'HOST/PATH/TO/TIMEMACHIN…
mkdir /Volumes/MOUNTNAME; mount_smbfs //USERNAME:PASSWORD@HOST/PATH/TO/TIMEMACHINE/SPARSEBUNDLE /Volumes/MOUNTNAME; /usr/bin/hdiutil attach /Volumes/MOUNTNAME/YOURTIMEMACHINE.sparsebundle;
@Andrewpk
Andrewpk / Gruntfile.js
Last active December 25, 2015 17:39
gruntfile with some modifications to run PHP and enable livereload with the grunt-contrib-watch component and lots of cruft. Originally based off the gruntfile included with generator-webapp.
// Generated on 2013-10-16 using generator-webapp 0.4.3
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
#!/usr/bin/env ruby
#
# This script can be used to check the in-store availability of the iPhone 5S.
# By default, it searches for all AT&T models. You can change this by editing
# the MY_DEVICES array below. While the Apple API supports searching for
# multiple devices at once, there is a limit.
#
# Once you have properly configured the MY_DEVICES array, you can run this script
# from the terminal. It takes a single parameter, which should be the zip code you
# wish to use for your search.
@Andrewpk
Andrewpk / iSeries_DB2 - FindForeignKeys.sql
Last active December 16, 2015 23:19
ridiculous query to grab foreign keys for a given table name and/or schema name
SELECT
child.CONSTRAINT_NAME As constraint_name,
coninfo.CONSTRAINT_TYPE as constraint_type,
parent.TABLE_NAME As parent_table_name,
parent.COLUMN_NAME As parent_column_name,
child.TABLE_NAME As child_table_name,
child.COLUMN_NAME As child_column_name,
child.TABLE_SCHEMA As child_table_schema
FROM
QSYS2.SYSKEYCST child
@Andrewpk
Andrewpk / codeLOLpt1.php
Last active December 15, 2015 05:19
codeLOLpt1. This is funny because in order to adequately catch errors of this function, you either need to register a new error handler and check within your handler, or parse $php_errormsg. Simply checking if unserialize returned false is not adequate, since false is an acceptable value to be serialized. IMO: unserialize should probably throw a…
<?php
$origErrorTrackVal = ini_set('track_errors',1);
$oldReportingLevel = error_reporting(E_ALL); //least reporting necessary is E_NOTICE
$mixedUnserializedVal = unserialize(($someArr['someIndex']));
/**
* This next conditional is fun. At this point $mixedUnserializedVal can legally be any value except "unset"
* You still have to check the error messages though :-/
*/
if(isset($mixedUnserializedVal) && preg_match('/Undefined\sindex:\ssomeIndex/', $php_errormsg) === 0) {
//do work