Skip to content

Instantly share code, notes, and snippets.

@chris-muller
chris-muller / compareObjects
Created July 28, 2017 05:27
Compare two objects
function compare(newField, oldField) {
var isClean = true;
for (var property in newField) {
if (!newField.hasOwnProperty(property)) { continue; }
if(property == 'options') {
const newOptions = newField.options;
const oldOptions = oldField.options;
@chris-muller
chris-muller / create.js
Created November 27, 2017 22:35
Sequelize Insert With Association
// Example of how to insert a record that includes a new association to be created with it
// assumes that sequelize and the associations have already been configured earlier.
var data = {
title: "Post title",
description: "Post description",
categories: [{
title: "General",
description: "The default category."
}]
@chris-muller
chris-muller / git-cheatsheet
Created September 2, 2018 23:41
Basic git commands
# Merge changes from one branch to another
git checkout master
git merge origin/hotfix
# Reset local to match the server
git fetch --all
@chris-muller
chris-muller / entries_view.sql
Created September 26, 2018 00:12
SQL View that has a conditional column, simplifying other complex queries
CREATE VIEW "view_entries" AS
-- Approved Entries
SELECT
"entries"."id",
"entries"."awardId",
"entries"."categoryId",
"entries"."userId",
CASE
@chris-muller
chris-muller / example.js
Last active September 17, 2019 04:31
Easy way to keep track of the $1, $2, $3, etc count inside an SQL query when working with loops, etc
import Bind from './sql-bind-incrementor.js'
const bind = new Bind()
const limit = 10
const queryValues = ['id_value', 'order_id_value']
const item_ids = ['aaa', 'bbb', 'ccc']
let sql = `
# Script for building and exporting iOS project
workspace_name=xxxx
scheme_name=xxxx
current_dir=$(dirname $0)
root_dir=$current_dir/..
archive_path=$root_dir/build/ios/archive/$workspace_name.xcarchive
export_path=$root_dir/build/ios/export
echo "Recreating build folder"