Skip to content

Instantly share code, notes, and snippets.

View davidchase's full-sized avatar
📺
Working from home

David Chase davidchase

📺
Working from home
View GitHub Profile
// IIFE - Immediately Invoked Function Expression
(function(yourcode) {
// The global jQuery object is passed as a parameter
yourcode(window.jQuery, window, document);
}(function($, window, document) {
// The $ is now locally scoped
@davidchase
davidchase / isObjEmpty.js
Last active May 30, 2018 11:47
Plain javascript gut check if object is empty or not
var yourObjectHere = {};
Object.getOwnPropertyNames(yourObjectHere).length === 0; // empty object true
var yourObjectHere = {'empty':'i am not empty!!'};
Object.getOwnPropertyNames(yourObjectHere).length === 0; // empty object false
// function isEmpty(obj) with object param
var isEmpty = function(yourObjectHere) {
for (var key in yourObjectHere) return false; return true;
@davidchase
davidchase / README.md
Last active December 18, 2015 19:29
Angularjs Directive Blurb

Usage:

<div data-blurb ng-class="'blurb'" title="Blurb Title" show="106" more="Read More" less="Read Less" ellipsis="...">
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
 proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }
@davidchase
davidchase / README.md
Last active December 16, 2015 21:49
"This gives you the box model you want. Applies it to all elements. Turns out many browsers already use border-box for a lot of form elements (which is why inputs and textareas look diff at width:100%;) But applying this to all elements is safe and wise." -- Paul Irish

Keep My Width

A nice article by Paul Irish read here.

It talks about keeping width the same on all elements without affecting performance regardless of adding padding.

One simple line of CSS and your back on track as long as you are dealing with IE8 + or other browsers.

@davidchase
davidchase / README.md
Last active December 16, 2015 17:19
Hide the logins of users on the mac, separate the users by spaces. the data array is stored in a plist file called /Library/Preferences/com.apple.loginwindow.plist

Hide Users

This one liner hides users on a Mac OS X v10.4 and later.

Just seperate each user you would like to hide from the login menu with a space and it will store it to an array inside of loginwindow.plist file.

The key is HiddenUserList along with the array values that you inputed of the users.

@davidchase
davidchase / README.md
Last active January 12, 2022 10:00
simple hash change with scrolling, using jQuery

#Hash Change onScroll

Reminder:

Need to add mootools version too :)

Change the value of the url by scrolling through div's data-id or #

@davidchase
davidchase / README.md
Last active December 16, 2015 12:28
Quick no dependency test for flash players installed... to test in chrome disable flash in chrome://plugins/ and console.log the variable "hasFlash"

Has Flash?

Test the user to see if they have flash player installed on their machine.

Vanilla JS no dependcies

Can be test in Chrome by simple disabling flash inside plugins like so:

In the address chrome://plugins/ then select Disable under Adobe Flash player.

jQuery(document).ready(function($){
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$('.stag-metabox-table .button').click(function(e) {
var send_attachment_bkp = wp.media.editor.send.attachment;
var button = $(this);
var id = button.attr('id').replace('_button', '');
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment){
if ( _custom_media ) {
@davidchase
davidchase / README.md
Created April 10, 2013 12:33
google maps from address to latlng

Geocoder

The function converts an address that a user enters to geocode aka lat/lng.

The results stored in a variable to later use in a application sense.