Skip to content

Instantly share code, notes, and snippets.

View johnlaine1's full-sized avatar

John Laine johnlaine1

View GitHub Profile
<?php
/**
* This file will demonstrate a method to export fields to code.
* You can use this to easily create fields using the UI, export to code
* and then use in a custom module. Upon installation of the module
* your fields and instances will already be set up.
*/
// Create the fields you want using the Drupal UI.
// On the same site, go to example.com/devel/php
@johnlaine1
johnlaine1 / Flexbox Off Canvas Menu.markdown
Created April 24, 2016 22:28
Flexbox Off Canvas Menu
@johnlaine1
johnlaine1 / app.js
Created October 10, 2017 21:35 — forked from verticalgrain/app.js
React Router V4 Redirect after form submission
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 March 7, 2017 02:18
A function that finds the rectangle intersection of 2 rectangles
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 August 14, 2016 13:52
Sample .gitconfig file
[alias]
llog = log --oneline --abbrev-commit --all --graph --decorate --color
st = status
br = branch
co = checkout
# Useful git commands
git log --oneline --abbrev-commit --all --graph --decorate --color
@johnlaine1
johnlaine1 / gulpfile.js
Last active July 4, 2016 15:42
gulp example
'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 June 5, 2016 00:05 — forked from Ehesp/.bowerrc
Gulp Workflow Snippet
{
"directory" : "src/assets/components"
}
@johnlaine1
johnlaine1 / new_gist_file
Created August 29, 2013 03:05
How to tar.gz a directory
$ tar cvzf archive_name.tar.gz dirname/
@johnlaine1
johnlaine1 / now.sh
Last active December 21, 2015 15:39
Add the current date to a file in linux.
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")