Skip to content

Commit cbfed7e

Browse files
author
Mostafa Kamal
committed
mk
1 parent 92367af commit cbfed7e

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

javascript-developer/extra/keycode/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,43 @@ toc_max: 4
1111
* [mdn keyCode](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode)
1212
* [css trick](https://css-tricks.com/snippets/javascript/javascript-keycodes/)
1313
* [https://dmauro.github.io/Keypress/](https://dmauro.github.io/Keypress/)
14+
15+
## keyPress,keyUp,keyDown
16+
17+
* Down happens first
18+
* Press happens second (when text is entered)
19+
* Up happens last (when text input is complete).
20+
21+
```js
22+
window.addEventListener("keyup", log);
23+
window.addEventListener("keypress", log);
24+
window.addEventListener("keydown", log);
25+
26+
function log(event){
27+
console.log( event.type );
28+
}
29+
```
30+
31+
## keyup with delay
32+
33+
```js
34+
// Get the input box
35+
var textInput = document.getElementById('test-input');
36+
37+
// Init a timeout variable to be used below
38+
var timeout = null;
39+
40+
// Listen for keystroke events
41+
textInput.onkeyup = function (e) {
42+
43+
// Clear the timeout if it has already been set.
44+
// This will prevent the previous task from executing
45+
// if it has been less than <MILLISECONDS>
46+
clearTimeout(timeout);
47+
48+
// Make a new timeout set to go off in 800ms
49+
timeout = setTimeout(function () {
50+
console.log('Input Value:', textInput.value);
51+
}, 500);
52+
};
53+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11

2+
## Guzzle http client
3+
4+
```php
5+
use GuzzleHttp\Client;
6+
$http = new Client([
7+
'base_uri' => '127.0.0.1:8000',
8+
]);
9+
$response = $http->get('/kapi/oauth/token', [
10+
// 'form_params' => [
11+
// // 'grant_type' => 'authorization_code',
12+
// // 'client_id' => 'client-id',
13+
// // 'client_secret' => 'client-secret',
14+
// // 'redirect_uri' => 'http://example.com/callback',
15+
// 'token' => \Request::get('token'),
16+
// ],
17+
'query' => [
18+
'token' => \Request::get('token'),
19+
'osecret' => '56d6107453c130e8eb71686c41bcd9kapi1'
20+
],
21+
'headers' => [
22+
'osecret' => '56d6107453c130e8eb71686c41bcd9kapi1'
23+
]
24+
]);
25+
```
26+
27+
## resources
228

329
* [post](https://gist.github.com/juampynr/bfd5e8e38424618b3065b3f6a9713e69)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11

22

33
* [pivot](https://laraveldaily.com/pivot-tables-and-many-to-many-relationships/)
4+
5+
## Eager Loading
6+
7+
```php
8+
$user = User::with(['message'])->get();
9+
# retrive specific column
10+
$user = User::with(['message:title,time'])->get();
11+
# nested
12+
# reply function inside message model
13+
$user = User::with(['message.reply'])->get();
14+
15+
```
16+
17+
* access
18+
19+
```php
20+
foreach ($users as $user) {
21+
echo $user->message->title;
22+
}
23+
```

0 commit comments

Comments
 (0)