try
intercept[DBException] {
categoryDAO.insert(catFixture).futureValue
categoryDAO.insert(catFixture).futureValue
}
try
intercept[DBException] {
categoryDAO.insert(catFixture).futureValue
categoryDAO.insert(catFixture).futureValue
}
def anyDuplicate(arr: List[Int], k: Int): Boolean = { | |
var any_duplicate = false | |
val hs = mutable.HashSet[(Int, Int)]() | |
arr.zipWithIndex | |
.withFilter(_ => !any_duplicate) | |
.map { | |
case tp @ (e, idx) => | |
hs.find(_._1 == tp._1) match { | |
case Some((d, idxD)) if (tp._2 - idxD <= k) => | |
any_duplicate = true // <-------- update flag |
trait Encryption { | |
/** | |
* Encrypt token | |
* @param app | |
* @param token | |
* @return | |
*/ | |
def encryptToken(app: Application, token: String): String = { |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Image, | |
TextInput, | |
AlertIOS, |
def time[R](name: String)(block: => R): R = { | |
val t0 = System.currentTimeMillis() | |
val result = block | |
val t1 = System.currentTimeMillis() | |
println(s" $name time: " + (t1 - t0) + "ns") | |
result | |
} | |
val Times = 1000000 |
Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.
Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.
function isMessageAttributeValid ({DataType} = {}) { | |
console.log(arguments) | |
if (!DataType) { | |
// throw new Error('A MessageAttribute must have a DataType key') | |
} | |
if (typeof DataType !== 'string') { |
// | |
//groupBy: <K, R>(keySelector: (value: T) => K, elementSelector?: (value: T) => R, durationSelector?: (group: GroupedObservable<K, R>) => Observable<any>) => Observable<GroupedObservable<K, R>>; | |
// | |
//map: <R>(project: (x: T, ix?: number) => R, thisArg?: any) => Observable<R>; | |
var codes = [ | |
{ keyCode: 38}, // up | |
{ keyCode: 38}, // up | |
{ keyCode: 40}, // down |
const Promise = require('bluebird') | |
const request = require('request') | |
const cheerio = require('cheerio') | |
const moment = require('moment') | |
const _ = require('lodash') | |
class GaroonClient { | |
constructor () { | |
this.jar = request.jar() | |
this.url = { |
var StringDecoder = exports.StringDecoder = function(encoding) { | |
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); | |
assertEncoding(encoding); | |
switch (this.encoding) { | |
case 'utf8': |