Skip to content

Instantly share code, notes, and snippets.

View bowheart's full-sized avatar
💥
Having a blast

Josh C bowheart

💥
Having a blast
View GitHub Profile
@bowheart
bowheart / zip-autofill.js
Last active October 20, 2016 15:10
Filling out forms can be tedious stuff. This library will autofill city and state fields in a form when the user enters their zipcode. Makes use of the Google Maps API.
/**
* Another library by Joshua Claunch
* https://github.com/bowheart
* https://gist.github.com/bowheart
*
* A jQuery-dependent secret intelligence library. :O
*/
(function() {
var Autofiller = function(zipInput, cityInput, stateInput, phoneInput) {
@bowheart
bowheart / input-confirmation.js
Last active October 20, 2016 15:07
When the user is filling out input fields, it's nice to have some visual feedback. This library performs non-strict input validation. It highlights fields red or green and animates a little 'x' or checkmark in from the right. This helps the user know if they made a mistake and encourages them to keep going.
/**
* Another library by Joshua Claunch
* https://github.com/bowheart
* https://gist.github.com/bowheart
*
* A jQuery-dependent form feedback library.
*/
$(function() {
var fontIsLoaded = function(fontName, content, callback) {
@bowheart
bowheart / input-filter.js
Created January 11, 2016 20:13
Some things just don't look good without a mask. This library enables easy input masking, turning ugly 5555555555 into beautiful (555) 555-5555. It also provides integrated regex-based input filtering as well as length limiting.
/**
* Another library by Joshua Claunch
* https://github.com/bowheart
* https://gist.github.com/bowheart
*
* A jQuery-dependent input masking/filtering/limiting library.
*
* class Masker
* Makes input fields more intelligent. Handles three data-* attributes on input elements:
* 1) data-filter -- A regex whitelist. Anything not in this whitelist is discarded.
/**
* LiteBox -- version 0.1.1 -- Jan. 22, 2016
*
* Another library by Joshua Claunch
* https://github.com/bowheart
* https://gist.github.com/bowheart
*
* A jQuery-dependent/integrated lightbox library
*/
(function($) {
var drawCanvas = function() {
var time,
mouse = {x: 0, y: 0};
var Star = function(ctx, width, height) {
this.ctx = ctx;
this.height = height;
this.width = width;
Math.random() > height / width * .5
? (this.x = parseInt(Math.random() * width)) && (this.y = 0)
@bowheart
bowheart / Sasser.php
Created November 8, 2016 15:44
A few sass-style functions for color manipulation in php
<?php
class Sasser {
private $hexChars = array('a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15);
public function toRGB($hex) {
if (is_array($hex)) return $hex;
if (substr($hex, 0, 1) === '#') $hex = substr($hex, 1);
if (strlen($hex) === 3) $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
@bowheart
bowheart / fire3d.js
Created November 8, 2016 15:55
A 3d fire shader
var fragmentShader = `
#define PI 3.1415926535897932384626433832795
uniform float u_time;
uniform vec2 u_res;
float range01(float num) {
return .5 + .5 * sin(num);
}
float getRed(vec2 xy) {
@bowheart
bowheart / redux-with-react-zedux.jsx
Created March 13, 2018 01:47
Provide and consume a Redux store with React Zedux
import React from 'react'
import { createContext } from 'react-zedux'
import { createStore } from 'redux'
import rootReducer from './reducers'
const store = createStore(rootReducer)
const Context = createContext(store)
const App = () => (
<Context.Provider>
@bowheart
bowheart / rxjs-with-react-zedux.jsx
Created March 13, 2018 18:27
A simple ticking clock example with React, RxJS, and React Zedux
import React from 'react'
import { Observable } from 'rxjs'
import { createContext } from 'react-zedux'
const tick$ = Observable.interval(1000)
const TickContext = createContext(tick$)
const App = () => (
<TickContext.Provider>
<Clock />
@bowheart
bowheart / machine.js
Created February 23, 2022 16:05
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions