Super Simple Router for React Without Any Dependencies
Here is some very simple code to render React components dynamically without using a framework or routing library. It doesn't cover pushState and URL parsing, so in that sense it isn't a routing library. But it does let you render components from othe...
Written by Sean Behan on 11/16/2018
How to Reset and Clear a Form Field or Textarea with Stateless Components in React
Stateless components are nice. They are simple to use and understand but can become tricky when you start thinking about data and how to manage state. In general, the consensus seems to be that if your UI is going to need state, then at least the componen...
Written by Sean Behan on 10/21/2018
How to Extract all Images from a Webpage with Ruby
Here is a little ruby snippet that will download all pictures from a webpage. Rather than using XPath, we are going to first reduce the source code to capture everything inside of quotes. Some websites use JSON w/in a script tag to lazy load images an...
Written by Sean Behan on 08/01/2018
How to Filter or Search HTML with Vanilla Javascript - No JQuery Required
The basic approach is to use the `document.querySelectorAll` to match certain elements, then manually set the display property to 'none' or 'block' (or 'inline-block') to hide or show it. Using the `match` method allows us to detect whether or not the sea...
Written by Sean Behan on 01/30/2018
How to Read Response Body HTML with Javascript Fetch Method with React Native
In React Native you see a lot of tutorials and articles using the `fetch` method when interacting with `JSON` APIs. It's great for this and the the pattern looks like this fetch(url).then((resp)=>{ return resp.json() }).then((json)=>{ console.log(json...
Written by Sean Behan on 07/17/2017
How to Fix xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
I just got a new machine and downloaded XCode. I used git to clone my ReactNative project from Github. I have everything ready to go. But when I run `react-native run-ios` I see xcrun: error: unable to find utility "instruments", not a developer tool ...
Written by Sean Behan on 03/05/2017
Pretty Formatted JSON from the Command Line
Sometimes you want to see JSON from the command line. I'm sure there are better tools for the job, but here is a little snippet you can throw in your ~/.bash_profile. function json { curl -s "$1" | python -mjson.tool; } Usage json https://g...
Written by Sean Behan on 08/21/2013
Parse for Links with Prototype JS
Parsing for links with the Prototype javascript library is easy. Here is the pattern for finding links /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^ =%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/ And to implement it you can loop through your con...
Written by Sean Behan on 06/17/2012