mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-06-15 22:57:33 +02:00
Update
This commit is contained in:
parent
2794e757a7
commit
9c50a07f5a
95
101.md
Normal file
95
101.md
Normal 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
36
siege.md
Normal 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"
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user