Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View robatron's full-sized avatar
🤖

Rob McGuire robatron

🤖
  • Zillow
  • Seattle, WA
View GitHub Profile
@robatron
robatron / javascript-log-wrapping.md
Last active February 6, 2024 06:49
Wrapping `console.log` (et al.) in your own function to modify logging behavior.

JavaScript Log Wrapping

Wrapping console.log (et al.) in your own function to modify logging behavior.

Why?

You may want a simple way to:

@robatron
robatron / outlook-macro-auto-bcc.vba
Last active December 18, 2015 00:59
Auto BCC the specified recipient on all sent emails in Outlook 2010.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
' Auto BCC the specified recipient on all sent emails. See "settings" below
'
' From "How to Automatically BCC in Outlook 2010" by Jack Bush, Nov. 2010
' <http://www.groovypost.com/howto/microsoft/how-to-automatically-bcc-in-outlook-2010/>
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim BCC_ADDR As String
@robatron
robatron / passive-attach-module-pattern-example.js
Last active December 19, 2015 07:39
JavaScript Module Pattern Example with "Passive Attachment"
/** JavaScript Module Pattern Example with "Passive Attachment"
*/
(function(
win,
doc,
$,
a,
b
){
// "Passively attach" your new module to global through your namespace,
@robatron
robatron / client-store.md
Last active March 30, 2018 20:23
Storing and accessing server-side JSP variables for client-side JavaScript consumption via a custom JSP tag that uses HTML5 `localStorage`

Set server-side variables in your JSP template via a js:clientStore custom tag for consumption by the JavaScript:

<%-- Arbitrary JSP variables --%>
<c:set var="a" val="1" />
<c:set var="b" val="2" />
<c:set var="c" val="3" />

<%-- Store the "a" and "b" JSP variables under "my.namespace" --%>
<js:clientStore 

Somewhere on the page...

    /** Extend a JSON object in localStorage, as oppose to overwriting it.
    */
    var localStoreExtend = function(namespace, jsonObj){
      
        // Grab existing JSON object
        var existingObj = JSON.parse(localStorage.getItem(namespace));
        
@robatron
robatron / 1. page.less
Last active December 27, 2015 05:09
Front-End Architecture: Root LESS files and how to "parameterize" component styles.
/** Root LESS file for the page where component styles are imported.
*/
// Import components LESS file
@import "component"
// Include component style as a mixin which CAN be included outside of a directive block
.component( 'blue'; 10px );
@robatron
robatron / gist:7900886
Last active December 30, 2015 23:29
{ "question":"How does the GitHub Gist API handle JSON metadata in the description field?", "tags": ["test tag 1", "test tag 2", "test tag 3"] }
test body
@robatron
robatron / 0_reuse_code.js
Created December 10, 2013 22:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@robatron
robatron / clippy-error.sh
Created January 17, 2014 21:33
Clippy error message
if [ "$SEARCH_RESULT" != "" ]; then
echo " _ "
echo " / \ ___________________________________________ "
echo " | | / \ "
echo " @ @ | It looks like you are trying to | "
echo " || |/ | destroy the original repository! | "
echo " || || <--| Please create a fork, and try again. | "
echo " |\_/| | (And read the README while you're at it.) | "
echo " \___/ \___________________________________________/ "
/** Example module that supports CommonJS and IFFE modularity
*
* - CommonJS modules can be imported via `require`
* - IFFE modules attach themselves to the browser's window object
*/
;( function ( factory ) {
// If the environment supports CommonJS modules, attach module to `module.exports`
if ( typeof require === 'function' && typeof exports === 'object' && typeof module === 'object' ) {
var target = module.exports || exports;