Skip to content

Instantly share code, notes, and snippets.

View jacksontong's full-sized avatar
🏠
Working from home

Jackson Tong jacksontong

🏠
Working from home
View GitHub Profile
@jacksontong
jacksontong / guzzle.php
Last active June 8, 2018 03:03
Guzzle async example
<?php
require_once('vendor/autoload.php');
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Promise as GuzzlePromise;
//https://stackoverflow.com/a/32751004/3787302
$start_time = microtime(TRUE);
$client = new GuzzleClient(['timeout' => 12.0]); // see how i set a timeout
$requestPromises = [];
$sitesArray = [
@jacksontong
jacksontong / youtube-api-response.json
Created August 12, 2018 12:21
youtube-api-response
[
{
"kind": "youtube#searchResult",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/iecMlihzF4qEDkzXsB6TUt81Oqw\"",
"id": {
"kind": "youtube#video",
"videoId": "M4ZoCHID9GI"
},
"snippet": {
"publishedAt": "2018-04-12T16:00:04.000Z",
{
"entities": {
"snippets": {
"aJOTlE1K90k": {
"publishedAt": "2018-05-31T04:00:00.000Z",
"channelId": "UCN1hnUccO4FD5WfM7ithXaw",
"title": "Maroon 5 - Girls Like You ft. Cardi B",
"description": "\"Girls Like You” is out now. http://smarturl.it/GLY For more, visit: https://www.facebook.com/maroon5 https://twitter.com/maroon5 ...",
"thumbnails": {
"default": {
@jacksontong
jacksontong / ioc.go
Last active December 29, 2024 14:58
Simple IOC container implementation in Go
// Package ioc provides a simple inversion of control container for registering and resolving services.
package ioc
import (
"fmt"
"sync"
)
// container holds the registered services and provides thread-safe access.
type container struct {