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 / 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 / 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 / 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;
};