This commit is contained in:
Rico Sta. Cruz 2016-08-25 10:27:17 +08:00
parent 2794e757a7
commit 9c50a07f5a
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
2 changed files with 131 additions and 0 deletions

95
101.md Normal file
View File

@ -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>

36
siege.md Normal file
View File

@ -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"
```