Skip to content

Instantly share code, notes, and snippets.

View BrynM's full-sized avatar

Bryn Mosher BrynM

View GitHub Profile
@BrynM
BrynM / git-stylebot.css
Last active June 30, 2018 22:46
Wide GitHub Stylebot Customizations
/*
* Use your whole screen for GitHub! This makes GH's layout more flexible to accomodate widescreen displays.
*
* Use/Installation:
* 1. Get Stylebot at https://chrome.google.com/webstore/detail/stylebot/oiaejidbmkiecgbjeifoejpgmdaleoha?hl=en
* 2. Right-click on a GitHub page and select "Stylebot->Style Element" (it doesn't matter which element).
* 3. When the Stylebot window opens, click the "edit CSS" button and paste the entire contents of this file in.
* 4. (optional) Edit to your tastes if you like, but you may lose the ability to update from this gist unless you
* re-make your changes.
*/
@BrynM
BrynM / dive.js
Last active August 29, 2015 14:13
Deep-dive a key from a JavaScript object without a pile of typeof or a try/catch
// the meat of this gist - a recursive function for diving namespaces
function dive(obj, path) {
// split the path, pluck away the first one
var sect = (''+path).replace(/^\./, '').split('.'),
curr = sect.length > 0? sect.shift(): null,
iter;
// see if our current desired match exists
if(curr && obj && 'undefined' !== typeof obj[curr]) {
// last match? then return othewise recurse
@BrynM
BrynM / oh_god_no_cloud_2_0.md
Created August 30, 2014 06:41
Oh god no... Cloud 2.0

It's recently come to my attention that the term Cloud 2.0 has actually been used. Let's head this monstrosity of marketing-speak off at the pass. Here's an invisible link to put on your pages so the term can be appropriately Google Bombed.

<a href="http://i.imgur.com/dZKX7hw.gif" style="height:1px;width:1px;text-indent:-1000px;overflow:hidden">Cloud 2.0</a>

With enough people using it, the GIF below will become the top search result. This will hopefully shame people away from using it.

oh god no

@BrynM
BrynM / hohoho.php
Last active December 31, 2015 01:59 — forked from liamja/hohoho.php
<?php
/**********************
Ho Ho Ho script ©2013 UNKNOWN
Found online in public source.
Considered Public Domain
********************************/
?>Ho! Ho! Ho!<?php
/********************************
No attribution was found,
so you may claim this as your own.
@BrynM
BrynM / isvis()
Last active December 14, 2015 23:39
Test if a given HTML element is visible - isvis()
function isvis ( thing ) {
if ( typeof(thing) === 'object' ) {
try {
return ( thing instanceof HTMLElement ) &&
!( ( thing.offsetWidth === 0 ) && ( thing.offsetHeight === 0 ) );
} catch (e) {
return ( thing.nodeType === 1 ) &&
( typeof(thing.style) === 'object') &&
( typeof(thing.ownerDocument) ==='object') &&
!( ( thing.offsetWidth === 0 ) && ( thing.offsetHeight === 0 ) );
@BrynM
BrynM / bpmv_scratch_pad_marklet.js
Created August 10, 2012 09:42
Chrome JavaScript Scratchpad Bookmarklet
(function () {
function bpmv_quick_scratch_pad () {
var scrId = 'bpmv_script_from_marklet'
, aTagId = 'scratch_pad_marklet_linky'
, scr = document.getElementById( scrId )
, aTag = document.getElementById( aTagId )
, bod = document.getElementsByTagName( 'body' )[0]
, oldCode = '';
function scratch_not_tab ( ev ) {
var aTab = 9;
@BrynM
BrynM / gist:2035091
Created March 14, 2012 08:26
JS Trickery
// editable web page
(function(){
document.body.contentEditable='true';
document.designMode='on';
})();
// merge arrays
(function(){
var a = [1,2,3];
b = [6,5,4];
@BrynM
BrynM / inBuckets.php
Created August 10, 2011 05:11
inBuckets() - A bucketizer function for PHP
<?php
/**
* Find which buckets a range of records belongs in.
*
* This function is for using bucketed queries and/or memcache keys. Let's say
* you want to have some sort of paginated list displaying 10 records per page.
* Which pages do entries 23-31 live on?
*
* <code>
* $recordMarkers = inBuckets( 23, 31, 10 );
@BrynM
BrynM / dSmarty.tpl
Created July 29, 2011 16:03
A slightly improved Smarty Debug Template
{capture name='_smarty_debug_header' assign="debug_header"}
<div class="heading">
<div style="float:right; width:280px; background-color: transparent;">
<select id="varJump" style="display: block; width:190px; margin: 0px auto;" title="You may use the keyboard by pressing [ENTER] to make your selection.">
<option value="#debugTop" selected="selected">*Bryn's Smarty Debug*</option>
<option value="#varsTop">*Var Section*</option>
{foreach $assigned_vars as $vars}
<option value="#anch_{$vars@key|escape:'html'}">VAR {$vars@key|escape:'html'}</option>
{/foreach}
{if !empty($template_data)}<option value="#tplTop" selected="selected">*Tpl Section*</option>{/if}