Skip to content

Instantly share code, notes, and snippets.

View kimaldis's full-sized avatar

Kim Aldis kimaldis

View GitHub Profile
@kimaldis
kimaldis / browserversion.js
Created January 19, 2019 13:16
Get Browser Version
var browser = '';
var browserVersion = 0;
if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
browser = 'Opera';
} else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
browser = 'MSIE';
} else if (/Navigator[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
browser = 'Netscape';
@kimaldis
kimaldis / sleep.js
Created January 19, 2019 13:19
Javascript Sleep Function
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// useage, await sleep(2000):
//
async function demo() {
console.log('Taking a break...');
await sleep(2000);
console.log('Two second later');
@kimaldis
kimaldis / actionparameters.php
Created January 20, 2019 07:57
Pass parameters to Wordpress actions & filters. #wordpress,#parameters
// hacky sort of way to pass parameters into action functions
//
static function Action( $name, $value ) {
return function() use( $name, $value) {
Log( "vlaue", $name, $value );
};
}
static public function Add( $name, $value ) {
add_action( 'admin_head', self::Action( $name, $value ));
@kimaldis
kimaldis / buildphase.bash
Last active July 13, 2019 12:13
[Copy Executable on Xcode Build] In the Build Phases, add a `New Run Script Phase` to the list. I use `/bin/bash`, but you can probably use the default `/bin/sh` too. Then, I added the following code to the script. Or: Add a copy files phase to Build Phases (`Editor->Add Build Phase->Add Copy Files Build Phase`) and drag the built app into the c…
cp -f -R "${BUILT_PRODUCTS_DIR}/${APPLICATION_NAME}" "/some/folder"