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
/// <reference path="../typings/mocha/mocha.d.ts" /> | |
/// <reference path="../StronglyTypedEvents.d.ts" /> | |
/// <reference path="../typings/node/node.d.ts" /> | |
/// <reference path="../typings/chai/chai.d.ts" /> | |
'use strict'; | |
var r = typeof require !== 'undefined', w = window as any; | |
var expect: Chai.ExpectStatic = r ? require('chai').expect : w.chai.expect; |
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
{ | |
"pomegranate": { | |
"50": "#f9ebea", | |
"100": "#f2d7d5", | |
"200": "#e6b0aa", | |
"300": "#d98880", | |
"400": "#cd6155", | |
"500": "#c0392b", | |
"600": "#a93226", | |
"700": "#922b21", |
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
"use strict"; | |
ko.conditionedObservable = function (initialValue, condition) { | |
var obi = ko.observable(initialValue); | |
var computer = ko.computed({ | |
read: function () { return obi(); }, | |
write: function (newValue) { | |
//unwrap value - just to be sure | |
var v = ko.unwrap(newValue); | |
//check condition | |
if (condition(v)) { |
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 | |
norrisUrl = 'https://api.icndb.com/jokes/random', | |
decode = require('decode-html'); | |
//the export is used to init the bot | |
module.exports = (robot) => { | |
//listen to phrases that contain "Norris" | |
robot.hear(/Norris/ig, (res) => { |
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
class Parameter | |
{ | |
[FromRoute] | |
public string CategoryCode { get; set; } | |
[FromRoute] | |
public string ShopCode { get; set; } | |
[FromRoute] | |
public string SegmentCode { get; set; } | |
[FromRoute] | |
public string ProductId { get; set; } |
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
public class RegexNamedGroupRoutingConstraint : IRouteConstraint | |
{ | |
private readonly List<Regex> regexes = new List<Regex>(); | |
public RegexNamedGroupRoutingConstraint(params string[] regexes) | |
{ | |
foreach (var regex in regexes) | |
{ | |
this.regexes.Add(new Regex(regex)); | |
} |
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
app.UseMvc(routes => | |
{ | |
var shopRoutingConstraint = new RegexNamedGroupRoutingConstraint( | |
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})_(?<SegmentCode>[A-Z0-9]{3})_(?<ProductId>\d+)/?$", | |
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})_(?<SegmentCode>[A-Z0-9]{3})/?$", | |
"/(?<CategoryCode>[A-Z0-9]{3})_(?<ShopCode>[A-Z0-9]{3})/?$", | |
"/(?<CategoryCode>[A-Z0-9]{3})/?$" | |
); | |
routes.MapRoute |
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 { mapper, RestParameter } = require('hubot-command-mapper') | |
module.exports = robot => { | |
let todos = [] | |
mapper(robot, { | |
name: 'todo', | |
commands: [{ | |
name: 'add', | |
alias: [''], |
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
{ | |
name: "list", | |
alias: ["", "lst", "ls"], | |
invoke: (tool, robot, res, match, values) => { | |
if (todos.length === 0) { | |
res.reply("The list is empty."); | |
return; | |
} | |
let i = 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
{ | |
name: "remove", | |
alias: ["rm", "del"], | |
parameters: [new RestParameter("item")], | |
invoke: (tool, robot, res, match, values) => { | |
let item = values.item.toLowerCase(); | |
let length = todos.length; | |
todos = todos.filter(f => f.toLowerCase().indexOf(item) === -1); | |
let i = length - todos.length; | |
if (i === 1) { |
OlderNewer