Skip to content

Instantly share code, notes, and snippets.

View manderly's full-sized avatar

Mandi Burley manderly

View GitHub Profile
@manderly
manderly / bashrc_customizations
Created February 13, 2015 18:56
.bashrc customization to show computer name, current directory path, and current git branch
#Add this to the bottom of your .bashrc file and run source ~/.bashrc
#thanks to
#http://www.ibm.com/developerworks/linux/library/l-tip-prompt/ and
#http://martinfitzpatrick.name/article/add-git-branch-name-to-terminal-prompt-mac/
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
@manderly
manderly / prepare-commit-msg
Created February 9, 2015 18:20
Git hook: Automatically add branch name to the end of every commit message
# Automatically adds branch name to the end of every commit message. Handy for git/JIRA integrations.
# Make a copy of .git/hooks/prepare-commit-msg.sample in your repo and name the file prepare-commit-msg (remove "sample" extension)
# Paste the following into the file, save the file, and try it out in bash
NAME=$(git branch | grep '*' | sed 's/* //')
echo $(cat "$1") "$NAME" > "$1"
@manderly
manderly / gist:9db712804d635a0f23ec
Created November 7, 2014 03:12
CBM.com admin controller changeIngredient method
$scope.changeIngredient = function(index) {
if (index == $scope.formMeal.ingredients.length -1) {
$scope.formMeal.ingredients.push('');
}
};
@manderly
manderly / cbm-ingredients
Created November 6, 2014 19:03
ChickenBreastMeals: Editable ingredients list created with ng-repeat
<h2>Ingredients</h2>
<ol class="ingredients-list">
<!-- loop through and display existing ingredients -->
<li data-ng-repeat="ingredient in formMeal.ingredients track by $index">
<textarea name="ingredientLines"
type="text"
data-ng-model="formMeal.ingredients[$index].name"
placeholder="Add ingredient"
data-ng-change="changeIngredient($index)"
></textarea>
@manderly
manderly / functions.php
Last active November 21, 2015 02:35
WordPress custom loop for use with the Genesis framework. Post titles display as a simple vertical list when viewing a category.
//Add this to the bottom of your functions.php file
//Must be using Genesis framework for WordPress
//This code will change your category pages to contain a simple list of your post titles as links
add_action( 'pre_get_posts', 'mjg_show_titles_only_category_pages' );
function mjg_show_titles_only_category_pages( $query ) {
if( $query->is_main_query() && $query->is_category() ) {
$query->set( 'orderby', 'title' );
@manderly
manderly / gist:db217926b02fef0b98b6
Created October 13, 2014 21:05
IonicOne WP Theme CSS for TowerSecrets
/*
Welcome to Custom CSS!
CSS (Cascading Style Sheets) is a kind of code that tells the browser how
to render a web page. You may delete these comments and get started with
your customizations.
By default, your stylesheet will be loaded after the theme stylesheets,
which means that your rules can take precedence and override the theme CSS
rules. Just write here what you want to change, you don't need to copy all
@manderly
manderly / fibo_under_max_num
Created September 13, 2014 04:05
Highest Fibonacci number under maxNum (improved)
//Return to me the highest Fibonacci number under 100
//0,1,1,2,3,5,8,13,21,34,55,89
var maxNum = 100;
var sum = 0;
var findHighestFiboUnder = function(max, num1, num2) {
//allows num1 and num2 to be optional
num1 = typeof num1 !== 'undefined' ? num1: 1;
num2 = typeof num2 !== 'undefined' ? num2: 1;
sum = num1 + num2;
@manderly
manderly / Highest_Fibonacci_Number_Under_100
Created September 12, 2014 16:17
JavaScript exercise: Find the highest Fibonacci number under 100
//Return to me the highest Fibonacci number between 0 and 100
//1,2,3,5,8,13,21,34,55,89
var sum = 0;
var arr = [];
var fibo = function(num1, num2) {
sum = num1 + num2;
console.log('num1: ' + num1 + ' + num2: ' + num2 + ' = sum: ' + sum);
@manderly
manderly / fizzbuzzchocolate.js
Created September 3, 2014 03:13
Fizz Buzz Chocolate
var str = "";
var params = {
3:"fizz",
5:"buzz",
8:"chocolate"
};
for (var i = 0; i < 100; i ++ ) {
str = i + " ";
@manderly
manderly / casperjstest.js
Last active August 29, 2015 14:05
CasperJS test exercise
casper.test.begin("Testing if node express app", 2, function suite(test) {
casper.start('http://localhost:3000', function() {
test.assertHttpStatus(200);
});
casper.then(function() {
if (this.fetchText('.daysLeft') > 0) { //todo: parse as int?
this.echo("more than 0 days left");
}
this.echo("Days left: " + this.fetchText('.daysLeft'));