Skip to content

Instantly share code, notes, and snippets.

jbinto / getTitleNative.js
Created Jan 13, 2016
Get title from remote HTML URL - without jQuery
View getTitleNative.js
// Only using native browser features (no jQuery).
// Uses `fetch`, `DOMParser` and `querySelectorAll`.
const getTitle = (url) => {
return fetch(`${url}`)
.then((response) => response.text())
.then((html) => {
const doc = new DOMParser().parseFromString(html, "text/html");
const title = doc.querySelectorAll('title')[0];
return title.innerText;
jbinto /
Created May 5, 2015
Dealing with Ruby versions - chruby

Dealing with Ruby versions - chruby

Every time I sit down to code, it seems like a new Ruby version is available.

When I first learned ruby I used rvm on my Mac. In production on linux, I use rbenv, likely due to its Capistrano integration.

When I set up my current machine, I found rvm had fallen out of fashion in favour of something called chruby.

Install new ruby

jbinto / howto-recover-google-authenticator-keys.txt
Created Feb 8, 2014
Recovering Google Authenticator keys from Android device for backup
View howto-recover-google-authenticator-keys.txt
### Last tested February 7 2014 on a Galaxy S3 (d2att) running Cyanogenmod 11 nightly, with Google Authenticator 2.49.
### Device with Google Authenticator must have root.
### Computer requires Android Developer Tools and SQLite 3.
### Connect your device in USB debugging mode.
$ cd /tmp
$ adb root
$ adb pull /data/data/
jbinto / input.scss
Created Nov 9, 2020
Generated by
View input.scss
h2 {
:global([data-theme="fancy"]) :global([[data-color="pineapple"]]) & :global(em) {
display: none;
jbinto /
Last active Feb 20, 2020
Upgrading SSL certificate on Cloudfront

Upgrading SSL certificate on Cloudfront

Last year I set up with an SSL certificate on Amazon S3 / CloudFront.

Now, it's time to renew the certificate.

The first time was fraught with peril, but I eventually got it working.

This time I will document the steps to renew the cert. Most steps for a new installation would be omitted.

jbinto / index.jsx
Created Nov 28, 2015
Egghead tutorial - Getting Started with Redux - JSBin implementation
View index.jsx
/* global ReactRedux, Redux, ReactDOM */
// "Getting Started with Redux" (by Dan Abramov)
// This file on JSBin (by Jesse Buchanan):
View cypress_mocks.js
// option 1 to override fetch, using cypress built-in facilities (e.g. sinon)
// sinon syntax ⬇️
.stub(win, 'fetch')
// The pseudocode-ish that this generates, kinda like this:
const realFetch = window.fetch
window.fetch = (arg1) => {
jbinto /
Last active Jul 27, 2018
Cloudflare migration

Migrating an SSL site to CloudFlare

Overview has run on AWS CloudFront for the past year. Today I renewed the certificate, and while I waited for the manual approval, I wondered whether I could get CloudFlare running in "5 minutes" as advertised.

Signing up

I signed up for an account, and entered the domain.

jbinto / test.js
Created May 10, 2017 — forked from jbaxleyiii/test.js
react-apollo testing
View test.js
import { Component } from "react";
import { print } from "graphql-tag/printer";
import { graphql } from "react-apollo";
import { MockedProvider } from "react-apollo/test-utils";
import { addTypenameToDocument } from "apollo-client/queries/queryTransform";
import { mount } from "enzyme";
import { withSavedPayments, SAVED_ACCTS_QUERY } from "../";

I am deploying with this IAM using Codeship and Circle CI to Elastic Beanstalk. I had a lot of trouble with this config. I talked to the aws support for about 6 hours until this worked properly, so, I guess it is worth to share.

UPDATE: In the end, I have to use the AWSElasticBeanstalkFullAccess policy. My custom policy keep breaking every week with some new added permission or some EB internal change. Anyway, the IAM I was using is below.

This works for me with CircleCI and EB Cli.

    "Version": "2012-10-17",
    "Statement": [