Skip to content

Instantly share code, notes, and snippets.

View jaredwilli's full-sized avatar
🏄‍♂️

Jared Williams jaredwilli

🏄‍♂️
View GitHub Profile
@jaredwilli
jaredwilli / gist:5469626
Last active February 9, 2024 10:29
HTML5 Canvas Performance and Optimization Tips, Tricks and Coding Best Practices

HTML5 canvas Performance and Optimization Tips, Tricks and Coding Best Practices With canvas being still very new to internet, and no signs of it ever getting old that I can see in the future, there are not too many documented best practices or other really important tips that are a must know for developing with it in any one particular place. Things like this are scattered around and many times on lesser known sites.

There's so many things that people need to know about, and still so much to learn about, so I wanted to share some things to help people who are learning canvas and maybe some who already know it quite well and am hoping to get some feedback from others about what they feel are some best practices or other tips and tricks for working with canvas in HTML5.

I want to start off with one I personally found to be quite a useful yet surprisingly uncommon thing for developers to do. Indent your code Just as you would any other time, in any other language whatever the case may be. It has been a best p

@jaredwilli
jaredwilli / mock-axios.js
Created November 28, 2017 13:40 — forked from cowboy/mock-axios.js
axios mocking via interceptors
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
@jaredwilli
jaredwilli / todoCtrl.js
Created April 27, 2013 08:30
todoFactor and TodoCtrl modules for the angularFire TodoMVC example to show an alternative example for using angularFireCollection to sync data with a Firebase by using a Factory to do so. https://github.com/firebase/angularFire/issues/24
'use strict';
todomvc.controller('TodoCtrl', [ '$scope', 'todoFactory', 'filterFilter',
function OtherCtrl($scope, todoFactory, filterFilter) {
$scope.todos = todoFactory.getAllTodos('todos');
$scope.newTodo = '';
$scope.editedTodo = '';
$scope.addTodo = function() {
todoFactory.addTodo($scope.newTodo);
};
$scope.editTodo = function(todo) {
@jaredwilli
jaredwilli / settings.json
Created September 8, 2022 14:49
Updated VS Code settings.json
{
"workbench.colorTheme": "Blackboard",
"security.workspace.trust.untrustedFiles": "open",
"workbench.iconTheme": "material-icon-theme",
"sync.gist": "4fe702ad17b04106241a9237b6dff85e",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"debug.allowBreakpointsEverywhere": true,
#!/usr/bin/env bash
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
@jaredwilli
jaredwilli / gist:c60e5f61a53af76b52ca
Last active February 11, 2020 17:45
Angular 2.0 questions answered by the Angular team
What is the release date for 2.0?
No exact release date yet. They don't want what happened with 1.2.They want to
make sure they get it done right for 2.0 so they are not setting a date yet.
What is the plan for having a migration path for 2.0? How much rewriting of 1.x
apps will need to be done to migrate to 2.0?
Mishko said that there will definitely be a migration plan for 2.0. They dont know
/**
* mergeDeep
*
* @param {*} target object to merge data into
* @param {*} source object containing the data to merge
*/
export function deepMerge(target, source) {
let output = Object.assign({}, target);
if (isObject(target) || isObject(source)) {
Object.keys(source).forEach((key) => {
@jaredwilli
jaredwilli / Fetch.test.js
Created March 8, 2018 17:53 — forked from alfonsomunozpomer/Fetch.test.js
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
@jaredwilli
jaredwilli / framework-sizes.md
Created February 28, 2018 19:40 — forked from Restuta/framework-sizes.md
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – Angular, Ember and React.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@jaredwilli
jaredwilli / ga-with-unbounce-variant.js
Created February 5, 2018 21:52 — forked from EvanWillms/ga-with-unbounce-variant.js
Track each Unbounce landing page variant in Google Analytics separately
<script type="text/javascript">
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;