Skip to content

Instantly share code, notes, and snippets.

View byrichardpowell's full-sized avatar

Richard Powell byrichardpowell

View GitHub Profile
@byrichardpowell
byrichardpowell / reddit-comments.js
Created November 8, 2017 20:15
JSON data for reddit comments
// Comments for https://www.reddit.com/r/formula1/comments/7aq9hf/massa_announces_his_retirement_from_f1/
const post = {
id: 111,
title: "Massa announces his retirement from F1"
};
const comments = [
{
id: 222,
@byrichardpowell
byrichardpowell / randomChild.csx.coffee
Created September 6, 2016 12:48
Show a random element using a React Component (CoffeeScript)
# COMPONENT
RandomChild = React.createClass
displayName: "RandomChild"
getInitialState: -> {
index: Math.ceil(Math.random() * @props.children.length-1)
}
@byrichardpowell
byrichardpowell / action-creator-mock.coffee
Created May 6, 2016 09:33
Mocking redux action creators
_ = require('underscore')
InventoryActions = require('action-creators/entities/inventory')
actions = _.keys(InventoryActions)
mock =
mock: ->
_.each actions, (action) =>
@[action] = jasmine.createSpy(action + "Spy").and.returnValue(action)
resetMock: ->
@byrichardpowell
byrichardpowell / find-dead-css.js
Last active April 18, 2016 16:22
Super simple node script to find CSS that is no longer in use. The results should be considered as safe as a global find and replace (not very), so use your judgement
var walk = require('walk');
var fs = require('fs');
var classesOrIds = [];
var viewsAndTemplates = []
var walkers = [];
var maybeUnusedClassesOrIds = [];
var compleWalkersCount = 0;
var classesToFileMap = {}
// Calback Function every time a walker ends
# ==========================
# Module: {{displayName}}
# Project: Server Density
# --------------------------
# Copyright Boxed Ice Ltd
# ==========================
define (require) ->
React = require('react')
# project/Gruntfile.coffee
# ------------------------
module.exports = (grunt) ->
scaffold:
component:
options:
questions: [{
name: 'path'
@byrichardpowell
byrichardpowell / gist:b9bcf5126f9571245899
Created May 12, 2014 10:31
Tamper monkey: Hide complete JIRA items
// ==UserScript==
// @name Hide Complete JIRA items
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description I find it tricky to distinguish between complete and incomplete items on the planning page of a JIRA sprint. This DIRTY code fades complete items out. You can still hover the items to see what they are.
// @match https://serverdensity.atlassian.net/secure/*
// @copyright 2012+, You
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
@byrichardpowell
byrichardpowell / KlondikeShuffle
Last active December 31, 2015 21:09
A function for shuffling a deck of cards into the stacks required for a game of klondike.
shuffleForKlondike = () ->
suits = _.shuffle(['clubs', 'spades', 'diamonds', 'hearts'])
range = [1..13]
deck =
clubs:
cards: _.shuffle(range)
index: 0
spades:
cards: _.shuffle(range)
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var turn = 10;
var turned = 0;
var stop = false;
<script type="text/view>
<% if ( SystemOwners !== undefined && SystemOwners.Name ) { %>
<p>System owners is <%= SystemOwners.Name %></p>
<!-- Even when _embedded.SystemOwners[0].Name is a string this html will never be outputted -->
<% } else { %>