Skip to content

Instantly share code, notes, and snippets.

View ryanbrainard's full-sized avatar

Ryan Brainard ryanbrainard

View GitHub Profile
@ryanbrainard
ryanbrainard / 0.demo.php
Last active November 15, 2018 02:11
PHP Class <-> JSON Serialization/Deserialization with Static & Dynamic Comparison
<?php
class Car
{
private $brand;
private $model;
private $year;
public function __construct($brand, $model, $year)
{
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE LexicalResource SYSTEM "DTD_LMF_REV_16.dtd">
<LexicalResource dtdVersion="16">
<GlobalInformation>
<feat att="label" val="한국어기초사전 - 국립국어원 제공" />
<feat att="creationDate" val="2017/05/30 03:06:04" />
<feat att="languageCoding" val="ISO 639-3" />
</GlobalInformation>
<Lexicon>
<feat att="language" val="kor" />
@ryanbrainard
ryanbrainard / file1.txt
Created January 12, 2017 06:31
the description for this gist
String file contents
@ryanbrainard
ryanbrainard / Profile.jsx
Created December 20, 2015 02:01
PromiseStateContainer Usage Example
import React, { Component, PropTypes } from 'react'
import { connect, PromiseState } from 'react-refetch'
import PromiseStateContainer from './PromiseStateContainer'
export default class Profile extends Component {
render() {
const { userFetch, likesFetch } = this.props
return (
<PromiseStateContainer
@ryanbrainard
ryanbrainard / PromiseStateContainer.jsx
Last active May 19, 2022 13:17
Example PromiseStateContainer
import React, { Component, PropTypes } from 'react'
import { connect, PromiseState } from 'react-refetch'
import LoadingAnimation from './LoadingAnimation'
import ErrorBox from './ErrorBox'
class PromiseStateContainer extends Component {
static propTypes = {
ps: PropTypes.instanceOf(PromiseState).isRequired,
onPending: PropTypes.func,
onNoResults: PropTypes.func,
@ryanbrainard
ryanbrainard / cache
Last active April 23, 2020 22:47
Bash Cache
#!/bin/sh
# forked from http://stackoverflow.com/a/11901300/129492
if [ $# == 0 ] || [ $1 == '-h' ] || [ $1 == '--help' ]; then
echo 'cache - cache the output of a command'
echo
echo 'Usage: cache [options] <command>'
echo
echo 'Options:'
echo ' -r, --reset [command]'
@ryanbrainard
ryanbrainard / gist:9765354
Last active August 29, 2015 13:57
Example of using `_HttpMethod=PATCH` query param with clients that do not support `PATCH`.
> POST /services/data/v29.0/sobjects/Component__c/a1IV0000000MN90MAG?_HttpMethod=PATCH HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
> Host: cs12.salesforce.com
> Accept: */*
> X-PrettyPrint: 1
> Authorization: Bearer REDACTED
> Content-Type: application/json
> Content-Length: 20
>
* upload completely sent off: 20 out of 20 bytes
@ryanbrainard
ryanbrainard / dataclip-column
Last active January 4, 2016 18:59
Script for extracting a single column from a Heroku Dataclip. Designed for piping into commands like xargs. Requires jq be installed.
#!/usr/bin/env bash
error() {
printf "$1\n" >&2
exit 1
}
[[ $# -eq 0 ]] && error "Usage: `basename $0` hash column [row(s)]"
hash=${1?'Must provide Dataclip hash'}
@ryanbrainard
ryanbrainard / 0 Visualforce Page
Last active December 26, 2015 11:59
Force.com Code Samples
<apex:page standardController="Invoice__c" sidebar="false" showHeader="false" >
{!Invoice__c.name}<br/>
{!Invoice__c.Status__c}
<ul>
<apex:repeat value="{!Invoice__c.Line_Items__r}" var="item">
<li>{!item.name}</li>
</apex:repeat>
</ul>
</apex:page>
<?xml version="1.0" encoding="UTF-8"?>
<Profile xmlns="http://soap.sforce.com/2006/04/metadata">
<recordTypeVisibilities>
<default>true</default>
<personAccountDefault>true</personAccountDefault>
<recordType>MyObject__c.A</recordType>
<visible>true</visible>
</recordTypeVisibilities>
<recordTypeVisibilities>
<default>false</default>