Skip to content

Instantly share code, notes, and snippets.

View bjork24's full-sized avatar

Dan Chilton bjork24

  • EasyPost
  • Springfield, MO
View GitHub Profile
@Mearman
Mearman / Obsidian Snippets
Last active May 14, 2024 12:39
Obsidian Snippets
A collection of snippets
@addyosmani
addyosmani / package.json
Last active May 29, 2024 15:54
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@clineamb
clineamb / app.js
Last active June 6, 2018 01:53
[DEPRECIATED] Nunjucks 1.0.7 + Express 4.9.2
/*
* Nunjucks + Express
* I couldn't find anything that helped me setup the enviornment
* correctly for these in the latest vesion of Express 4 (at the time
* of writing this).
*
* This Gist for those that want to keep using Nunjucks with Express 4.
* This also goes over working with a Nunjucks environment to use custom
* filters, extensions, etc.
*
@branneman
branneman / breakpoints.scss
Last active February 19, 2019 08:57
JavaScript - CSS breakpoint Sync
/**
* Set the breakpoints as a font-family and pseudo element.
* This way JavaScript can read the current active breakpoint.
*/
head {
font-family: 'no-breakpoint';
}
body:after {
display: none;
content: 'no-breakpoint';
@jackie
jackie / breakpoints.json
Last active December 19, 2015 15:28
Sass Script function to get breakpoint values from a JSON file.
{
"phone" : "all and (max-width: 603px)",
"desktop": "all and (min-width: 1025px)",
"tablet" : "all and (min-width: 604px) and (max-width: 1024px)"
}
@robatron
robatron / passive-attach-module-pattern-example.js
Last active December 19, 2015 07:39
JavaScript Module Pattern Example with "Passive Attachment"
/** JavaScript Module Pattern Example with "Passive Attachment"
*/
(function(
win,
doc,
$,
a,
b
){
// "Passively attach" your new module to global through your namespace,
@zenorocha
zenorocha / multiple-3rd-party-widgets.js
Last active November 14, 2022 12:18
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@matteoagosti
matteoagosti / client.js
Created June 3, 2012 21:49
Meteor JS server side sessions
Meteor.subscribe(
'server_sessions',
amplify.store('session'), // Read from local storage / cookies
function() {
// The server returns only one record, so findOne will return that record
var serverSession = new Meteor.Collection('server_sessions').findOne();
// Stores into client session all data contained in server session;
// supports reactivity when server changes the serverSession
Session.set('serverSession', serverSession);
// Stores the server session id into local storage / cookies
@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