Skip to content

Instantly share code, notes, and snippets.


emily dela cruz emdecr

View GitHub Profile
JamieMason /
Created Sep 14, 2018
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value


const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
csknk / Cors.php
Last active Dec 6, 2019
Set up CORS on a Laravel API to respond to an Axios request with an 'OPTIONS' preflight.
View Cors.php
// app/Http/Middleware/Cors.php
// It's possible to generate the file with artisan (see comment)
namespace App\Http\Middleware;
use Closure;
class Cors
bpmore / kill-fusion.php
Created Apr 6, 2017
remove fusion builder shortcodes
View kill-fusion.php
add_filter('the_content', 'remove_fusion_shortcodes', 20, 1);
function remove_fusion_shortcodes( $content ) {
$content = preg_replace('/\[\/?fusion.*?\]/', '', $content);
return $content;
**Tested with WP All Import and Export**
benwells / reduce-example.js
Created May 12, 2016
Using Array.reduce to sum a property in an array of objects
View reduce-example.js
var accounts = [
{ name: 'James Brown', msgCount: 123 },
{ name: 'Stevie Wonder', msgCount: 22 },
{ name: 'Sly Stone', msgCount: 16 },
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages
// get sum of msgCount prop across all objects in array
var msgTotal = accounts.reduce(function(prev, cur) {
return prev + cur.msgCount;
chrismccoy / restapi.txt
Last active Apr 15, 2020
WordPress REST API Resources
View restapi.txt
Allow ALL cross origin requests to WordPress REST API
WordPress theme using Rest API and Vue.js
WordPress Post from Front End using REST API and Vue.js
An offline-first SPA using Vue.js, the WordPress REST API and Progressive Web Apps
wizioo /
Last active Feb 22, 2021
HowTo have specific .gitignore for each git branch

How to have specific .gitignore for each git branch


My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.


My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.

Chandler /
Last active Feb 24, 2021
Download Slack Channel/PrivateChannel/DirectMessage History
# MIT License
# Copyright (c) 2016 Chandler Abraham
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
PurpleBooth /
Last active Feb 27, 2021
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


luislavena /
Last active Jan 18, 2021
Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)

SSL upgrades on and RubyInstaller versions

UPDATE 2016-12-01: Please refer to the official guide instead of this process.

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


jonathantneal /
Last active May 22, 2020
Local SSL websites on macOS Sierra

Local SSL websites on macOS Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\"