Skip to content

Instantly share code, notes, and snippets.


Marcus Shepherd marcusshepp

Block or report user

Report or block marcusshepp

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
marcusshepp /
Last active Aug 21, 2017
git diff without white space
git diff -w # ignores whitespace differences
# note that this will see no difference in "asc" and "a s c"
git diff --ignore-space-at-eol # ignores all space at the end of line
# this is most likely what you want.
# these options also work with git show
git show 2ert4d9 --ignore-all-space
git show 2ert4d9 --ignore-space-change
marcusshepp /
Created Aug 9, 2017
suppressing the possible error of a command
git log @{u}.. 2> /dev/null
# if git log fails, it will fail silently.
# 2> means redirecting the output of stderr.
marcusshepp /
Last active Aug 9, 2017
compare local branch git log to remote branch
git log @{u}..
# @{u} is a shortcut to the upstream branch that this current branch is tracking.
# .. specifies a range of commits.
# same as saying git log @{u}..HEAD
# comparing where HEAD is on this branch to where HEAD is on the remote tracked branch.s
marcusshepp /
Last active Nov 9, 2017
changing the permissions level of a folder
sudo chown -R $USER ~/projects/kaa-api/log
View rails_queries.rb
# rails 2.3.5
p = Promotion.find(:first, :conditions => ["subdomain = ?", "foobar"])
# to find based on multiple conditions based on multiple associations
User.find(:all, :include => [:contact, :promotion], :conditions => [' = ? and = ?', '', 22])
# to find last record in old rails apps, rails 2
p = Promotion.find(:all, :order => "id desc", :limit => 1) # newest first
# and in ascending order
p = Promotion.find(:all, :order => "id asc", :limit => 1) # oldest first
marcusshepp / promise.js
Last active Oct 28, 2016
js ajax promise
View promise.js
function ajax(type, url){
return new Promise(function(resolve, reject){
var http_request = new XMLHttpRequest();, ""+ url);
http_request.onload = function() {
if (http_request.status === 200){
} else {
marcusshepp / is_empty.js
Last active Oct 26, 2016
is object empty
View is_empty.js
function is_empty(obj){
return Object.keys(obj).length === 0;
// alternative
function isEmpty(object) {
for(var i in object) {
return true;
return false;
marcusshepp /
Created Oct 25, 2016
How to reset an app with an existing migration in production on postgres. Had a problem where I deployed a project with a new app with an initial migration. Then changed the migration in dev. Then redeployed with a different initial migration.
psql -h 999.999.99.99 -U web_forms web_forms
web_forms=> SELECT * from django_migrations;
web_forms=> DELETE FROM django_migrations WHERE id=28;
web_forms=> DROP TABLE room_change_request_type;
# drop all tables from that app
web_forms=> \q
./ migrate
marcusshepp / csrf
Created Sep 30, 2016
react django csrf middleware token component + jquery cookie function
View csrf
import React from 'react';
export default class DjangoCSRFToken extends React.Component {
var csrf_token = getCookie('csrftoken');
return (<input type="hidden" name="csrfmiddlewaretoken" value={ csrf_token }/>);
marcusshepp /
Last active Sep 28, 2016
setting up react and webpack dev server with hot module replacement


  "name": "todo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./node_modules/.bin/webpack-dev-server --inline --hot",
    "test": "echo \"Error: no test specified\" && exit 1"
You can’t perform that action at this time.