Skip to content

Instantly share code, notes, and snippets.

View itsravenous's full-sized avatar
🐧

Tom Jardine-McNamara itsravenous

🐧
View GitHub Profile
@itsravenous
itsravenous / matchTextAcrossElements.ts
Created July 21, 2022 10:48
Custom matcher for testing-library/* to find text broken up by elements
/**
* A TextMatch (see https://testing-library.com/docs/queries/about#textmatch)
* which will match a text string broken across multiple elements.
* Useful for finding, e.g. "hello there" in <p>hello <b>there</b></p>
*/
export const matchTextAcrossElements =
(text: string) => (content: string, element: Element | null) => {
const hasText = (element) => element.textContent === text;
const elementHasText = hasText(element);
@itsravenous
itsravenous / package.json
Last active May 8, 2017 20:57
Node server which always 500s (with CORS support!)
{
"name": "thefamous500",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"express": "^4.15.2"
},
"scripts": {
"start": "node server.js"
@itsravenous
itsravenous / package.json
Created May 8, 2017 16:33
Stream live web cam video using Node.js and Gstreamer
{
"name": "streamingtest",
"version": "0.0.1",
"engines": {
"node": ">=0.6.0"
},
"dependencies": {
"express": "2.5.x",
"coffee-script": "1.2.x"
},
@itsravenous
itsravenous / resave-incomplete-classification.js
Created July 13, 2016 17:52
Resaving incomplete classification results in GET, not PUT
const api = require('panoptes-client/lib/api-client');
const auth = require('panoptes-client/lib/auth');
const credentials = {
login: process.env.PANOPTES_USER,
password: process.env.PANOPTES_PASSWORD,
}
auth.signIn(credentials)
.then(() => {
return api.type('classifications/incomplete').get();
})
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@itsravenous
itsravenous / test.html
Last active January 2, 2016 14:59
Psuedo-elements breaking elementQuery
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="test.css" type="text/css" />
</head>
<body>
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Blog</a></li>
@itsravenous
itsravenous / gist:2844052
Created May 31, 2012 15:12
Zepto.js - Adding touches object to data passed with tap events
$(document.body).bind('touchstart', function(e){
now = Date.now()
delta = now - (touch.last || now)
touch.el = $(parentIfText(e.touches[0].target))
touchTimeout && clearTimeout(touchTimeout)
touch.touches = e.touches // Store touch list
touch.x1 = e.touches[0].pageX
touch.y1 = e.touches[0].pageY
if (delta > 0 && delta <= 250) touch.isDoubleTap = true
touch.last = now