Skip to content

Instantly share code, notes, and snippets.

View eljamez's full-sized avatar
🕶️
Good Times

James Augustus Hall eljamez

🕶️
Good Times
View GitHub Profile
@eljamez
eljamez / Breakpoint Mixins
Created February 3, 2015 18:13
Breakpoint Mixins for SCSS for easy setup.
// 1120px
@mixin bp-xlarge {@media only screen and (min-width: 80em) {@content;}}
// 960px
@mixin bp-large {@media only screen and (min-width: 64em) {@content;}}
// 640px
@mixin bp-medium {@media only screen and (min-width: 40em) {@content;}}
// 480px
@mixin bp-small {@media only screen and (min-width: 30em) {@content;}}
// special for header (840px)
@mixin bp-header {@media only screen and (min-width: 53em){@content;}}
@eljamez
eljamez / animateElementMethod.js
Created December 10, 2015 21:17
animate.css "animateElement" method for an ES2015 Class
// A method withn an es2015 Class
// requires animate.css (https://daneden.github.io/animate.css/)
// animation defaults to "pulse"
// call it, watch animation, end event binds and unbinds after one use, removing animate classes.
animateElement($element, animationType) {
// animate.css animate type
animationType = animationType || "pulse";
let animationClasses = 'animated ' + animationType;
let animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
$element.addClass(animationClasses).one(animationEnd,function() {
@eljamez
eljamez / functions.php
Last active December 21, 2015 13:29
Wordpress Function for Functions.php, Get The Current Username from Anywhere
// get the current user name from anywhere
// paste into functions.php
if ( ! function_exists( 'get_user_name' ) ) {
function get_user_name() {
global $current_user;
get_currentuserinfo();//populates current user var/object
$current_visible_name = $current_user->user_firstname;
if($current_visible_name == '') {
$current_visible_name = $current_user->display_name;
};
@eljamez
eljamez / browser_info.coffee
Last active December 21, 2015 13:38
CoffeeScript + Jquery : quick function to get browser width and height
$ () -> #jQuery starter upper!
# browser window var
$browser_window = $(window)
# function
window_info = ->
console.log '----------------BROWSER WIDTH AND HEIGHT-------------------'
console.log $browser_window.width()+' is the browser width || '+$browser_window.height()+' is the browser height'
# function call
window_info()
@eljamez
eljamez / revert_array_keys_to_defaults.php
Last active December 21, 2015 20:00
Revert Array to default numbering system for arrays.
// usage
// just call rekey_array_keys_to_defaults( $my_array );
// this function call will return the same array in the same order
// but with new keys. The new keys are the default array keys
// i.e. [0,1,2]
function rekey_array_keys_to_defaults($array_to_rekey) {
$rekeyed_array = array();
foreach ($array_to_rekey as $key => $value) {
array_push($rekeyed_array, $value);
@eljamez
eljamez / switch.coffee
Created September 12, 2013 18:02
CoffeeScript switch example (for quick reference)
# just copy and paste and you have the quick bones for a CoffeeScript Swtich statement
# 'day' is the variable you are checking
switch day
when "Fri" then 'yeah'
else 'dang'
@eljamez
eljamez / get_scroll_top.coffee
Last active December 29, 2015 08:49
Just a quick snip that returns the scroll position of the page.
# start at the top
scroll_top = 0
# on the scroll
$(@).scroll () =>
scroll_top = $(@).scrollTop()
# log it
console.log scroll_top
@eljamez
eljamez / hero-paralax
Last active December 31, 2015 08:49
Quick bit for initiating a background image paralax on a large image (hero) that is at the top of your page. (NEEDS WORK)
# Still working on this.
# the element with the class 'hero-paralax' will be targeted, setting the variable
$hero_paralax = $('.hero-paralax')
# watching for scrolling
$(@).scroll () =>
# set scroll top position
scroll_top = $(@).scrollTop()
# set new bg position (moves down at half the speed of scrolling
@eljamez
eljamez / concat.js
Last active December 10, 2017 22:43
es6 spread and concat, add to array of objects.
const myObj = {
list: [
{name: 'bill'},
{name: 'fred'}.
],
};
const newObj = {
...myObj,
list: myObj.list.concat({name: 'sam'})
@eljamez
eljamez / getUrlParamsObj.js
Created June 19, 2018 21:02
ES6 friendly function to retrieve url parameters as an Object.
const getUrlParamsObj = (queryString) => {
const paramsArray = (window.location.search.charAt(0) === "?")
? window.location.search.substr(1).split('&')
: window.location.search.split('&')
return paramsArray.reduce((mainObj, val) => {
const valArray = val.split('=')
return Object.assign(mainObj, {[valArray[0]]: valArray[1]})
}, {})
}