Skip to content

Instantly share code, notes, and snippets.

View CAYdenberg's full-sized avatar

Casey Ydenberg CAYdenberg

View GitHub Profile
@CAYdenberg
CAYdenberg / index.html
Created November 1, 2018 20:14
Using React in a script tag (simple working example)
<!doctype html>
<html>
<body>
<input type="date" id="date-input" />
<div id="date-picker"></div>
<script type="text/javascript" src="https://unpkg.com/react@16.0.0/umd/react.production.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/react-dom@16.0.0/umd/react-dom.production.min.js"></script>
<script type="text/javascript" src="https://momentjs.com/downloads/moment.js"></script>
<script type="text/javascript" src="/index.js"></script>
/*
** Simple CSS loader. Since font-size and color are both inherited, you can drop this
** anywhere and it should just work.
*/
.loading {
display: inline-block;
width: 1em;
height: 1em;
border-radius: 50%;
@CAYdenberg
CAYdenberg / sow.md
Last active March 9, 2018 00:01 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Statement of Work

Between [company name]

And [customer name].

Summary:

We’ll always do our best to fulfill your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@CAYdenberg
CAYdenberg / index.js
Created February 25, 2017 17:30
Web task demo - countdown api
"use latest"
const moment = require("moment");
/* When used with Webtask (https://webtask.io)
creates a simple API that returns the number of days between now
and the given `date`.
e.g. https://address.run.webtask.io/index?date=20180225
@CAYdenberg
CAYdenberg / executeWhenVisible.jquery.js
Created December 16, 2016 23:58
Execute callbacks when element scrolls into view
$.fn.executeWhenVisible = function() {
var _this = this;
var callbacks = [].slice.call(arguments);
var executed = false;
$(window).on('scroll', function onScroll() {
var relativeScroll = $(this).scrollTop() + $(this).height() - _this.offset().top;
if (!executed && relativeScroll > 0) {
executed = true;
callbacks.forEach(function(callback) {
@CAYdenberg
CAYdenberg / load.js
Last active December 16, 2016 23:58
function injectScript(url, id) {
var js;
if (document.getElementById(id)) {
return;
}
js = document.createElement('script');
js.id = id;
js.async = true;
js.src = url;
js.charset = 'utf-8';
@CAYdenberg
CAYdenberg / test.cj
Created April 6, 2016 19:15
Fibonacci function in clojure
(defn fibonacci
([max sofar]
(def nextnum (+ (first (rseq sofar)) (second (rseq sofar))))
(if (< nextnum max)
(fibonacci max (conj sofar nextnum))
sofar))
([max]
(fibonacci max [1, 1])))
@CAYdenberg
CAYdenberg / number_shuffle.rb
Last active November 23, 2015 23:22
General solution to the Number Shuffle problem
# from https://rubymonk.com/learning/books/1-ruby-primer/problems/154-permutations
# Problem statement: Given a 3 or 4 digit number with distinct digits, return a sorted array of all the unique numbers that can be formed with those digits.
# This solution will work for any number (within limits of memory and stack depth)
def number_shuffle(number)
digits = number.to_s.split('')
if digits.length == 1
return [number]
end
combinations = []