Skip to content

Instantly share code, notes, and snippets.

View geddski's full-sized avatar

Dave Geddes geddski

View GitHub Profile
@geddski
geddski / Brewfile
Last active November 13, 2022 13:28
Dave Geddes' Brewfile for awesome mac automation
cask_args appdir: "/Applications"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-drivers"
tap "homebrew/cask-fonts"
tap "homebrew/core"
brew "fish"
brew "git"
brew "httpie"
brew "github/gh/gh"
@geddski
geddski / nesting.js
Created January 14, 2012 05:08
helper function for nesting backbone collections.
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];
@geddski
geddski / useComponentRect.js
Created November 16, 2019 21:10
hook for calculating a component's bounding rect
import React, { useState, useEffect, useLayoutEffect, useContext } from 'react';
import debounce from "debounce";
function useComponentRect(containerRef, debounceTime = 100) {
const [rect, setRect] = useState();
const calculateRect = debounce(() => {
if (containerRef.current){
const rect = containerRef.current.getBoundingClientRect();
setRect(rect);
/*
How to use Angular inside a Backbone view.
*/
var ViewWithAngular = Backbone.View.extend({
render: function(container){
var $injector = angular.injector(['ng', 'mason']);
$injector.invoke(function($rootScope, $compile){
var elem = $compile('<h1 ng-controller="NestedCtrl">Backbone View with nested Angular. Message: {{message}}</h1>')($rootScope);
@geddski
geddski / geddes-french-bread.md
Last active December 30, 2019 19:50
Mama Geddes' French Bread Recipe

BEFORE YOU MAKE THIS: These will turn out best if you use french bread pans

Mix together in a bowl 2 Tbls Yeast 1/2 cup warm water 1 tsp sugar let yeast activate (about 10 minutes)

In large bowl, combine:

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>
</title>
<!--[if !mso]><!-- -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
@geddski
geddski / StretchTitle.jsx
Created November 16, 2019 21:08
StretchTitle component
/** @jsx jsx */
import { css, jsx } from '@emotion/core'
import React, {useRef, useEffect, useState, useLayoutEffect} from "react"
import useComponentRect from "shared/hooks/useComponentRect"
const StretchTitle = (props) => {
const containerRef = useRef();
const textRef = useRef();
const componentRect = useComponentRect(containerRef, 10);
const [scale, setScale] = useState(1);
@geddski
geddski / create-react-app-for-testing
Created August 30, 2017 20:51
quick way to start testing ES6 code with a real browser (using create-react-app and Jasmine)
create-react-app comes with Jest which is awesome, but sometimes you need a real DOM/browser to test with. Here's a quick way to get up and running testing your app.
1. Create a *separate* app for testing, using create-react-app:
```
create-react-app tests
cd tests
```
2. Modify the index.html to include the Jasmine spec runner (see index.html below)
3. Modify the index.js to just run your tests rather than bootstrap a React app. (see index.js below)
@geddski
geddski / cf.less
Created April 18, 2012 20:06
micro clearfix LESS mixin
/* Micro ClearFix Mixin */
.clearfix{
zoom:1;
&:before, &:after{ content:""; display:table; }
&:after{ clear: both; }
}
@geddski
geddski / Avatar.js
Created November 10, 2016 23:01
Angular 1 component helper for rendering components directly
/**
* A sample Angular 1 component, created using the component helper above.
* Uses Aphrodite for CSS
*/
import component from './component';
import { StyleSheet, css } from 'aphrodite';
const styles = StyleSheet.create({
avatar: {