Skip to content

Instantly share code, notes, and snippets.

View graemeworthy's full-sized avatar

Graeme Worthy graemeworthy

View GitHub Profile
@graemeworthy
graemeworthy / posts.js
Last active November 20, 2018 17:10
Circular dependencies in reselect.
import { createSelector } from 'reselect';
import {
getCurrentUser,
} from './user';
export const getPosts = (state) => state.posts;
export const getPostsByCurrentUser = createSelector(
[

Keybase proof

I hereby claim:

  • I am graemeworthy on github.
  • I am graemeworthy (https://keybase.io/graemeworthy) on keybase.
  • I have a public key whose fingerprint is 8223 B7F7 06F4 A78A 9ED5 7646 56C5 3394 F7D5 9476

To claim this, I am signing this object:

@graemeworthy
graemeworthy / Mason.js
Created November 16, 2015 11:55
Masonry
(function (window) {
'use strict';
// Masonry:
// Places items based on their width, so that lines all line up.
//
// args:
// list: list of items to make a wall with.
// width_fn: method of assessing item width
//
@graemeworthy
graemeworthy / log_media_queries
Created December 12, 2014 17:43
list your active media queries
media_triggers = {
"mobile_xs": "only screen and (min-width: 239px) and (max-width: 321px)",
"mobile": "only screen and (max-width: 529px)",
"mobile_landscape": "only screen and (max-width: 529px) and (orientation: landscape)",
"mobile_portrait": "only screen and (max-width: 529px) and (orientation: portrait)",
"iphone_five_portrait ": "only screen and (min-width: 319px) and (max-width: 321px) and (orientation: portrait)",
"iphone_five_landscape ": "only screen and (min-width: 361px) and (max-width: 640px) and (orientation: landscape)",
"nexus_four_landscape": "only screen and (min-width: 600px) and (max-width: 601px) and (orientation: landscape)",
"tablet": "only screen and (min-width: 530px) and (max-width: 949px)",
"tablet_landscape": "only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: landscape)",
@graemeworthy
graemeworthy / load_order_independence
Last active August 29, 2015 14:11
How to namespace your Javascript to be load order independent
// The problem: Load order independence.
// Sometimes your js files are loaded out of order,
// How can you make sure all your modules are properly assembled.
var myApp = (function(existing){
var self = existing || {};
self.a = 'one';
return self;
}(myApp));
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">
@graemeworthy
graemeworthy / Stash.js
Created March 17, 2011 21:44
A practical implementation of local storage.
Stash = {
supported: function() {
try {
return 'localStorage' in window && window['localStorage'] !== null;
} catch(e) {
return false;
}
},
storage_check: function(url) {
return !!localStorage[url];
@graemeworthy
graemeworthy / nodester_deploy
Created February 10, 2011 03:08
a deploy script that works untill the git push issue is solved
require 'rubygems'
require 'json'
class DeployNodester
attr_accessor :username, :password
def initialize
# you'll need to edit these
@username = ''
@password = ''
@app = ''
@graemeworthy
graemeworthy / test_nodester.rb
Created February 10, 2011 02:52
a test of the nodester api
require 'rubygems'
require 'json'
class TestNodester
attr_accessor :username, :password
def initialize
# all you need is these
@username = ''
@password = ''
# just the above thanks
require 'rubygems'
require 'activerecord'
require 'yaml'
require '../config/boot'
Rails::Initializer.run do |config|
config.action_controller.session = {
:session_key => '_greenbuildingbrain_session',
:secret => 'ebf2f31f5da304726e5e483b755ca30aaad4a67c28034785bdc0a2dc6f2c18930b52be16e42ece664f9e86ca67b049f48f6f4741a10022be5dd2dcfe8c4cea35'
}