Skip to content

Instantly share code, notes, and snippets.

View cmcculloh's full-sized avatar

Christopher McCulloh cmcculloh

View GitHub Profile
@cmcculloh
cmcculloh / msConverter.js
Created June 11, 2021 14:41
Converting a timespan of HH:MM:SS to MS using Javascript
console.log('qa', (1 * 60 * 60 * 1000) + (40 * 60 * 1000) + (30 * 1000))
const rawTimespan = '01:40:30';
const rawTimespanArray = rawTimespan.split(':').slice(-3);
const timespanFromReduce = rawTimespanArray.reduce((timespan, segment, i, rawTimespanArray) => {
@cmcculloh
cmcculloh / app.js
Last active May 11, 2021 19:25
Proxying a request through node from front end to different server
//public/javascripts/app/app.js
define(function (require) {
//require dependancies
var Marionette = require('backbone.marionette');
var Backbone = require('backbone');
var $ = require('jquery');
// Override renderer to use pre-compiled templates
Marionette.Renderer.render = function render(template, data) {
<!DOCTYPE html>
<html class="fuelux">
<head lang="en">
<!-- styles -->
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<link href="http://www.fuelcdn.com/fuelux/3.3.0/css/fuelux.min.css" rel="stylesheet"/>
<link href="http://www.fuelcdn.com/fuelux-mctheme/1.1.0/css/fuelux-mctheme.min.css" rel="stylesheet"/>
<!-- scripts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
@cmcculloh
cmcculloh / what-forces-layout.md
Last active May 11, 2020 16:43 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@cmcculloh
cmcculloh / marionette-cheat-sheet.md
Last active June 7, 2018 17:09
Marionette Cheat Sheet
@cmcculloh
cmcculloh / gst.sh
Last active November 8, 2017 06:34
Takes contents of clipboard, syntax highlights them, pasts them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
#!/bin/bash
# Takes contents of clipboard, syntax highlights them, places a copy in "gists" directory in Google Drive, pastes them into a gist, opens the gist in a browser, and puts syntax highlighted version of text in clipboard for pasting into Evernote/email/etc
# requires:
#* gist (https://github.com/defunkt/gist)
#* Google Drive
#* highlight (brew install highlight)
#* an alias that will run this file `alias gst="~/gst.sh"`
@cmcculloh
cmcculloh / highlights
Last active August 8, 2017 18:10
Bookmarklet that allows you to highlight (permanently for that visit) text on page.
javascript: (function() {
/* STYLES */
const css = '.highlight { background: yellow; }';
const head = document.head || document.getElementsByTagName('head')[0];
const style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
@cmcculloh
cmcculloh / Preferences.sublime-settings
Last active September 29, 2016 20:48
My sublime text settings
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/SublimeLinter/Monokai (SL).tmTheme",
"copy_with_empty_selection": false,
"draw_minimap_border": true,
"draw_white_space": "all",
"file_exclude_patterns":
[
"*.class",
@cmcculloh
cmcculloh / escape JSHint
Created March 8, 2011 20:32
allowing escape in JSHint
/*global escape: true */
var string = "blah";
string = escape(string);
{
"Badge Text" : "\\(user.gitBranch)",
"Working Directory" : "\/Users\/cmcculloh",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Red Component" : 0.8866617679595947,
"Color Space" : "Calibrated",
"Blue Component" : 0.9910151958465576,
"Alpha Component" : 1,
"Green Component" : 0.9932246208190918