Skip to content

Instantly share code, notes, and snippets.

View jimmynotjim's full-sized avatar
☀️
Enjoying SoCal "Fall"

Jimmy Wilson jimmynotjim

☀️
Enjoying SoCal "Fall"
View GitHub Profile
@jimmynotjim
jimmynotjim / url_params.js
Last active August 29, 2015 13:56
JS URL Param Functions
var ArrayToURL = function(array) {
var pairs = [];
for (var key in array)
if (array.hasOwnProperty(key))
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(array[key]));
return pairs.join('&');
};
var URLToArray = function(url) {
var request = {};
@jimmynotjim
jimmynotjim / menus.js
Created October 8, 2014 20:57
Menu JS examples
// currently
$('button.toggleNav').on('click', function() {
$('.top-bar__dropdown').toggleClass('MenuIsOpen');
});
// better
// Ensures that you only open the menu adjacent to the button if there are more than one.
// Great for reusing the same code throughout for multiple dropdowns
$('.toggleNav').on('click', function() {
(function () {
'use strict';
var gulp = require('gulp');
var glob = require('glob');
var del = require('del');
var $ = require('gulp-load-plugins')();
var pkg = require('./package.json');
@jimmynotjim
jimmynotjim / gist:e2e182eea6dedeb57109
Last active August 29, 2015 14:14
Pull Request Template
Short description explaining the highlevel reason for the pull request
## Additions
- List of additions made
- To the project
- Within this PR
## Removals
@jimmynotjim
jimmynotjim / markup.md
Last active August 29, 2015 14:16
Markup Standards

HTML Coding Standards

This documents outlines HTML code standards. The intent of the HTML standards is to foster cross-browser compatibility, accessibility, simplicity and maintainability.

Syntax

  • Use soft tabs with four spaces to guarantee code renders the same in any environment.
  • Nested elements should be indented once (four spaces).
Task Grunt Gulp
lint js 3.9s 1.81s
styles (sourcemaps takes forever) 2.6s 2.55s
scripts 4.92s 2.04s
copy 998ms 524ms
unit tests (only one in grunt) 16.5s 944ms
@jimmynotjim
jimmynotjim / first-paragraph-class.php
Created April 7, 2012 03:44 — forked from ericrasch/first-paragraph-class.php
WordPress: Add Class to first Paragraph in WordPress the_content; (add this to the functions.php in your Theme)
<?php
/* =BEGIN: Add Class to first Paragraph in WordPress the_content();
Source: http://webdevbits.com/wordpress/add-class-to-first-paragraph-in-wordpress-the_content/
---------------------------------------------------------------------------------------------------- */
function first_paragraph($content){
// Testing to see if the content is a Page or Custom Post Type of school, if so, display the text normally (without the class = intro).
if ( is_page() || ('school' == get_post_type() ) ) {
return preg_replace('/<p([^>]+)?>/', '<p$1>', $content, 1);
} else {
return preg_replace('/<p([^>]+)?>/', '<p$1 class="intro">', $content, 1);
@jimmynotjim
jimmynotjim / include-tweets.php
Created April 7, 2012 03:44 — forked from ericrasch/include-tweets.php
How to display your latest tweets in your WordPress site without a plugin
<?php
// How to display your latest tweets in your WordPress site without a plugin
// Source: http://dinolatoga.com/2010/07/31/how-to-display-your-latest-tweets-in-your-wordpress-blog-without-a-plugin/
include_once(ABSPATH . WPINC . '/feed.php');
//configuration
$username = "EricRasch"; // Just insert the username of the Twitter account you want to display
$feed = "http://twitter.com/statuses/user_timeline/$username.rss"; // Changed the code from dinolatoga.com to actually use the username variable
$num = 2; // Set the number of Tweets you want to display
@jimmynotjim
jimmynotjim / fb-comments.html
Created April 25, 2012 17:34
Adaptive sizing for FB comments plugin
<!-- New HTML5 FB Comments -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
@jimmynotjim
jimmynotjim / gist:2570530
Created May 1, 2012 19:04
Add user avatar uploader to admin panel and function call for front end
<?php
/* BEGIN: add user info
---------------------------------------------------------------------------------------------------- */
add_action( 'show_user_profile', 'show_extra_profile_fields' );
add_action( 'edit_user_profile', 'show_extra_profile_fields' );
function show_extra_profile_fields( $user ) { ?>