brew uninstall --ignore-dependencies node icu4c
brew install node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {map, first} = require('lodash'); | |
const resolvers = { | |
Query: { | |
hero: async (_, {id}, {dataSources}) => { | |
const res = await dataSources.marvelApi.getHero(id); | |
const data = res.data; | |
const item = first(data.results); | |
return { | |
id: item.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
const { RESTDataSource } = require('apollo-datasource-rest'); | |
const { ApolloError } = require('apollo-server-errors'); | |
class MarvelApi extends RESTDataSource { | |
constructor() { | |
super(); | |
this.baseURL = 'https://gateway.marvel.com:443/v1'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<[DEFINE name="dateFormat" value="exportData.createDateFormat('yyyy-MM-dd')"/]> | |
<[DEFINE name="keywords" value="exportData.keywords"/]> | |
<[DEFINE name="searchEngines" value="exportData.searchEngines"/]> | |
date,keyword,search_engine,rank | |
<[FOR_EACH name="keywords" id="keyword"]> | |
<[FOR_EACH name="searchEngines" id="searchEngineType"]> | |
<[DEFINE name="history" value="keyword.getHistory(searchEngineType)"/]> | |
<[FOR_EACH name="exportData.reverse(history)" id="historyRecord"]> | |
"<[ECHO text="dateFormat.format(historyRecord.checkDate)"/]>",<[ECHO text="keyword.query"/]>,<[ECHO text="searchEngineType.getName()"/]>,<[DEFINE name="position" value="exportData.getPosition(historyRecord)"/]><[IF condition="position != null"]><[THEN]><[ECHO text="position"/]><[/THEN]><[/IF]> | |
<[/FOR_EACH]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name api.example.com; | |
location / { | |
root /usr/share/nginx/LARAVEL_DIR/public; | |
index index.php; | |
try_files $uri $uri/ /index.php$is_args$args; | |
location ~ \.php$ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function progress_bar($done, $total, $info="", $width=50) { | |
$perc = round(($done * 100) / $total); | |
$bar = round(($width * $perc) / 100); | |
return sprintf("%s%%[%s>%s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Promise\EachPromise; | |
use GuzzleHttp\Promise\FulfilledPromise; | |
use GuzzleHttp\Psr7\Response; | |
use Cache; | |
$users = ['one', 'two', 'three']; | |
$cache = new Cache(); | |
$promises = (function () use ($users, $cache) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Promise\EachPromise; | |
use GuzzleHttp\Psr7\Response; | |
$users = ['one', 'two', 'three']; | |
$promises = (function () use ($users) { | |
foreach ($users as $user) { | |
// don't forget using generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Promise\Promise; | |
$promise = new Promise(); | |
$promise->then( | |
// $onFulfilled | |
function ($value) { | |
echo 'The promise was fulfilled.'; | |
}, | |
// $onRejected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$promise = $client->getAsync('http://httpbin.org/get'); | |
$promise = $client->deleteAsync('http://httpbin.org/delete'); | |
$promise = $client->headAsync('http://httpbin.org/get'); | |
$promise = $client->optionsAsync('http://httpbin.org/get'); | |
$promise = $client->patchAsync('http://httpbin.org/patch'); | |
$promise = $client->postAsync('http://httpbin.org/post'); | |
$promise = $client->putAsync('http://httpbin.org/put'); |
NewerOlder