Skip to content

Instantly share code, notes, and snippets.

View brianswisher's full-sized avatar

Brian Swisher brianswisher

View GitHub Profile
@brianswisher
brianswisher / .editorconfig
Last active August 28, 2017 19:31
A static test drive for https://bl.ocks.org
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 120
@brianswisher
brianswisher / wait.js
Created August 14, 2017 22:46
Wait w/ a promise
function wait (delay = 1000) {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
}, delay)
})
}
window.location.hash.match(/user=([^&]+)/)
@brianswisher
brianswisher / deprecated-react-bootstrap-datetimepicker-0.0.16.sh
Created June 15, 2017 18:45
Deprecated, react-bootstrap-datetimepicker
warning @ warning.js:48
checkPropTypes @ ReactElementValidator.js:256
validatePropTypes @ ReactElementValidator.js:366
createElement @ ReactElementValidator.js:408
(anonymous) @ UnifiedTableFixed.jsx:738
(anonymous) @ index.js:2874
arrayMap @ index.js:1406
map @ index.js:6710
_renderColumns @ UnifiedTableFixed.jsx:733
(anonymous) @ UnifiedTableFixed.jsx:716
@brianswisher
brianswisher / queue.js
Created June 15, 2012 05:31
Queue pattern in JavaScript
(function(){
var util = (function(){
var Queue = function Queue(){
var methods = [],
flushed = false,
add = function( fn ){
if( flushed ) {
fn( response );
} else {
methods.push( fn );
@brianswisher
brianswisher / get-nginx-v.md
Last active January 21, 2017 15:22
Get nginx version; command line
# cli
V=`nginx -v 2>&1 | tee`; echo "var re = /command not found/; var no = '$V'.match(re); if (no) { console.log('$V'.replace(re,'You don\'t have')) } else{ console.log('$V'.split('/').pop()) }" | node

# package
"scripts": {
    "nginx:v": "V=`nginx -v 2>&1 | tee`; echo \"var re = /command not found/; var no = '$V'.match(re); if (no) { console.log(unescape('$V'.replace(re,'You don%27t have'))) } else{ console.log('$V'.split('/').pop()) }\" | node"
}
@brianswisher
brianswisher / test-jenkins-chrome.sh
Created January 11, 2017 04:26
test:jenkins:chrome
npm run test:jenkins -- --browsers=Chrome
@brianswisher
brianswisher / console-agent.js
Created November 29, 2016 00:24
Console Agent
window.name=`
()=>{
const i=0
function step(num){window.name = window.name.split('i='+num).join('i='+(num+1))}
const commands=[
()=>{
step(0)
document.forms[0].username.value = 'username'
document.forms[0].password.value = 'password'
},
@brianswisher
brianswisher / equalizeTimezoneOffset.js
Created November 1, 2016 18:11
Equalize Timezone Offset
function equalizeTimezoneOffset (dateString) {
const parsedDate = new Date(dateString)
parsedDate.setMinutes(parsedDate.getMinutes() - parsedDate.getTimezoneOffset())
return parsedDate
}
@brianswisher
brianswisher / gettimezone.js
Created October 28, 2016 04:49
Get Timezone JavaScript
(() => {
const libs = [
'https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.6/jstz.min.js'
].map((src) => {
return new Promise(resolve => {
const script = document.createElement("script"); script.src = src; script.async = false;
script.onload = () => {
resolve();
};
document.head.appendChild(script);