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 / animate.js
Created November 26, 2014 17:57
Animate a form: drops into view from the top of the page when 'add' button is clicked. When 'save' is clicked, it animates up and out of view again. No extra JS library needed.
function ShowAssertiveForm(){
$('.assertiveFormSlider').animate({
top: '400px'
}, 600);
}
function HideAssertiveForm(){
$('.assertiveFormSlider').animate({
top: '-400px'
}, 400);
@dacur
dacur / placeholder.less
Created December 29, 2014 17:59
Change placeholder text color for text areas.
::-webkit-input-placeholder {
color: @grey !important;
}
:-moz-placeholder {
color: @grey !important;
}
::-moz-placeholder {
color: @grey !important;
}
:-ms-input-placeholder {
@dacur
dacur / keyboard
Created January 7, 2015 15:27
How to make UITextField move up when keyboard is present.
http://ios-blog.co.uk/tutorials/how-to-make-uitextfield-move-up-when-keyboard-is-present/
@dacur
dacur / click
Last active August 29, 2015 14:13
Selecting a list item from a 'ddl' type dropdown list. You cannot use .change(). Can then fire a 'sort' function to sort on the selected 'li'.
$(".occassionRow").click ->
alert "changed"
return
@dacur
dacur / loginsignup.swift
Last active August 29, 2015 14:13
A generic signup / login form for an iOS app written in Swift. NOTE: This uses Parse for user management. Put your Parse credentials in your AppDelegate.swift file.
import UIKit
class ViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var signupActive = true
var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
func displayAlert(title: String, error:String){
@dacur
dacur / password.js
Last active August 29, 2015 14:13
Password validation using regular expressions. Returns an error message based on what is missing/wrong with the user's password (or returns "ok"). Password must contain at least one letter and one number, must be between 6 and 50 characters in length, and may contain certain special characters (such as !, #, &, etc.).
function ValidatePassword(str){
if (str.length < 6) {
return("Password is too short. Must be at least 6 characters.");
} else if (str.length > 50) {
return("Password is too long. Must be no more than 50 characers.");
} else if (str.search(/\d/) == -1) {
return("Password must contain at least one number.");
} else if (str.search(/[a-zA-Z]/) == -1) {
return("Password must contain at least one letter.");
@dacur
dacur / pushArray.js
Created February 3, 2015 15:14
Loop through a set of checkboxes. If checked, push into an array.
var inputID = "";
$('#howDidIFeelCheckboxes').find('input').each(function(){
if($(this).is(':checked')){
inputID = $(this).attr('id');
// alert(id);
_howDidIFeelPopup.push(inputID);
}
});
@dacur
dacur / guid.js
Created February 5, 2015 21:36
Create a unique GUID. I sometimes use these when I need a unique value; for instance, when I need to add a unique ID to a DIV.
function CreateGuid() {
function _p8(s) {
var p = (Math.random().toString(16) + "000000000").substr(2, 8);
return s ? "-" + p.substr(0, 4) + "-" + p.substr(4, 4) : p;
}
return _p8() + _p8(true) + _p8(true) + _p8();
}
// to create a GUID, just call it like this:
// var id = CreateGuid();
@dacur
dacur / countItems.js
Created February 9, 2015 17:03
Every time a filter is applied/clicked, check to see if any items are displayed on the page. If not, display the message "Your search did not return any results. Please try again.". The message is hidden by default. The searches are fired on the click of a dropdown item. This function is called from each search function.
function DoesFilterReturnZeroItems(){
var hiddenItems = 0;
var allItems = 0;
$('#closetItems').find('.closetWrapper').each(function(){
if($(this).hasClass('displaynone')){
hiddenItems++;
}
allItems++;
});
if(allItems==hiddenItems){
@dacur
dacur / checkboxes.js
Created February 20, 2015 20:07
Checking if 'fancy' checkboxes are checked, and reseting them to unchecked.
$('#howDidIFeelCheckboxes').find('input').each(function(){
if($(this).is(':checked')){
$(this).attr('checked', false);
}
});