Skip to content

Instantly share code, notes, and snippets.

View jamesmoss's full-sized avatar

James Moss jamesmoss

View GitHub Profile
import React, { useState } from 'react';
const UseHook = ({ children, hook, args }) => children(hook(...args));
<UseHook hook={ useState } args={ [0] }>
{ ({ count, setCount }) => (
<button type="button" onClick={ () => setCount(count + 1) }>I have been clicked { count } times</button>
) }
</UseHook>
@jamesmoss
jamesmoss / gist:6ad430fccd4f199720f8
Last active August 29, 2015 14:23
First Great Western's crazy email validation for their on-train wifi service.
var lastchar = $(this).val().length-1;
var e=$(this).val();
var alpha = /[a-z]/;
if (lastchar<7 || !alpha.test(e) || e.indexOf('@') === -1 || e.indexOf('.') === -1 || e.charAt(0) == "."
|| e.charAt(0) == "@" || e.charAt(lastchar) == "." || e.charAt(lastchar) == "@" || e.indexOf("[email protected]")>-1
|| e.indexOf("[email protected]")>-1 || e.indexOf("[email protected]")>-1 || e.indexOf("@example.")>-1 || e.indexOf("donald@duck")>-1
|| e.indexOf("mickey@mouse")>-1 || e.indexOf("@crap.")>-1 || e.indexOf("@test.")>-1 || e.indexOf("@none.")>-1
|| e.indexOf("@222.")>-1 || e.indexOf("@2.")>-1 || e.indexOf("no@one.")>-1 || e.indexOf("@off.")>-1
|| e.indexOf("no@email.")>-1 || e.indexOf("no@spam.")>-1 || e.indexOf("fake@")>-1 || e.indexOf("@fake.")>-1) {
errors = true;

Keybase proof

I hereby claim:

  • I am jamesmoss on github.
  • I am jamesmoss (https://keybase.io/jamesmoss) on keybase.
  • I have a public key whose fingerprint is CFC6 560C FB70 8F10 8BB4 9327 F207 EBB3 92D0 FD44

To claim this, I am signing this object:

find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull --rebase\;
@jamesmoss
jamesmoss / fooljs.com
Created March 31, 2012 09:41
weirdness
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
@jamesmoss
jamesmoss / SO WEIRD
Created March 31, 2012 09:37
WHAT IN THE HELL
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://fooljs.com/">here</a>.</p>
</body></html>
@jamesmoss
jamesmoss / cron.php
Created November 18, 2011 14:17 — forked from jaspertandy/cron.php
function myfloor( $value , $precision = 0 ){
$multiplier = pow(10, $precision);
return floor( $value * $multiplier ) / $multiplier;
}
function myceil( $value , $precision = 0 ){
$multiplier = pow(10, $precision);
return ceil( $value * $multiplier ) / $multiplier;
}
gource -960x540 --seconds-per-day 1 --auto-skip-seconds 0.1 --file-idle-time 0 --max-file-lag 1 --max-files 0 -e 0.3 --title "Oi Polloi Development" --hide dirnames,filenames --font-size 18 --font-colour FFFFFF --background 111111 --bloom-multiplier 0.8 --bloom-intensity 0.5 --stop-at-end --key --hash-seed 3798 --colour-images --default-user-image ~/gource/default.png --highlight-users --logo ~/gource/message_logo.png --user-scale 3 --multi-sampling -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libvpx -b 10000K ~/gource/oipolloi.webm
@jamesmoss
jamesmoss / Custom.css
Created July 10, 2011 07:50
Left side CSS inspector checkboxes in Chrome devtools
.styles-section:hover .properties .enabled-button {
visibility: visible !important;
}
.styles-section .properties li.disabled .enabled-button {
visibility: visible !important;
}
.styles-section .properties .enabled-button {
margin: 0 4px 0 0 !important;
<?php
// 0:00 1/1/2011 UTC
$some_time = 1293840000;
$some_timezone = 'Europe/Moscow';
date_default_timezone_set($some_timezone);
require('Twig/lib/Twig/Autoloader.php');
Twig_Autoloader::register();