Skip to content

Instantly share code, notes, and snippets.

View bradoyler's full-sized avatar
👋
say hi

brad oyler bradoyler

👋
say hi
View GitHub Profile
@bradoyler
bradoyler / story.html
Last active December 11, 2015 22:09
newsvine comment counter, which I can't get working.
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type='text/javascript' src='http://www.cdn.newsvine.com/_elliott/jenga.php?widgets=core%2Czinger%2Cfb%2Ctroff&#038;ver=1.0'></script>
This doesn't work':
<a class="j_troff_count" data-verbose="0" data-public-only="1"
data-title="Minimalist mom vows to spend nothing on her kid in 2013"
href="http://moms.today.com/_news/2013/01/25/16697528-minimalist-mom-vows-to-spend-nothing-on-her-kid-in-2013">test fails</a>
But this does:
<a class="j_troff_count" data-verbose="0" data-public-only="1"
@bradoyler
bradoyler / NoStaleQueriesAllowed.cs
Created January 31, 2013 17:23
Needed for unit testing. This ensures RavenDB will wait for non-stale results for any query.
// somewhere in your test’s setup
documentStore.RegisterListener(new NoStaleQueriesAllowed());
public class NoStaleQueriesAllowed : IDocumentQueryListener
{
public void BeforeQueryExecuted(IDocumentQueryCustomization queryCustomization)
{
queryCustomization.WaitForNonStaleResults();
}
}
@bradoyler
bradoyler / mapReduce-WordCounter.js
Last active November 6, 2022 01:45
Using Map-Reduce in Javascript: counting words in a string.
// for counting words in a string
var words="Hi there and hello there. Welcome and hello there.";
var wordcnt = words.replace(/[^\w\s]/g, "").split(/\s+/).reduce(function(map, word){
map[word] = (map[word]||0)+1;
return map;
}, Object.create(null));
@bradoyler
bradoyler / articlelist.hbs
Created October 21, 2013 04:12
An Ember.js controller that fetches data and binds to a template without using a router. Helpful if you have mutiple requests with a single Route. Uses the PromiseProxyMixin on a ObjectProxy
<ul class="article-list">
{{#each view.content.articlelist}}
<li>
{{#link-to 'article' this }} {{headline}} {{/link-to}}
</li>
{{/each}}
</ul>
@bradoyler
bradoyler / 0_reuse_code.js
Created November 29, 2013 06:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bradoyler
bradoyler / javascript_resources.md
Created November 29, 2013 06:21 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@bradoyler
bradoyler / css_resources.md
Created November 29, 2013 06:21 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

// jquerify.js // https://github.com/bgrins/devtools-snippets // Add jQuery to any page that does not have it already.
(function() {
if (!window.jQuery) {
var s = document.createElement('script');
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js');
document.body.appendChild(s);
console.log('jquery loaded!');
window.log = Function.prototype.bind.call(console.log, console);
/* log-globals by Sindre Sorhus https://github.com/sindresorhus/log-globals MIT License */
(function () { 'use strict';
function getIframe() {
var el = document.createElement('iframe');
el.style.display = 'none';
document.body.appendChild(el);
var win = el.contentWindow;
document.body.removeChild(el);
return win;