Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
jhollingworth / gist:701488f121af94694fb7
Created March 30, 2015 14:02
Add `locally` to fetch
import Marty from 'marty';
import OfferConstants from './OfferConstants';
import OfferQueries from './Queries';
class OffersStore extends Marty.Store {
constructor(options){
super(options);
this.state = [];
class Foo {
constructor() {
this.getFoo()
}
get getFoo() {
return function () {
console.log('foo');
}
}
var ActionStore = require('marty/stores/actionStore');
var actionToken = ActionCreators.someAction();
ActionStore.addChangeListener(function () {
var action = ActionStore.getAction(actionToken);
console.log(action.status, action.error)
});
var UsersStore = Marty.createStore({
handlers: {
addUser: [UserConstants.ADD_USER, UserConstants.CREATE_USER]
},
addUser: function (user) {
this.state[user.id] = user;
this.hasChanged();
return function actionFailed(error) {
this.state.errors[user.id] = error;
var UserState = Marty.createStateMixin({
listenTo: [ActionStore, UserStore],
getState: function () {
return {
user: UserStore.getById(123),
createUser: ActionStore.getStatus(this.createUserToken)
};
}
})
@jhollingworth
jhollingworth / define.sublime-snippet
Created April 28, 2013 11:32
Snippet for defining a module in requirejs
<snippet>
<content><![CDATA[
define(function(require) {
var \$ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone')
${1:Content}
})
]]></content>
@jhollingworth
jhollingworth / gt.bat
Created April 10, 2013 10:32
Git alias "gt" for tracking the current branch
FOR /F "delims=" %%i IN ('git rev-parse --abbrev-ref HEAD') DO git branch --set-upstream %%i origin/%%i
public static string[] Split(this string str, string separator)
{
return str.Split(new [] { separator }, StringSplitOptions.None);
}
deploy-website `
-Server = "Foo" `
-Website = "Foo" `
-AppPool = "Foo" `
-Source = "Foo"
//this javascript works
"=foo".replace(/=/,'');
#but this coffeescript does not work (turns out due to a known issue https://github.com/jashkenas/coffee-script/issues/1399)
"=foo".replace(/=/,'')
#but as you say, this works
"=foo".replace(/\=/,'')