Skip to content

Instantly share code, notes, and snippets.

View schneidmaster's full-sized avatar

Zach Schneider schneidmaster

View GitHub Profile
@schneidmaster
schneidmaster / gilded_rose.rb
Created August 2, 2018 23:54
GildedRose kata
ITEM_AGED_BRIE = "Aged Brie".freeze
ITEM_BACKSTAGE_PASS = "Backstage passes to a TAFKAL80ETC concert".freeze
ITEM_SULFURAS = "Sulfuras, Hand of Ragnaros".freeze
class GildedRose
def initialize(items)
@items = items
end
def update_quality()
@schneidmaster
schneidmaster / setup.sh
Last active August 30, 2018 21:14
Environment Setup
# Sets up basic development environment for ruby and nodejs
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebrew basics
brew install adns apr apr-util archey aspell atk augeas autoconf automake aws-cfn-tools aws-elasticbeanstalk awscli boost cairo certbot clamav cmake convox coreutils dialog dos2unix doxygen ec2-api-tools elasticsearch erlang faac ffmpeg flow fontconfig freetds freetype gcc gd gdbm gettext gifsicle git glew glib gmp gnupg gnupg2 gnutls go gobject-introspection gource graphviz heroku htop htop-osx hub icu4c imagemagick isl jhead jpeg jpegoptim lame libassuan libevent libffi libgcrypt libgpg-error libidn2 libksba libmpc libpng libpq libtasn1 libtiff libtool libunistring libusb libusb-compat libvo-aacenc libxml2 libyaml libzip mcrypt memcached mhash mpfr mysql nettle node npth nvm openssl optipng overmind p11-kit pcre pgcli phantomjs php pinentry pinentry-mac pixman pkg-config prettyping pth python python3 python@2 qt r
@schneidmaster
schneidmaster / 1-useState.js
Last active October 29, 2018 21:44
React Conf 2018 -- new functional component APIs https://reactjs.org/docs/hooks-intro.html
// Basic example of useState.
import React, { useState } from 'react';
export default function Greeting(props) {
const [name, setName] = useState('Mary');
function handleNameChange(e) {
setName(e.target.value);
}
@schneidmaster
schneidmaster / react.d.ts
Last active October 31, 2018 17:08
Typescript definitions for React hooks
// Typescript definitions for React hooks
// Take with a grain of salt; these are a first attempt and I've only actually
// used a few so far :)
import { Context, RefObject } from 'react';
declare module 'react' {
export function useState<T>(initialValue: T): [T, (newState: T) => void];
export function useEffect(effect: Function, inputs?: Array<any>): void;
export function useMutationEffect(effect: Function, inputs?: Array<any>): void;
@schneidmaster
schneidmaster / MaskedInput.js
Created January 28, 2016 19:44
react-bootstrap + react-maskedinput
import React from 'react';
import classNames from 'classnames';
import { Input } from 'react-bootstrap';
import MaskedInputField from 'react-maskedinput';
export default class MaskedInput extends Input {
renderInput() {
const className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control';
return <MaskedInputField {...this.props} className={classNames(this.props.className, className)} ref="input" key="input" />;
}