Skip to content

Instantly share code, notes, and snippets.

View nicksheffield's full-sized avatar

Nick Sheffield nicksheffield

View GitHub Profile
@nicksheffield
nicksheffield / maybe-monad.js
Last active February 22, 2018 02:12
An attempt at implementing a maybe monad myself
const Maybe = function(val) {
this.__value = val instanceof Maybe ? val.__value : val
}
Maybe.from = function(val) {
return new Maybe(val)
}
Maybe.none = function() {
return new Maybe()
import React from 'react'
class MyComponent extends React.Component {
state = {}
componentWillMount() {}
componentDidMount() {}
componentWillUnmount()
componentWillReceiveProps(nextProps) {}
@nicksheffield
nicksheffield / watchercount.js
Created August 16, 2017 06:16
Count amount of watchers in angularjs
function getScopes(root) {
var scopes = []
function traverse(scope) {
scopes.push(scope)
if (scope.$$nextSibling)
traverse(scope.$$nextSibling)
if (scope.$$childHead)
traverse(scope.$$childHead)
}
traverse(root)
@nicksheffield
nicksheffield / p6.js
Last active April 20, 2017 03:09
My own approach at a p5 style canvas drawing library
// ----------------------------------------------------
// p6 Object
// ----------------------------------------------------
window.p6 = {
running: false,
ratio: 1,
size: {
w: 100,
h: 100
},
@nicksheffield
nicksheffield / paper-shadow.styl
Created March 31, 2017 01:49
Material design paper shadow mixin for Stylus
paperShadow(level = 1)
if level == 1
box-shadow 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)
else if level == 2
box-shadow 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)
else if level == 3
box-shadow 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)
else if level == 4
box-shadow 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)
else if level == 5
@nicksheffield
nicksheffield / project.sublime-project
Last active September 21, 2016 22:52
Laravel sublime project
{
"folders": [
{
"folder_exclude_patterns": [
"bootstrap",
"storage",
"tests",
"vendor",
"database/factories",
"resources/assets",
@nicksheffield
nicksheffield / .bash_profile
Created August 22, 2016 02:30
Modified copy of git bash
source ~/.git-prompt.sh
GIT_PS1_SHOWCOLORHINTS=true
PROMPT_COMMAND='__git_ps1 "\n\[$(tput setaf 6)\]\u \[$(tput setaf 3)\]\w\[$(tput sgr0)\]" "\[$(tput sgr0)\]\n> "'
@nicksheffield
nicksheffield / gulpfile.js
Created August 19, 2016 03:44
Gulp with sass or stylus
var gulp = require('gulp')
var minify = require('gulp-clean-css')
var autoprefix = require('gulp-autoprefixer')
var rename = require('gulp-rename')
var stylus = require('gulp-stylus')
var sass = require('gulp-sass')
var plumber = require('gulp-plumber')
var notify = require('gulp-notify')
var gulpif = require('gulp-if')
var path = require('path')
@nicksheffield
nicksheffield / average.js
Last active May 3, 2016 04:58
Get average number using Array.prototype.reduce
function avg(a) {
return a.reduce((s, n) => n = s + n) / a.length
}