Skip to content

Instantly share code, notes, and snippets.

@michaelcox
michaelcox / SpecRunner.js
Last active October 12, 2024 17:11
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@mxriverlynn
mxriverlynn / EventedStateMachine.js
Created November 14, 2012 17:22
Triggering events to notify of state machine state change
// This is built on top of MarionetteJS' [Controller](https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.controller.md)
// object, which includes Backbone.Events in it, to
// trigger events.
//
// I think this is a sort of statemachine. But honestly, I'm not entirely
// sure about that. I've had very little luck / experience with statemachines
// in my career.
//
// Would love to get feedback on this.
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
git clone git://github.com/wbond/sublime_package_control.git Package\ Control
cd Package\ Control
git checkout python3
# restart Sublime Text 3 and you should have Package Control working
@shanselman
shanselman / gist:5422230
Last active September 30, 2025 08:47
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
@paulirish
paulirish / performance.now()-polyfill.js
Last active December 11, 2024 09:06
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
@seifsallam
seifsallam / RESTAdapter.js
Last active August 15, 2016 19:37
Ember RESTAdapter configuration for sending HTTP header and CrossDomain Access
// store.js
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
url: 'http://localhost:5000',
namespace: 'api',
corsWithCredentials: true,
headers: {
'Accept': 'application/vnd.vendor+json;version=1',
'Content-type': 'application/json',
@tomdale
tomdale / gist:6382021
Created August 29, 2013 18:56
Ember inspector description
The Ember Inspector is a plug-in for the Chrome developer tools that makes understanding and debugging your Ember.js application a snap.
After installing this extension, you'll be able to easily:
- View all of the routes defined in your application.
- Reference Ember's naming conventions for your URLs, including what to name your controllers, templates, routes and more.
- Overlay your application with information about what templates, controllers, and models are currently being rendered.
- Inspect the objects in your application, such as models and controllers, with UI that fully supports Ember features such as bindings and computed properties.
- Make your application's objects available in the console as the $E variable.
@haacked
haacked / csharp-conventions.md
Last active December 23, 2015 07:29
Examples of C# code conventions for http://sideeffect.kr/popularconvention/

Space vs Tab

Space

public string GetSomething()
{
    return something;
}
<HTabControl Grid.Row="1" ItemsSource="{Binding Path=OutNursingPartStatementFolderList}" SelectedItem="{Binding Path=SelectedNursingPartFolder}"
SelectedValuePath="NRST_FLDR_CTG_CD" DisplayMemberPath="FLDR_NM" ItemContainerStyle="{StaticResource treeItemStyle}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding Path=SelectionFolderChangedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</HTabControl>
@wycats
wycats / connection-problems.md
Created October 22, 2013 14:07
Connection Issues

Let's say we have a stream that represents the value of a property on some object.

var stream = new PathStream(post, 'title');

When we subscribe to this stream, we want to get its current value right away, and then any subsequent changes to the value.

In order to do this, we implement PathStream to hold onto a reference to the current value, and implement its subscribe to always emit the current value right away.