Skip to content

Instantly share code, notes, and snippets.

View dacur's full-sized avatar

David Curtis dacur

  • Raleigh, North Carolina
View GitHub Profile
@dacur
dacur / age.js
Last active August 29, 2015 14:06
User inputs DOB with dropdowns for month and date, with a text box for year. Since month is 'January, February, etc.' and we need its numerical value, we included a switch statement to convert it to a number. We then add those together into 'birthday', pass that value to CurrentAge(), which returns the user's age as YEAR-MO-DY.
$('#birthdayBtn').on('click', function(){
var month = $('#birth_month').val();
switch (month){
case 'January':
month = 1;
break;
case 'February':
month = 2;
break;
case 'March':
@dacur
dacur / goals.jade
Created September 17, 2014 20:25
Using CSS with Jade and Bootstrap to turn text 90 degrees - works in '.col-xs-6' for mobile.
#pageGoalSettingPlan.page
.content
.col-xs-6
h4 Goal Setting Plan
br
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
input(type='text', class='form-control', placeholder='Free Text')
@dacur
dacur / radiobtns.jade
Created September 17, 2014 19:42
Radio buttons in Jade/Bootstrap. Using the same 'name' (e.g., 'confidence) will allow only one radio button to be clicked/active at a time.
label.radio-inline
input(type='radio', class='radioSpans', id='confidence1', value='option1', name='confidence')
span 1
label.radio-inline
input(type='radio', class='radioSpans', id='confidence2', value='option2', name='confidence')
span 2
label.radio-inline
input(type='radio', class='radioSpans', id='confidence3', value='option3', name='confidence')
span 3
@dacur
dacur / include.jade
Created September 17, 2014 19:38
Using Jade's 'include' to add pages in a subfolder into your single page app. Subfolder in this example is called 'goalsetting', and the file is 'pageGoalSettingPlan' (which is saved as pageGoalSettingPlan.jade).
include ./goalsetting/pageGoalSettingPlan
@dacur
dacur / checkbox.jade
Created September 16, 2014 16:53
This is how you create a checkbox in Jade with text after it, 'Remember Me', and that is 'checked' automatically on page load.
input#remember(type='checkbox', name='remember', checked=true)
span Remember Me
@dacur
dacur / currency_conversion.js
Created September 15, 2014 20:17
Changing a float to currency using JavaScript.
(item.price).toFixed(2)
//or more specifically:
html += '<div class="price">$' + (item.price).toFixed(2) + '</div>'
@dacur
dacur / isboxchecked.js
Created September 5, 2014 17:42
How to check if a checkbox is checked.
// First method - Recommended
$('#checkbox').prop('checked') // Boolean true
@dacur
dacur / data.js
Created September 4, 2014 19:35
Getting the value (or 'data-id' value) of a checked radio button.
$("#btnSubmitPayment").on "click", -> # clicking button to submit payment
shirt = $("input[name=shirt]:checked").attr("data-id") # grabbing size of shirt selected
alert shirt # alerting shirt size to check that it's getting correct values
Create a local .gitignore
If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.
A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository.
In Terminal, navigate to the location of your Git repository.
Enter: touch .gitignore to create a .gitignore file.
@dacur
dacur / searchgif.js
Last active August 29, 2015 14:06
Adding a 'loading.gif' while something is happening on the page (e.g. waiting for search results).
$("#searchloading").html("<img src='/assets/loader.gif' alt='loading...' />");
// then:
$("#searchloading").css("display", "none");