Skip to content

Instantly share code, notes, and snippets.

View lewisf's full-sized avatar

Lewis Chung lewisf

  • San Francisco, CA
View GitHub Profile
@lewisf
lewisf / erlang-elixir-on-amazon-linux.md
Last active September 28, 2020 02:44 — forked from techgaun/erlang-elixir-on-amazon-linux.md
Running elixir 1.10.4 on amazon linux

Script

#!/bin/bash

sudo yum install gcc gcc-c++ make libxslt fop ncurses-devel openssl-devel *openjdk-devel unixODBC unixODBC-devel -y

cd /tmp
wget "http://erlang.org/download/otp_src_23.1.tar.gz" -O otp23.1.tar.gz
tar xfz otp23.1.tar.gz
@lewisf
lewisf / gist:0425157c0ec3562bace6626df4ba114a
Last active February 6, 2019 23:42 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
cut -d/ -f2- |
xargs git push origin --delete
@lewisf
lewisf / .vimrc
Created November 17, 2018 09:14
lewisf vimrc
set nocompatible
filetype off
syntax enable
" set pyx=3
set backspace=indent,eol,start
" On pressing tab, insert 2 spaces
set expandtab
" show existing tab with 2 spaces width
set tabstop=2
@lewisf
lewisf / logdna docker
Created May 15, 2018 19:34
Commands to get LogDNA rsyslog setup in a container
RUN wget -O /etc/ld-root-ca.crt http://repo.logdna.com/syslog/ld-root-ca.crt
RUN echo $'### START LogDNA rsyslog logging directives ###\n\
\n\
## TCP TLS only ##\n\
$DefaultNetstreamDriverCAFile /etc/ld-root-ca.crt # trust these CAs\n\
$ActionSendStreamDriver gtls # use gtls netstream driver\n\
$ActionSendStreamDriverMode 1 # require TLS\n\
$ActionSendStreamDriverAuthMode x509/name # authenticate by hostname\n\
$ActionSendStreamDriverPermittedPeer *.logdna.com\n\
## End TCP TLS only ##\n\
@lewisf
lewisf / ssr-react-apollo-7.js
Created September 13, 2017 23:15
How SSR Works in React Apollo Code Example 7
function asyncAction(dispatchFn) {
return function(Component) {
class AsyncAction extends React.Component {
static displayName = `Action(${Component.displayName})`
fetchData() {
return dispatchFn(props, dispatch);
}
render() {
return <Component {...this.props} />
@lewisf
lewisf / ssr-react-apollo-6.jsx
Last active September 13, 2017 23:14
How SSR Works in React Apollo Code Example 6
class UserImage extends React.Component {
render() {
return (
<div>
<img src={this.props.userImageUrl} />
</div>
);
}
}
@lewisf
lewisf / ssr-react-apollo-5.jsx
Created September 13, 2017 23:13
How SSR Works in React Apollo Code Example 5
class UserImageLoader extends React.Component {
constructor() {
if (window == undefined) { this.fetchData() }
}
fetchData() {
return dispatch(loadUserImage(this.props.userId));
}
render() {
@lewisf
lewisf / ssr-react-apollo-4.jsx
Last active November 13, 2017 00:20
How SSR Works In React Apollo Code Example 4
class UserImage extends React.Component {
constructor() {
if (window !== undefined) { this.fetchData() }
}
fetchData() {
return dispatch(loadUserImage(this.props.userId));
}
render() {
@lewisf
lewisf / ssr-react-apollo-3.jsx
Last active November 13, 2017 00:21
How SSR works in React Apollo Code Example 3
class UserImage extends React.Component {
constructor() {
// getDataFromTree from react-apollo will call the
// constructor and fetchData automatically so there's
// no need to call it during SSR. This is here
// so if the app is being rendered on the client,
// it will still know to call fetchData.
if (window !== undefined) { this.fetchData() }
}
@lewisf
lewisf / ssr-react-apollo-2.jsx
Created September 13, 2017 23:10
how-ssr-works-in-react-apollo
function loadUserImageUrlAction(userId) {
return function(dispatch) {
return fetch(USER_IMAGE_API)
.then(
res => res.json(),
err => console.log('An error has occured.', err)
)
.then(json => {
dispatch(receiveUserImage(json));
})