Skip to content

Instantly share code, notes, and snippets.

View jshakes's full-sized avatar

James Shakespeare jshakes

View GitHub Profile
@jshakes
jshakes / additional_info_en.example.json
Last active January 30, 2024 14:59
Additional Info Schema example - all questions
{
"questions": [
{
"question_uuid": "baby_supplies",
"label": "Number of Children Needing Baby Supplies",
"type": "number",
"default_value": 0,
"validations": [
{
"name": "min",
@jshakes
jshakes / index.js
Last active January 12, 2021 20:16
Cloud functions examples for Tatsuya
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const Mercury = require('@postlight/mercury-parser');
const { countArticleWords } = require( './lib/articles' );
admin.initializeApp(functions.config().firebase);
/*
Create some profile information in the users collection,
including an array in which to store the user's article
@jshakes
jshakes / sublime-wordpress-linting-setup.md
Last active September 14, 2018 03:52
Installing Wordpress PHP linting in SublimeText

Install phpcs with homebrew:

brew install php-code-sniffer

cd /usr/local/lib (or wherever you want to the code sniffer rules to live)

Clone the WP rules:

git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs

import React, { Component } from 'react';
import PropTypes from 'prop-types';
class BookItem extends Component {
static propTypes = {
books: PropTypes.array.isRequired,
updateShelf: PropTypes.func.isRequired
}
constructor(props) {
var Sudoku = function(data)
{
// Private methods
// -------------------------
function makeColArr() {
let columns = [];
let valid = true;
data.forEach((row, rowIndex) => {
columns.push([]);
/*
Slideshow Component
-----------------
An extensible class for adding slideshow functionality to a group of elements. Supports next/prev buttons,
autoplay and counter elements for showing the current and total number of slides.
@ $slides (jQuery el) - The element containing the slides (jQuery object)
@ $nextButton (jQuery el) - The forward button
@ $prevButton (jQuery el) - The previous button
@jshakes
jshakes / good-vs-bad.scss
Last active October 22, 2015 21:02
Media queries and nesting
// BAD - lots of selector repetition and if we don't match the nesting/specificity in the media query, the rules we write may not override the defaults
.my-module {
height: 4em;
.my-module-header {
width: 100%;
.my-module-title {
font-size: 1em;
}
}
@jshakes
jshakes / infiniteScroll.class.js
Last active August 29, 2015 14:05
Infinite scroll class
/*
Infinite Scroll Component
-----------------
An extensible class for enabling up-and-down infinite scroll on a scrollable element.
Triggers events on the element when threshold is reached
@ $viewport (jQuery el) - the scrollable viewport element, eg. window
@ $content (jQuery el) -the content container, eg. document
@ threshold (int) - a pixel value for determining how far from the bottom we should fire the callback
@jshakes
jshakes / reset-to-css2
Created April 3, 2014 15:56
CSS3 to CSS2
* {
border-radius: none !important;
-moz-border-radius: none !important;
-o-border-radius: none !important;
-webkit-border-radius: none !important;
border-image: default !important;
box-sizing: content-box !important;
-moz-box-sizing: content-box !important;
-o-box-sizing: content-box !important;
-webkit-box-sizing: content-box !important;
@jshakes
jshakes / page-forgot-password.php
Created October 30, 2012 16:42
One-page WP password reset page (for themes with front-facing bespoke log-in)
<?php
/*
Lets you display a forgot/reset password page within your theme.
Eg, create a page called 'Forgot Password'; save this file as page-forgot-password.php
Adapted from code posted here: http://wordpress.stackexchange.com/questions/14692/check-for-correct-username-on-custom-login-form/14696#14696
*/