Skip to content

Instantly share code, notes, and snippets.

View gachecker.go
package main
import (
"fmt"
"strings"
)
type mapDiff struct {
a string
b string
View pubsub.js
/**
* @param { Function } reducer
* @param { Object } initialState
* @returns { Store } State
*/
function createPubSub() {
let messages = {};
/**
* Publish publishes messages
View tableflip.js
javascript:(function (d) {
var tables = d.getElementsByTagName('table'),
head = d.head || d.getElementsByTagName('head')[0],
styleElement = d.createElement('style'),
cssStr = '.table-flip {transition: 1s linear;transform: rotate(360deg);}';
styleElement.type = 'text/css';
styleElement.appendChild(d.createTextNode(cssStr));
head.appendChild(styleElement);
function toggleSpin() {
var i = 0,
@jgilless
jgilless / create-next-redux-app.js
Created Dec 7, 2017
Nextjs + Redux + React app with opinionated architecture.
View create-next-redux-app.js
const fs = require('fs');
const { execSync } = require('child_process');
if (!process.argv[2]) {
console.log('useage: node create-next-app.js <appname>');
process.exit(1);
}
const rootFolder = process.argv[2];
@jgilless
jgilless / create-next-redux-app.sh
Last active Dec 7, 2017
Create Next App, instant regret writing it in bash not node.
View create-next-redux-app.sh
#!/bin/bash
if [ -z "$1" ]
then
echo "No argument supplied"
exit 1
fi
mkdir $1 && cd $1
View use-case-example.md

Use Case: Name of Use Case

Actors

  • List of all actors involved in the use case
  • Each actor should be distinct
  • Generalize to User and System before getting specific
  • Refer to each actor exactly as listed here through the rest of the document

Brief

Provide a brief overview (~paragraph) of what the use case includes. Roughly equivalent to a user story or an epic.

@jgilless
jgilless / application_helper.rb
Last active Aug 29, 2015
Application Helper for Blog Post
View application_helper.rb
module ApplicationHelper
def markdown(text)
render_options = {
#do not allow any user-inputted HTML in the output.
filter_html: true,
#do not generate any <img> tags.
#no_images: true,
#do not generate any <a> tags.
#no_links: true,
#do not generate any <style> tags.
@jgilless
jgilless / euler3.rb
Created Nov 14, 2014
Ruby solution for Project Euler problem 3
View euler3.rb
# https://projecteuler.net/problem=3
puts "Find the largest prime factor of:"
STDOUT.flush #clears the buffer
max_num = Integer(gets.chomp)
def largest_prime_factor(num)
largest_factor = 1
#get rid of factors of 2
@jgilless
jgilless / euler2.rb
Last active Aug 29, 2015
Ruby solution for Project Euler problem 2
View euler2.rb
# https://projecteuler.net/problem=2
puts "Find the sum of even valued Fibonnaci terms which values do not exceed:"
STDOUT.flush #clears the buffer
num = Integer(gets.chomp)
def fibonacci(max_num)
fibonacci = [1,2] #first two numbers of the sequence
while fibonacci[-2] + fibonacci[-1] < max_num
fibonacci << fibonacci[-2] + fibonacci[-1] # next num in sequence
@jgilless
jgilless / euler1.rb
Last active Aug 29, 2015
Ruby solution for Project Euler problem 1
View euler1.rb
# https://projecteuler.net/problem=1
puts "Find the sum of all the multiples of 3 or 5 below which number?"
STDOUT.flush #clears the buffer
max_num = Integer(gets.chomp)
def sum_x3_x5(num)
sum = 0
(1..num).each do |n|
sum = sum + n if (n % 3 == 0) || (n % 5 == 0) #Add if n is divisible by 3 or 5