Skip to content

Instantly share code, notes, and snippets.

View mandiwise's full-sized avatar

Mandi Wise mandiwise

  • Edmonton, Canada
View GitHub Profile
@mandiwise
mandiwise / Count lines in Git repo
Last active April 19, 2024 02:22
A command to calculate lines of code in all tracked files in a Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@mandiwise
mandiwise / Update remote repo
Last active April 17, 2024 07:41
Transfer repo from Bitbucket to Github
// 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 / Sync gh-pages + master branches
Last active January 6, 2024 21:57
Keep gh-pages up to date with a master branch
// 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 / Stop tracking directory in Git repo
Last active April 11, 2023 16:28
A command to stop tracking and entire directory in a 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 / Dynamically Populate Gravity Forms Dropdown with CPT
Last active March 22, 2023 12:40
Using gform_pre_render_[form ID] for Auto-population
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 / seedData.js
Last active April 24, 2022 12:11
Generate seed data for Auth0 and MongoDB.
// Usage (from `server` directory):
// $ node -r dotenv/config -r esm src/scripts/seedData.js <PASSWORD>
import faker from "faker";
import gravatarUrl from "gravatar-url";
import mongoose from "mongoose";
import auth0 from "../config/auth0";
import initMongoose from "../config/mongoose";
import Post from "../models/Post";
@mandiwise
mandiwise / init-letsencrypt.sh
Last active February 26, 2022 04:21
Create dummy certificates to start up nginx so it can request real certificate from Let's Encrypt
#!/bin/bash
# Usage:
# $ chmod +x init-letsencrypt.sh
# $ init-letsencrypt.sh mydomain.com bob@email.com 1
#
# Reference:
# https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
domain=${1}
@mandiwise
mandiwise / Limit Gravity Forms Upload Size
Last active January 16, 2022 14:12
Set a maximum upload size for a Gravity Forms image field
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 / db.json
Created April 29, 2021 02:04
Sample book, author, and user data to be use with JSON Server.
{
"authors": [
{
"name": "Chinua Achebe",
"id": 1
},
{
"name": "Douglas Adams",
"id": 2
},
@mandiwise
mandiwise / lexer.py
Created April 5, 2021 19:29
Mostly working JSX lexer for Pygments
# -*- coding: utf-8 -*-
"""
pygments.lexers.jsx
~~~~~~~~~~~~~~~~~~~~
Lexers for JSX formats.
Based on https://github.com/fcurella/jsx-lexer
"""
import re