Skip to content

Instantly share code, notes, and snippets.

View jonpemby's full-sized avatar

Jonathon Pemberton jonpemby

  • Chewy, Inc
  • Salem, MA
View GitHub Profile
@jonpemby
jonpemby / atom-scope.js
Created August 17, 2017 13:52
Get current scope in Atom
atom.workspace.getActiveTextEditor().getGrammar().scopeName
@jonpemby
jonpemby / AppServiceProvider.php
Created October 17, 2017 19:53
How to fix Laravel key length more than limit (Laravel ~5.5)
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Schema;
class AppServiceProvider extends ServiceProvider
{
@jonpemby
jonpemby / once.js
Created December 29, 2017 19:21
JavaScript once function
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
@jonpemby
jonpemby / Procfile
Created January 11, 2018 18:15
Heroku: Laravel Procfile (Apache)
web: vendor/bin/heroku-php-apache2 public/
@jonpemby
jonpemby / Procfile
Last active January 11, 2018 18:17
Heroku: Laravel Procfile (Nginx)
web: vendor/bin/heroku-php-nginx public/
@jonpemby
jonpemby / new-drupal-project.sh
Last active January 21, 2018 19:22
Starting a new Drupal project with Docker (SQLite)
#!/bin/bash
# Change directory to where you want to create your project.
# Composer's create-project command creates a project with
# a particular vendor package as the base into a provided directory
# You can change the project variable to the
# preferred folder name for your project
export project="project-name"
composer create-project drupal/drupal $project
@jonpemby
jonpemby / selectEnd.es6.js
Last active February 2, 2018 17:15
Select end of text in a contenteditable.
/**
* Selects the end of the text in an element. Useful for contenteditable elements.
* @param {HTMLElement} target
* @return {void}
*
* note: This function does not support browsers < IE9
*/
export default (target) => {
const range = document.createRange();
range.selectNodeContents(target);
@jonpemby
jonpemby / theme.info.yml
Created February 4, 2018 20:33
Theme info yml file for Drupal 8
name: Fluffiness
type: theme
description: 'A cuddly theme that offers extra fluffiness.'
core: 8.x
libraries:
- fluffiness/global-styling
base theme: classy
regions:
header: Header
content: Content
@jonpemby
jonpemby / substr_last.sql
Created March 1, 2018 17:16
Find last part of a string after delimiter in SQL
SELECT SUBSTRING_INDEX("first_middle_last", '_', -1);
@jonpemby
jonpemby / recursive_comments.sql
Created March 3, 2018 17:35
Recursive comments in PostgreSQL
with recursive co (id, parent_id, body) as
(select c.id, c.parent_id, c.body
from comments c
where c.id = 1
union all
select c.id, c.parent_id, c.body
from co
join comments c
on c.parent_id = co.id)
select * from co;