Update
This commit is contained in:
parent
2794e757a7
commit
9c50a07f5a
|
@ -0,0 +1,95 @@
|
||||||
|
---
|
||||||
|
title: 101
|
||||||
|
category: JavaScript libraries
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
isObject({})
|
||||||
|
isString('str')
|
||||||
|
isRegExp(/regexp/)
|
||||||
|
isBoolean(true)
|
||||||
|
isEmpty({})
|
||||||
|
isfunction(x => x)
|
||||||
|
isInteger(10)
|
||||||
|
isNumber(10.1)
|
||||||
|
instanceOf(obj, 'string')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Function composition
|
||||||
|
|
||||||
|
```
|
||||||
|
compose(f, g) // x => f(g(x))
|
||||||
|
curry(f) // x => y => f(x, y)
|
||||||
|
flip(f) // f(x, y) --> f(y, x)
|
||||||
|
|
||||||
|
passAll(f, g) // x => f(x) && g(x)
|
||||||
|
passAny(f, g) // x => f(x) || g(x)
|
||||||
|
|
||||||
|
converge(and, [pluck('a'), pluck('b')])(x)
|
||||||
|
// and(pluck(x, 'a'), pluck(x, 'b'))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Objects
|
||||||
|
|
||||||
|
```js
|
||||||
|
del(state, 'user.profile')
|
||||||
|
put(state, 'user.profile.name', 'john')
|
||||||
|
pluck(state, 'user.profile.name')
|
||||||
|
|
||||||
|
omit(state, 'user.profile')
|
||||||
|
pick(state, ['user', 'ui'])
|
||||||
|
pick(state, /^_/)
|
||||||
|
|
||||||
|
hasKeypaths(state, ['user'])
|
||||||
|
hasKeypaths(state, { 'user.profile.name': 'john' })
|
||||||
|
|
||||||
|
values(state)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Arrays
|
||||||
|
|
||||||
|
```js
|
||||||
|
find(list, x => x.y === 2)
|
||||||
|
findIndex(list, x => ...)
|
||||||
|
includes(list, 'item')
|
||||||
|
last(list)
|
||||||
|
|
||||||
|
groupBy(list, 'id')
|
||||||
|
indexBy(list, 'id')
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
find(list, hasProps('id'))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Simple
|
||||||
|
|
||||||
|
Useful for function composition.
|
||||||
|
|
||||||
|
```js
|
||||||
|
and(x, y) // x && y
|
||||||
|
or(x, y) // x || y
|
||||||
|
xor(x, y) // !(!x && !y) && !(x && y)
|
||||||
|
equal(x, y) // x === y
|
||||||
|
exists(x) // !!x
|
||||||
|
not(x) // !x
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Function composition:
|
||||||
|
|
||||||
|
```js
|
||||||
|
isFloat = passAll(isNumber, compose(isInteger, not))
|
||||||
|
// n => isNumber(n) && not(isInteger(n))
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
function doStuff (object, options) { ... }
|
||||||
|
|
||||||
|
doStuffForce = curry(flip(doStuff))({ force: true })
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
<https://github.com/tjmehta/101>
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
title: Siege
|
||||||
|
category: Others
|
||||||
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
siege -b -c=10 -t=5m http://...
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
-c, --concurrent=N
|
||||||
|
-t, --time=MINSm
|
||||||
|
-r, --reps=N
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
-i, --internet Hit URLs randomly
|
||||||
|
-b, --benchmark No delay between requests
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
```
|
||||||
|
-f, --file=FILE load urls.txt
|
||||||
|
-R, --rc=FILE load siegerc
|
||||||
|
```
|
||||||
|
|
||||||
|
> Also see: [siegerc](https://gist.github.com/stansmet/3067988)
|
||||||
|
|
||||||
|
### Headers
|
||||||
|
|
||||||
|
```
|
||||||
|
-H, --header="Cookie: foo=bar"
|
||||||
|
-A, --user-agent="Mozilla"
|
||||||
|
-T, --content-type="text/html"
|
||||||
|
```
|
Loading…
Reference in New Issue