Skip to content

Instantly share code, notes, and snippets.

View sbrichardson's full-sized avatar
:octocat:
In coding land

Stephen Richardson sbrichardson

:octocat:
In coding land
View GitHub Profile
@sbrichardson
sbrichardson / formikApollo.js
Created November 19, 2017 02:55 — forked from mwickett/formikApollo.js
Formik + Apollo
import React from 'react'
import { withRouter, Link } from 'react-router-dom'
import { graphql, compose } from 'react-apollo'
import { Formik } from 'formik'
import Yup from 'yup'
import FormWideError from '../elements/form/FormWideError'
import TextInput from '../elements/form/TextInput'
import Button from '../elements/form/Button'
import { H2 } from '../elements/text/Headings'
@sbrichardson
sbrichardson / Player.jsx
Created April 15, 2019 16:45 — forked from vincentriemer/Player.jsx
Player code for my Apple Music clone
// @flow
import * as React from "react";
import {
View,
StyleSheet,
Image,
Animated,
TouchableOpacity,
Text,
@sbrichardson
sbrichardson / opencv_blackfly.cpp
Created June 18, 2019 05:08 — forked from kevinhughes27/opencv_blackfly.cpp
A simple program showing how to capture from a Point Grey Research Camera and display the image using OpenCV
#include "FlyCapture2.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace FlyCapture2;
int main()
@sbrichardson
sbrichardson / opencv_blackfly.cpp
Created June 18, 2019 05:08 — forked from kevinhughes27/opencv_blackfly.cpp
A simple program showing how to capture from a Point Grey Research Camera and display the image using OpenCV
#include "FlyCapture2.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace FlyCapture2;
int main()
@sbrichardson
sbrichardson / clone-all-twitter-github-repos.sh
Created July 8, 2019 03:34 — forked from caniszczyk/clone-all-twitter-github-repos.sh
Clone all repos from a GitHub organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@sbrichardson
sbrichardson / what-forces-layout.md
Created December 9, 2019 01:42 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@sbrichardson
sbrichardson / what-forces-layout.md
Created December 9, 2019 01:42 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@sbrichardson
sbrichardson / plink-plonk.js
Created February 16, 2020 00:12 — forked from tomhicks/plink-plonk.js
Listen to your web pages
@sbrichardson
sbrichardson / MSWordHtmlCleaners.js
Created July 29, 2020 00:01 — forked from ronanguilloux/MSWordHtmlCleaners.js
2 js solutions to clean nasty MS Word HTML pasted in any CMS + 2 server-side tips
var CleanWordHTML = function ( str )
{
str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
@sbrichardson
sbrichardson / gist:10ff12d4823aa493fee523e277a1fcf5
Created November 12, 2020 02:37 — forked from alexandernl/gist:8090a79a7af4197c5f5571e8cc8c05b8
Convert daily New York Times frontpage to jpg
<?php
// set the output-file
$outputfile = "/var/www/nyt/nyt.jpg";
// set path to todays NYT frontpage
$pathToPdf="https://static01.nyt.com/images/".date('Y')."/".date('m')."/".date('d')."/nytfrontpage/scan.pdf";
// check if there is any today
$file_headers = @get_headers($pathToPdf);