Skip to content

Instantly share code, notes, and snippets.

View adtaylor's full-sized avatar

Ad Taylor adtaylor

  • Birmingham, England
View GitHub Profile
@adtaylor
adtaylor / 00 - README.md
Last active July 19, 2016 16:24
React children issue

Problem

When using JSX code on a pre-existing piece of code that is using props.children, I am receiving the error Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {})..

Furthur more, the object sent through as this.props.children no longer look like element classes.

Files 01 and 03 shows the code working on a JSBIN sandbox. https://jsbin.com/busaqipeme/edit?js,console,output

Files 02 and 04 show the code from a large react project.

@adtaylor
adtaylor / fetchAllPlayers.js
Created August 30, 2015 11:07
Access the Fantasy Football Premier League API using Node.js
var fplFetch = require('./fplFetch.js'),
PLAYER_COUNT = 590;
//
// Fetch All Players
//
for(var i = 0; i < PLAYER_COUNT; i++) {
fplStat( i, function(data) {
console.log('Player data:' ,data);
@adtaylor
adtaylor / RMT.js
Created August 6, 2015 19:23
Output a RMT ready string from the FPL 'Pick My Team' page
var s = "\n",
pos = ['GK: ', 'DEF: ', 'MID: ', 'FORW: ', '\n ['];
[].forEach.call( document.querySelectorAll('.ismPitchRow'), function(row, i){
s += pos[i];
[].forEach.call( row.querySelectorAll('.ismPitchWebName'), function(dt){ s += dt.innerHTML });
if( i == 4 ) s += "]";
s += "\n";
}); s;
@adtaylor
adtaylor / Create Resource Table
Last active August 29, 2015 14:23
Building a Duckworth-Lewis calculator in Rails and React.js
rails generate scaffold Resource zero:decimal one:decimal two:decimal three:decimal four:decimal five:decimal six:decimal seven:decimal eight:decimal nine:decimal over:integer over_ball:integer
$blue-shades: #002050, #00188F, #4668C5 !default;
@function blue($shade:2) {
@return nth($blue-shades, $shade);
}
color: blue(3);
@adtaylor
adtaylor / embeds.html
Created April 9, 2015 15:45
Example embeds
<!-- Facebook Video -->
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.3";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
@adtaylor
adtaylor / wordpress_lorem_finder_snippets.sql
Created January 7, 2014 13:31
Wordpress Lorem Finder SQL Snippets
SELECT * from `wp_posts`
WHERE `post_content` RLIKE
'Lorem|ipsum|dolor|luptatum|molestiae|dolorem|mnesarchum|blandit|ocurreret|Nullam|graeci|appellantur|sensibus|splendide|vituperatoribus|dicam|periculis|dignissim|aliquam|philosophia|iusto|utroque|oportere|utinam|eloquentiam|definitiones|tacimates|meliore|reformidans|Graecis|constituto|assum|atomorum|recteque|Melius|maluisset|solum|ullum|habemus|ponderum|luptatum|honestatis|torquatos|contentiones';
SELECT * from `wp_posts` WHERE `post_excerpt` RLIKE
'Lorem|ipsum|dolor|luptatum|molestiae|dolorem|mnesarchum|blandit|ocurreret|Nullam|graeci|appellantur|sensibus|splendide|vituperatoribus|dicam|periculis|dignissim|aliquam|philosophia|iusto|utroque|oportere|utinam|eloquentiam|definitiones|tacimates|meliore|reformidans|Graecis|constituto|assum|atomorum|recteque|Melius|maluisset|solum|ullum|habemus|ponderum|luptatum|honestatis|torquatos|contentiones';
SELECT * from `wp_posts` WHERE `post_title` RLIKE
'Lorem|ipsum|dolor|luptatum|molestiae|dolorem|mnesarchum|blandit
@adtaylor
adtaylor / fizz_buzz.rb
Last active December 21, 2015 01:49 — forked from luxerama/fizz_buzz.rb
100.times do |i|
case
when ((i % 3) == 0 and (i % 3) == 0)
puts "FizzBuzz"
when i % 3 == 0
puts "Fizz"
when i % 5 == 0
puts "Buzz"
else
puts i
@adtaylor
adtaylor / HTML5_Geolocation_Mocking.coffee
Created December 31, 2012 16:46
A simple and dirty way to test applications that rely on the HTML5 Geolocation API. Useful for headless testing that do not include the API. Includes tests - just run `navigator.geolocation.metaTesting()`.
# A faked Geolocation Class
#
# @example Usage
# window.navigator = { geolocation : new Geolocation() };
#
# @example A sucessful Geolocation call
# navigator.geolocation.getCurrentPosition(
# function(position) {
# console.log(position);
# },
@adtaylor
adtaylor / UMD_jQuery_plugin.coffee
Created September 3, 2012 11:32
This is an UMD CoffeeScript implementation of Twitter Bootstrap's approach to jQuery plugin development
# ============================================================
# PluginName v0.0.0
# http://URL
# ============================================================
# Copyright 2012 The Beans Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#