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 / 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 / example-equivalent.coffee
Created November 20, 2011 04:35
Parse readable string vows into should.js assertions
###
This is what the below example produces.
###
vows = require 'vows'
should = require 'should'
# Create the test suite.
suite = vows.describe('QuickVows')
# Test quickVows
@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 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 / AppDelegate.m
Created July 5, 2016 19:55
Auto-IP Detection React-Native 0.28.0
// ...
NSURL *jsCodeLocation;
/**
* This Replaces the regular OPTION1/OPTION2 business with the hard-coded IPs.
* @see https://gist.github.com/cpsubrian/5f3acf2b9ed1212ee33703a6bee63737
* @see http://moduscreate.com/automated-ip-configuration-for-react-native-development/
* @see https://github.com/facebook/react-native/pull/4681/files
*/
#define AUTO_IP
@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 / 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 / README.md
Last active March 15, 2016 20:31
Redux folder structure

Organize by Verb

  • actions/
    • campaigns.js
  • components/
    • Campaign.js
    • Campaigns.js
  • models/
    • campaign.js
  • reducers/
@cpsubrian
cpsubrian / package.json
Created March 15, 2016 20:15
Symlink app root alias in package.json
{
"name": "example",
"scripts": {
"postinstall" : "node -e \"var s='../src/js',d='node_modules/@app',fs=require('fs');fs.exists(d,function(exists){exists||fs.symlinkSync(s,d,'dir')});\""
}
}
@cpsubrian
cpsubrian / model.js
Last active March 8, 2016 19:57
Immutable.Record for models
import _ from 'lodash'
import idgen from 'idgen'
import {List, Map, Record} from 'immutable'
import serialize from '../lib/serialize'
// Wraps a schema to provide the default values that an Immutable Record needs.
export default function CreateModel (schema, name = 'Model') {
// Create a 'defaults' object for the Record factory.
let defaults = _.reduce(schema, (result, opts, key) => {
return _.extend(result, {