Skip to content

Instantly share code, notes, and snippets.

View bjmiller121's full-sized avatar

BJ Miller bjmiller121

View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@angrytoast
angrytoast / omghosts
Created April 10, 2014 23:39
omg hosts
#! /usr/bin/env bash
PROBLEM="$(cat /etc/hosts | grep tableausoftware.com | grep -v '^#' | wc -w)"
if [ "$PROBLEM" -gt 0 ]; then
say omg fix yer hosts
fi
@angrytoast
angrytoast / release_template
Last active July 14, 2021 09:29
GitHub Release Template
# DATE - "RELEASE NAME" #1000009
![ALT TEXT](IMAGE_URL "IMAGE TITLE")
### New Features / Projects
* __PROJECT / FEATURE__ [#42] - by @person
* __PROJECT / FEATURE__ [#42] - by @person
* __PROJECT / FEATURE__ [#42] - by @person
* __PROJECT / FEATURE__ [#42] - by @person
{
"alignment_chars":
[
"=",
":"
],
"alignment_space_chars":
[
"=",
":"
@jtwalters
jtwalters / git-grepwords
Last active July 19, 2016 09:11
Grep multiple words in your git commit message history
# Example use: find commit messages that contain pattern1 and pattern2
# $ git grepwords pattern1 pattern2
# Ensure we have at least one param (a pattern)
[ -n "$1" ] || { echo "usage: $0 PATTERN..." >&2; exit 1; }
pattern=""
# Append all remaining patterns
while [ -n "$1" ]; do
@angrytoast
angrytoast / translate.md
Last active August 29, 2015 14:12
OnTour Translation

OnTour Translation Starting point

  • /admin/tmgmt/sources

Translating Pages (this may mean both pages and field collections)

  • In general, pages will not have anything to translate beyond the title because everything should be in field_collection sections
  • The labels for standard pages can be confusing in the TMGMT interface, so it may be quicker to get the translation for the page title, and then update by hand.

Field Collections

  • /admin/tmgmt/sources
# Don't cache anything
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
</ifModule>
@bjmiller121
bjmiller121 / jquery.slideHeight.js
Created July 14, 2015 20:03
Re-implementation of jQuery slideUp() and slideDown() to avoid display: none;
/*
A re-implementation of jQuery's slideDown() and slideUp() that animates the
height of an element without requiring the use of display: none;
Helpful when needing to hide a video player while maintaining control via an
API.
The element must have "overflow: hidden;" set in CSS for this to work properly.
In order to have the element hidden by default, you mist also set "height: 0;"
in CSS as well.