Skip to content

Instantly share code, notes, and snippets.

View shrunyan's full-sized avatar

Stuart Runyan shrunyan

View GitHub Profile
# custom login link
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L]
@shrunyan
shrunyan / fartscroll.js
Last active December 17, 2015 07:08
Dynamically insert fartscroll while your co-worker is away from their desk. Insert line 1 into a users console, followed up by line 2.
var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = 'http://code.onion.com/fartscroll.js'; document.getElementsByTagName('body')[0].appendChild( script );
fartscroll();
@shrunyan
shrunyan / gist:5860985
Created June 25, 2013 18:25
Wordpress: Load different header based on the page your looking at. @source http://pastie.org/private/lnkpqeh4eyaguhdxn51w
<?php
// Header.php - Load individual header files based on view
if ( is_home() ) {
include(TEMPLATEPATH.'/header-index.php');
}
else if ( is_single() ) {
@shrunyan
shrunyan / iphone-splash-screen.html
Last active December 19, 2015 12:28 — forked from burin/gist:3840737
Adds a splash screen to an iPhone web app.
<!-- standard viewport tag to set the viewport to the device's width
, Android 2.3 devices need this so 100% width works properly and
doesn't allow children to blow up the viewport width-->
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" />
<!-- width=device-width causes the iPhone 5 to letterbox the app, so
we want to exclude it for iPhone 5 to allow full screen apps -->
<meta name="viewport" id="vp" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)" />
<!-- provide the splash screens for iPhone 5 and previous -->
<link href="assets/splashs/splash_1096.png" rel="apple-touch-startup-image" media="(device-height: 568px)">
<link href="assets/splashs/splash_iphone_2x.png" rel="apple-touch-startup-image" sizes="640x960" media="(device-height: 480px)">
@shrunyan
shrunyan / page-top-bar-loader.html
Last active December 20, 2015 07:28
Page loader; CSS animation that is deactivated by javascript after page is loaded. Source: medium.com
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Loading Bar Test</title>
<style>
/**
* Animations
*
@shrunyan
shrunyan / get-all-url-parameters.js
Last active May 21, 2018 11:10
Javascript function which returns an Array of all URL parameters.
/**
* Returns an Array of all url parameters
* @return {[Array]} [Key Value pairs form URL]
*/
function getAllUrlParams() {
var keyPairs = [],
params = window.location.search.substring(1).split('&');
for (var i = params.length - 1; i >= 0; i--) {
keyPairs.push(params[i].split('='));
};
@shrunyan
shrunyan / javascript-for-loop-test.js
Last active December 21, 2015 18:19
Testing performance of different for loop variations in JavaScript. Creating 100,000 anchor link elements.
/**
* v0.1 - removing anchor tag DOM insertion; not neccessary for loop test.
*/
console.time('Multi-variable:');
for (var i = 0, k = 100000; i < k; i++) {
var a = document.createElement('A');
a.href = 'http://www.google.com';
a.innerHTML = 'Link';
};
@shrunyan
shrunyan / python-process-threading-example.py
Last active December 25, 2015 00:29
Threading example in python
import threading
def worker(num):
"""thread worker function"""
print 'Worker: %s' % num
return
threads = []
for i in range(5):
t = threading.Thread(target=worker, args=(i,))
function eachAsync(collection, iterator, callback) {
var iterate = function(i) {
setTimeout(function() {
iterator(collection[i]);
if (i < collection.length) {
iterate(i + 1);
} else {
callback();
}
}, 0);
@shrunyan
shrunyan / Monokai.tmTheme
Created October 18, 2013 23:16
Altered Monokai theme for Sublime Text 2.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>