Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / angular_get_request.js
Created April 26, 2016 15:33
Angular: Making a GET request
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);
<!doctype html>
<html ng-app>
<head>
<title>My Angular App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
</head>
<body>
</body>
</html>
@marcusshepp
marcusshepp / pip_install_solution.py
Created May 2, 2016 13:37
when pip installing a requirements file fails on something stupid
# collects and installs each requirement fully one at a time.
# rather than collecting all packages then installing.
import pip
from subprocess import call
with open("requirements.txt", "r") as req:
for package in req:
call("pip install " + package, shell=True)
mkmanagementcommand(){
# creates a new management command
# arg1: app name
mkdir $1/management;
touch $1/__init__.py;
mkdir $1/management/commands;
touch $1/management/commands/__init__.py;
touch $1/management/commands/$2.py;
}
add_ci(){
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
// sleep(1000);
@marcusshepp
marcusshepp / is_ascii.js
Created May 2, 2016 15:06
Javascript check for non-ascii chars
function is_ascii(str){
for (var i = 0; i < str.length; i++)
if (str.charCodeAt(i) > 127)
return false;
return true;
}
@marcusshepp
marcusshepp / google_fonts.html
Created May 3, 2016 16:03
google fonts example
<!-- html -->
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Lato">
<!-- css -->
body{
font-family: 'Lato', serif;
font-size: 110%;
}
<!-- button to delete an object -->
<% @foo.each do |f| %>
<%= button_to 'delete', f, method: :delete %>
<% end %>
.foo{
animation: foo_ani 1s;
}
@keyframes foo_ani{
0%{
background-color: #53E889;
}
100%{
background-color: #AAF9C6;
@marcusshepp
marcusshepp / find_a_file.sh
Created May 11, 2016 17:22
Find a file in bash
find / -name foo.bar