This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vcrMachine = new Machine( | |
{ | |
id: "videoMachine", | |
initial: "idle", | |
context: { | |
url: null, | |
video: null, | |
duration: 0, | |
elapsed: 0 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fetchUser = createAsyncThunk<Cleaner>( | |
"authentication/fetchUser", | |
async () => { | |
const cleaner = await authenticationApi.fetchUser(); | |
return cleaner; | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Machine({ | |
initial: "idle", | |
states: { | |
idle: { | |
invoke: { | |
src: "fetchUser", | |
onDone: { | |
target: "mainApp" | |
}, | |
onError: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sets item2 tab color (rgb) | |
iterm_set_tab_color() { | |
if [ $# -eq 0 ]; then | |
# Reset tab color if called with no arguments | |
echo -ne "\033]6;1;bg;*;default\a" | |
return 0 | |
fi | |
echo -ne "\033]6;1;bg;red;brightness;${1}\a" | |
echo -ne "\033]6;1;bg;green;brightness;${2}\a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- building on data from my scenario http://gist.github.com/44489 | |
-- and bayesian rating http://www.thebroth.com/blog/118/bayesian-rating | |
assume we have a products table and we want to sort products based on their rating. | |
With bayesian rating, you get better weighting, so that a single 5 star vote won't show up as "top product" | |
select * from products; | |
mysql> select * from products; | |
+------+--------+---------------+--------------+---------+ | |
| id | name | ratings_count | total_rating | weight | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { includes, last, lowerCase, padStart } = require("lodash"); | |
const babylon = require("babylon"); | |
const generator = require("babel-generator").default; | |
const t = require("babel-types"); | |
const traverse = require("babel-traverse").default; | |
const fs = require("fs"); | |
const path = require("path"); | |
const prettier = require("prettier"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, TestBed } from '@angular/core/testing'; | |
import { | |
BaseRequestOptions, | |
ConnectionBackend, | |
Http, | |
RequestMethod, | |
Response, | |
ResponseOptions | |
} from '@angular/http'; | |
import { MockBackend, MockConnection } from '@angular/http/testing'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "angular2/core"; | |
import { Headers, Http, Response, RequestOptionsArgs, URLSearchParams, RequestMethod } from "angular2/http"; | |
import { Observable } from "rxjs/Observable"; | |
import { SessionStorage } from "./session_storage.service"; | |
import { Router } from "angular2/router"; | |
@Injectable() | |
export class HttpClient { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bang(target, name, descriptor) { | |
var _get = descriptor.get; | |
descriptor.get = function() { | |
return _get.call(this) + '!'; | |
} | |
} | |
function wrap(pattern) { | |
return function (target, name, descriptor) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chai = require('chai'); | |
var chaiAsPromised = require('chai-as-promised'); | |
chai.use(chaiAsPromised); | |
var sinonChai = require('sinon-chai'); | |
chai.use(sinonChai); | |
var expect = require('chai').expect; | |
var sinon = require('sinon'); |
NewerOlder