Skip to content

Instantly share code, notes, and snippets.

Mandi Wise mandiwise

Block or report user

Report or block mandiwise

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mandiwise
mandiwise / Sync gh-pages + master branches
Last active Nov 17, 2019
Keep gh-pages up to date with a master branch
View Sync gh-pages + master branches
// Reference: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/
$ git add .
$ git status // to see what changes are going to be commited
$ git commit -m 'Some descriptive commit message'
$ git push origin master
$ git checkout gh-pages // go to the gh-pages branch
$ git rebase master // bring gh-pages up to date with master
$ git push origin gh-pages // commit the changes
@mandiwise
mandiwise / Update remote repo
Last active Nov 16, 2019
Transfer repo from Bitbucket to Github
View Update remote repo
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket
@mandiwise
mandiwise / Count lines in Git repo
Last active Nov 6, 2019
A command to calculate lines of code in all tracked files in a Git repo
View Count lines in Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@mandiwise
mandiwise / permutations.js
Last active Oct 29, 2019
Get all unique permutations of character strings in an array.
View permutations.js
let someChars = ['A', 'B', 'C', 'D'];
/**
* Handle all permutations for one array item (in relation to all other array items)
*/
function permutateAgainstOneItem(arr) {
let [first, ...tail] = arr;
let head = [first];
let permutations = [];
@mandiwise
mandiwise / seedData.js
Last active Aug 7, 2019
Generate seed data for Auth0 and MongoDB.
View seedData.js
require("dotenv").config();
const faker = require("faker");
const gravatarUrl = require("gravatar-url");
const mongoose = require("mongoose");
const auth0 = require("../config/auth0");
const initMongoose = require("../config/mongoose");
const Post = require("../models/Post");
const Profile = require("../models/Profile");
const Reply = require("../models/Reply");
@mandiwise
mandiwise / data.js
Last active Apr 17, 2019
Some sample movie data
View data.js
const data = {
people: [
{
id: 1,
name: "Mark Hamill",
birthday: "September 25, 1951",
placeOfBirth: "Oakland, California, USA",
bio:
"Mark Hamill is best known for his portrayal of Luke Skywalker in the original Star Wars trilogy.",
filmography: [1]
@mandiwise
mandiwise / Stop tracking directory in Git repo
Last active Feb 11, 2019
A command to stop tracking and entire directory in a Git repo
View Stop tracking directory in Git repo
// Reference: http://stackoverflow.com/questions/936249/stop-tracking-and-ignore-changes-to-a-file-in-git
$ git rm --cached -r <dir>
@mandiwise
mandiwise / Limit Gravity Forms Upload Size
Last active Jan 29, 2019
Set a maximum upload size for a Gravity Forms image field
View Limit Gravity Forms Upload Size
function limit_file_upload_size( $validation_result ) {
$form = $validation_result['form'];
foreach( $form['fields'] as &$field ){
// NOTE: Add a custom CSS class to your image upload field and grab onto it here...
if( strpos( $field['cssClass'], 'choose-file' ) === false )
continue;
@mandiwise
mandiwise / Dynamically Populate Gravity Forms Dropdown with CPT
Last active Dec 26, 2018
Using gform_pre_render_[form ID] for Auto-population
View Dynamically Populate Gravity Forms Dropdown with CPT
function populate_concept_nominees( $form ){
foreach ( $form['fields'] as &$field ){
// Set a custom CSS class for your field and grab onto it here
if ( $field['type'] != 'select' || strpos( $field['cssClass'], 'populate-concept' ) === false )
continue;
// Query parameters for get_posts
@mandiwise
mandiwise / dataFormatHelpers.js
Last active May 22, 2018
Function to help format data fetched from the R10 Graphcool API for a React Native SectionList.
View dataFormatHelpers.js
// Helper to format GraphQL data into section list data
export const formatSessionData = sessions => {
return sessions
.reduce((acc, curr) => {
const timeExists = acc.find(section => section.title === curr.startTime);
timeExists
? timeExists.data.push(curr)
: acc.push({ title: curr.startTime, data: [curr] });
return acc;
}, [])
You can’t perform that action at this time.