Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
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
marcusshepp / kill_port.sh
Created Feb 26, 2016
how to kill a port on mac os x terminal
View kill_port.sh
lsof -i tcp:8000 # or what ever port # you need to search for
kill -9 <PID> # replace <PID> with the process PID you want to kill
@marcusshepp
marcusshepp / django_migration_function.py
Created Mar 11, 2016
How to create a function inside a Django migration file
View django_migration_function.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-03-11 23:37
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
def foo(apps, schema_editor):
@marcusshepp
marcusshepp / csrf.js
Last active Mar 11, 2016
Access CSRF token in external javascript file, using jquery.cookie.js
View csrf.js
// base.html
<script type="text/javascript">
$(document).ready(function(){
var csrf = "{% csrf_token %}";
$.cookie("csrfmiddlewaretoken", csrf);
});
</script>
// script.js
var csrf_func = function(){
@marcusshepp
marcusshepp / ssh_config
Created Mar 14, 2016
couldn't connect to aws ec2 instance
View ssh_config
# added this to
# ~/.ssh/config
Host ec2-52-38-4-225.us-west-2.compute.amazonaws.com
User ubuntu
IdentityFile ~/foobar.pem
IdentitiesOnly yes
@marcusshepp
marcusshepp / gunicorn.sh
Last active Mar 16, 2016
Django Gunicorn Daemon Script
View gunicorn.sh
# django gunicorn script
# Generates a Daemon process with Gunicorn.
# see processes with ps -aux
# tested on: Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-74-generic x86_64), aws ec2
# Runs on apps built with Django==1.9
# Marcus Shepherd <marcusshepdotcom@gmail.com>
# 3-12-16
NAME=project # REPLACE WITH BASE DIR NAME
@marcusshepp
marcusshepp / js_char_keycodes.js
Created Apr 8, 2016
javascript keycodes for chars and both delete btns
View js_char_keycodes.js
var keycode = event.which;
var valid_key = (keycode > 47 && keycode < 58) ||
(keycode > 64 && keycode < 91) ||
keycode == 8 || keycode == 48 ||
keycode == 190;
@marcusshepp
marcusshepp / ajax_request.js
Created Apr 10, 2016
Vanilla Javascript AJAX Function
View ajax_request.js
var http_request = new XMLHttpRequest();
http_request.open("GET", "{% url 'api_categories' %}");
http_request.send(null);
http_request.onreadystatechange = function(){
var DONE = 4;
var OK = 200;
if (http_request.readyState === DONE){
if (http_request.status === OK){
console.log(http_request.responseText);
} else {
@marcusshepp
marcusshepp / document_dot_ready.js
Created Apr 10, 2016
Vanilla Javascript's equivalent to jQuery's $(document).ready(function(){});
View document_dot_ready.js
document.addEventListener("DOMContentLoaded", function(){});
@marcusshepp
marcusshepp / changing_angular_template_tags.js
Created Apr 26, 2016
Angular: using different template tags
View changing_angular_template_tags.js
var app = angular.module("myfirstapp", []);
app.config(["$interpolateProvider", function($interpolateProvider){
$interpolateProvider.startSymbol("{[");
$interpolateProvider.endSymbol("]}");
}]);
@marcusshepp
marcusshepp / angular_get_request.js
Created Apr 26, 2016
Angular: Making a GET request
View angular_get_request.js
var foo_app = angular.module("foo_app", []);
foo_app.controller("bar_controller", ["$scope", "$http",
function ($scope, $http){
$http({
method: "GET",
url: "api/foo/bar/",
}).then(
function successCallback(response){
console.log(response);
You can’t perform that action at this time.