Skip to content

Instantly share code, notes, and snippets.

View coderatchet's full-sized avatar
💹
line go up

Jared Nagle coderatchet

💹
line go up
View GitHub Profile
@coderatchet
coderatchet / goog-debouncer-usage.js
Last active August 14, 2016 22:06
goog.async.Debouncer usage
//after a little messing around, I found out how to use the goog.async.Debouncer properly
goog.require('goog.async.Debouncer');
goog.require('goog.events.InputHandler');
var usernameField_ = /* something like a textfield */
var thingThatShouldHappenOnceAfterInterval = function(){ /* ... */ }
var inputHandler = new goog.events.InputHandler(userNameField_);
var eventHandler_ = /* @type goog.events.EventHandler */
/* where the magic happens */
@coderatchet
coderatchet / goog-events-eventtype-beforeunload-tabclose.html
Last active August 15, 2016 00:57
goog.events.EventType.BEFOREUNLOAD. Intercepting a tab close using the 'beforeunload' event.
<!doctype html>
<html lang="en">
<head>
<title>BEFOREUNLOAD intercept example</title>
</head>
<body>
<h1>Try to close me!</h1>
<form action="javascript:console.log('stop poking me!');">
<label for="something">sometimes you need to interact with the page before the browser will prompt you.</label><input type="text" id="something" />
<input type="submit" />
@coderatchet
coderatchet / bash_profile_insert.sh
Last active August 17, 2016 00:05
bash completion for virtual environments (virtualenv) in mac os x
export VENVS=$HOME/venvs # or whatever your virtualenvs folder is.
# first install brew_completion by calling `brew install brew-completion`
# will add bash_completion in the future. for now this is a place holder for when it will be needed.
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# if you're placing the _act function and its alias in their corresponding files
if [ -f $HOME/.bash_functions ]; then
@coderatchet
coderatchet / mod_wsgi-POST-example-environ-variable-contents.txt
Created August 25, 2016 00:23
Example environ variable contents of mod_wsgi apache server POST method (sanitized for public viewing)
# example of the contents of the environ variable that is passed to wsgi application callables. i.e. __call__(environ, reponse)
{'mod_wsgi.listener_port': '9999'
'HTTP_X_FORWARDED_SERVER': 'localhost'
'HTTP_REFERER': 'http://localhost:1234/app'
'beaker.get_session': <bound method SessionMiddleware._get_session of <beaker.middleware.SessionMiddleware object at 0x105da2190>>
'HTTP_ACCEPT_LANGUAGE': 'en-AU,en;q=0.8'
'CONTEXT_DOCUMENT_ROOT': '/.../myapp/conf/.mod_wsgi-express/api/htdocs'
'SERVER_SOFTWARE': 'Apache'
'SCRIPT_NAME': ''
@coderatchet
coderatchet / example-turn-off-formatter.py
Created September 8, 2016 01:50
Turn off code formatting for code block in Intellij Idea
# open intellij settings
# Editor -> Code Style -> (in context window) Formatter Control -> tick "Enable formatter markers in comments"
# @formatter:off
...
(r"/api/myapp/([0-9]+)/module/(some|uberlly|rediculouslly|long|line|of|code|that-will-probably|be-auto-formatted|into-multiple|lines|but|I've|arranged|like|this|intentionally)/datboi/export", my.awesome.over.80.line.Class)
...
# @formatter:on
@coderatchet
coderatchet / after--example_goog.object.extend_config_defaults.js
Last active September 8, 2016 05:50
default values for keys in a configuration object for a function using goog.object.extend()
/**
* @typedef {{
* exportFormat: string,
* renderFormat: string,
* exportArguments: Array }}
*/
some.namespace.MyClass.ARGUMENTS;
/**
* @param {some.namespace.MyClass.ARGUMENTS=} opt_config optional configuration object
@coderatchet
coderatchet / FlywayIntegrationTests.java
Created August 2, 2017 10:38
Flyway Integration Test
package com.example.tests;
import com.example.tests.config.TestDatabaseConfig;
import org.flywaydb.core.Flyway;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.context.annotation.PropertySource;