Skip to content

Instantly share code, notes, and snippets.

View and1truong's full-sized avatar
🎯

Hong Truong and1truong

🎯
View GitHub Profile
@IanColdwater
IanColdwater / twittermute.txt
Last active July 2, 2024 02:25
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@tgalopin
tgalopin / symfony-http-client-async-example.php
Created March 2, 2019 21:26
Symfony HttpClient Async example
<?php
$client = \Symfony\Component\HttpClient\HttpClient::create();
// Create a few requests: this is entierely async, requests are launched in the background
$request1 = $client->request('GET', 'http://releases.ubuntu.com/18.04.2/ubuntu-18.04.2-desktop-amd64.iso?request=a');
$request2 = $client->request('GET', 'http://releases.ubuntu.com/18.04.2/ubuntu-18.04.2-desktop-amd64.iso?request=b');
$request3 = $client->request('GET', 'http://releases.ubuntu.com/18.04.2/ubuntu-18.04.2-desktop-amd64.iso?request=c');
// The code continues execution immediatly, you can do whathever you want here ...
@fracasula
fracasula / context_cancel.go
Last active May 19, 2022 20:49
GoLang exiting from multiple go routines with context and wait group
package main
// Here's a simple example to show how to properly terminate multiple go routines by using a context.
// Thanks to the WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"
@pyldin601
pyldin601 / tailrecursion.php
Last active August 18, 2023 11:20 — forked from beberlei/tailrecursion.php
PHP Tail Recursion
<?php
function tail($fn)
{
$underCall = false;
$pool = [];
return function (...$args) use (&$fn, &$underCall, &$pool) {
$result = null;
$pool[] = $args;
@vasanthk
vasanthk / System Design.md
Last active July 22, 2024 17:59
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@weierophinney
weierophinney / summary.md
Created May 4, 2015 21:54
Summary of PSR-7 changes since Review 2 began.

Summary of changes since Review 2 Started

  • Expanded section on expected structure returned by getUploadedFiles(), with several examples ranging from a flat structure to a nested structure with a collection of files.
  • Clarifications and simplification of URI -> Host header interactions.
    • Updated withUri() to indicate it MUST update the Host header with the value present in the URI provided (if any) UNLESS the $preserveHost flag is boolean true.
@antfroger
antfroger / forum_php_2014.md
Last active October 21, 2017 12:53
Forum PHP 2014
<?php
/**
* Client to interact with Amazon Simple Queue Service.
* @method Model addPermission(array $args = array()) {@command Sqs AddPermission}
* @method ResourceIteratorInterface getListQueuesIterator(array $args = array()) The input array uses the parameters of the ListQueues operation
* @link http://j.mp/1mtRCqZ#demo API docs
* @link http://j.mp/1xlxRpb#phpDoc
*/
class SqsClient extends AbstractClient {}
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@crittermike
crittermike / gist:6a24108a65407676497e
Created June 24, 2014 15:07
Parse a tweet's text with PHP and regex
<?php
/**
* Regex taken from http://saturnboy.com/2010/02/parsing-twitter-with-regexp/
*/
function parse_tweet($text) {
// Parse links.
$text = preg_replace(
'@(https?://([-\w\.]+)+(/([\w/_\.]*(\?\S+)?(#\S+)?)?)?)@',
'<a href="$1">$1</a>',