Skip to content

Instantly share code, notes, and snippets.

View cpsubrian's full-sized avatar

Brian Link cpsubrian

  • Dropbox
  • Fremont, CA
View GitHub Profile
@cpsubrian
cpsubrian / HomeScene.js
Last active July 11, 2016 18:10
react-router-native dynamic header via redux
import React from 'react'
import {View, Image, Text, TouchableHighlight} from 'react-native'
import {Link} from 'react-router-native'
import Scene from 'core/components/scene/Scene'
import styles from './HomeScene.styles'
class HomeScene extends React.Component {
render () {
return (
@cpsubrian
cpsubrian / console.txt
Created July 21, 2016 17:47
react-native realm crash
2016-07-21 10:44:30.968 [error][tid:com.facebook.react.JavaScript] create@[native code]
file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:576:849
write@[native code]
save@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:576:816
u@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:578:451
save@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:578:1008
file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:573:511
f@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:301:187
d@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:301:1579
c@file:///var/containers/Bundle/Application/60FA3246-6B52-4A8A-B47E-D0AAB4D65D5B/ESA.app/main.jsbundle:301:435
@cpsubrian
cpsubrian / README.md
Last active March 27, 2023 13:34
React decorators for redux/react-router/immutable 'smart' components.

This is my typical decorator stack for a 'smart component' used as the component for react-router route. Note some code is missing here but this should give you the idea.

Example usage:

StateDetailsScene.js

import React from 'react'
import _ from 'lodash'
import route from 'core/decorators/route'
@cpsubrian
cpsubrian / README.md
Last active October 28, 2016 15:32
Styler - Meldium Launchpad

Styler Injector for Meldium Launchpad

Pasted the following into the styler JS area:

var gistUrl = 'https://gist.githubusercontent.com/cpsubrian/f9cd249f981c0870305421fb4d3a410c/raw';
$.get(gistUrl + '/styles.css?v=' + Date.now(), function (result) {
  $('#stylerStyle').after('<style>' + result + '</style>'); 
});
@cpsubrian
cpsubrian / README.md
Last active November 22, 2016 04:14
LetsEncrypt Auto Renewal Via Dgate

Note: You must edit [domain] and [dir] in the examples below.

Step 1. Double-check that dgate-ssl is loading the live certs.

Step 2. Create a script to renew the cert via an http standalone server. (Make sure it has execute permissions)

~/certbot-auto certonly\
  --standalone\
  --standalone-supported-challenges http-01\
 --http-01-port 3005\
@cpsubrian
cpsubrian / README.md
Last active December 6, 2023 11:03
Compile Xvfb for AWS Lamba
@cpsubrian
cpsubrian / regexSupplant.js
Created January 25, 2017 20:05
Create a regex from parts using a tagged template.
function regexSupplant (strings, ...values) {
let parts = []
while (strings.length || values.length) {
if (strings.length) {
parts.push(strings.shift()
.split('\n')
.map((val) => val.trim())
.join('')
)
}
@cpsubrian
cpsubrian / db.js
Last active June 13, 2023 06:59
Mock knex database for Jest
/* eslint-env jest */
import _ from 'lodash'
import path from 'path'
import fs from 'fs'
import callsites from 'callsites'
import knex from 'knex'
import hash from 'object-hash'
import conf from '<conf>'
// Get the db config.
@cpsubrian
cpsubrian / example.test.js
Created March 7, 2017 16:56
Chainable request helper for testing express apps with jest
import request from './request'
// Your express app (or router).
import app from './app'
it('can serve requests', () => {
return request
.app(app)
.post('/foo/bar')
.header({authorization: 'Bearer mytoken'})
@cpsubrian
cpsubrian / upload.js
Last active December 2, 2018 22:13
Upload files to S3 via node aws-sdk (if aws-cli isn't easily installable)
// Put credentials in ~/.aws/credentials like:
//
// [default]
// aws_access_key_id = [key]
// aws_secret_access_key = [secret]
if (process.argv.length !== 5) {
console.log('Usage: node ./upload.js [filepath] [bucket] [key]')
process.exit()
}