Skip to content

Instantly share code, notes, and snippets.

View alex-hall's full-sized avatar
😎
Just vibin'

Alex Hall alex-hall

😎
Just vibin'
View GitHub Profile
describe('The Basics', () => {
it('works the way you would expect', () => {
expect("Hello world. Replace me with the number one for your first passing test!").toEqual(1)
})
describe("Truthy v Falsy", () => {
beforeAll(() => {
//TODO: Go Read: https://www.sitepoint.com/javascript-truthy-falsy/
})
@alex-hall
alex-hall / promisify_and_jest_mocks.md
Last active December 29, 2022 17:07
How to mock a promisify'd method

Given an api that looks like this:

    this.client = redis.createClient()
    
    const asyncSet = promisify(this.client.set).bind(this.client)

    return asyncSet(key, value, "EX", expiry)
@alex-hall
alex-hall / install.sh
Created November 8, 2017 02:48
Bootstrapping Phoenix + Elixir
#Install the language
brew install elixir
#Install Elixir package manager
mix local.hex
#Check the version
elixir -v
#Get latest of Phoenix framework
@alex-hall
alex-hall / react_intro_2.js
Created October 29, 2017 19:52
More react drilling
const Card = (props) => {
return(
<div style={{margin: '1em'}}>
<img style={{width: 75}} src={props.avatar_url}/>
<div style={{ display: 'inline-block', marginLeft: 10}}>
<div style={{ fontSize: '1.25em', fontWeight: 'bold'}}>{props.name}</div>
<div>{props.company}</div>
</div>
</div>
)
@alex-hall
alex-hall / react_intro.js
Created October 29, 2017 18:46
Drilling React Syntax (via Pluralsight tutorial)
class Button extends React.Component{
handleClick = () => {
this.props.onClickFunction(this.props.incrementValue)
}
render() {
return (
<button onClick={ this.handleClick}>
+{this.props.incrementValue}
</button>
@alex-hall
alex-hall / gist:2f89a53db32828d72081227ae3cbb04e
Created October 29, 2017 18:46
Drilling React Syntax (via Pluralsight tutorial)
class Button extends React.Component{
handleClick = () => {
this.props.onClickFunction(this.props.incrementValue)
}
render() {
return (
<button onClick={ this.handleClick}>
+{this.props.incrementValue}
</button>
@alex-hall
alex-hall / sinatra_with_cors.rb
Last active July 19, 2017 14:02
Configure Sinatra for CORS (Whitelist from any domain, don't actually do this in production)
require 'sinatra'
set :server, 'webrick'
before do
response.headers['Access-Control-Allow-Origin'] = '*'
end
options '*' do
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, PATCH, DELETE, OPTIONS'