Skip to content

Instantly share code, notes, and snippets.

Avatar

John Laine johnlaine1

View GitHub Profile
@johnlaine1
johnlaine1 / app.js
Created Oct 10, 2017 — forked from verticalgrain/app.js
React Router V4 Redirect after form submission
View app.js
import React, { Component } from 'react'
import { Redirect } from 'react-router'
export default class ContactForm extends Component {
constructor () {
super();
this.state = {
fireRedirect: false
}
}
@johnlaine1
johnlaine1 / rectangleIntersection.js
Last active Mar 7, 2017
A function that finds the rectangle intersection of 2 rectangles
View rectangleIntersection.js
const findRangeOverlap = (point1, length1, point2, length2) => {
const highestStartPoint = Math.max(point1, point2);
const lowestEndPoint = Math.min(point1 + length1, point2 + length2);
if (highestStartPoint >= lowestEndPoint) {
return {startPoint: null, width: null};
}
const overlapLength = lowestEndPoint - highestStartPoint;
return {startPoint: highestStartPoint, overlapLength: overlapLength};
@johnlaine1
johnlaine1 / .gitconfig
Last active Aug 14, 2016
Sample .gitconfig file
View .gitconfig
[alias]
llog = log --oneline --abbrev-commit --all --graph --decorate --color
st = status
br = branch
co = checkout
View Git commands
# Useful git commands
git log --oneline --abbrev-commit --all --graph --decorate --color
View gulpfile.js
'use strict';
// Load our dependencies.
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var htmlMin = require('gulp-htmlmin');
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var lazypipe = require('lazypipe');
var gulpIf = require('gulp-if');
@johnlaine1
johnlaine1 / .bowerrc
Created Jun 5, 2016 — forked from Ehesp/.bowerrc
Gulp Workflow Snippet
View .bowerrc
{
"directory" : "src/assets/components"
}
@johnlaine1
johnlaine1 / new_gist_file
Created Aug 29, 2013
How to tar.gz a directory
View new_gist_file
$ tar cvzf archive_name.tar.gz dirname/
@johnlaine1
johnlaine1 / now.sh
Last active Dec 21, 2015
Add the current date to a file in linux.
View now.sh
now=$(date +"%m_%d_%Y")
touch my_file_$now
# Will output something like my_file_08_20_2013
# You can also do this, which will have the same results
touch my_file_$(date +"%m_%d_%Y")