Skip to content

Instantly share code, notes, and snippets.

View schneidmaster's full-sized avatar

Zach Schneider schneidmaster

View GitHub Profile
@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 / 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 / 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()
# Problem: https://twitter.com/AtticusGF/status/935977894651691008
#
# Stage 1 has 7 disks
# Stage 2 has 16 disks (or 7 + 3^2)
# Stage 3 has 41 disks (or 16 + 5^2)
# Stage 4 has 90 disks (or 41 + 7^2)
# so for each stage, add the incrementor squared and then
# increase the incrementor by 2
# Print off every million to avoid wasting too much
# time with terminal output
@schneidmaster
schneidmaster / .tool-versions
Last active January 19, 2018 10:03
Elixir/Phoenix + CircleCI config
erlang 18.0
elixir 1.3.2
@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" />;
}
@schneidmaster
schneidmaster / policy.json
Created December 17, 2015 18:07
S3 policy to allow full access to a bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::BUCKET_NAME"
@schneidmaster
schneidmaster / SimpleHTTPServer.cs
Created September 23, 2015 22:34
Simple C# Webserver for Aha! access token
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Threading;
using System.Diagnostics;
Verifying I am +schneidmaster on my passcard. https://onename.com/schneidmaster