Skip to content

Instantly share code, notes, and snippets.

View tridungpham's full-sized avatar

Pham Tri Dung tridungpham

View GitHub Profile
@tridungpham
tridungpham / .zshrc
Created July 7, 2022 08:40
Configuring word jumping for kitty & iterm2
# this config is for zsh
# iterm
bindkey "\e\e[D" backward-word # ⌥←
bindkey "\e\e[C" forward-word # ⌥→
# kitty
bindkey "\e[1;3D" backward-word # ⌥←
bindkey "\e[1;3C" forward-word # ⌥→

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@tridungpham
tridungpham / Flutter Development on Windows with IntelliJ and WSL.md
Created July 7, 2021 16:10
Flutter Development on Windows with IntelliJ and WSL

Developing Flutter apps using Windows

I've been developing Flutter apps for two years, and until this month did so exclusively on OS X. I decided to move my development environment entirely to Windows, troubled by Apple's recent behavior with the App Store, put off by being forced to buy an overpriced Mac to develop apps for iOS, and tired of wrestling with OS X's non-standard BSD-like Linux environment and Homebrew package manager. This document describes the various approaches I tried, and how to set up the one I liked the best.

@tridungpham
tridungpham / php7.4-fpm-alpine
Created June 12, 2021 13:04 — forked from jpswade/php7.4-fpm-alpine
PHP 7.4 PHP-FPM Alpine with core extensions gd
FROM php:7.4-fpm-alpine
# @see https://hub.docker.com/r/jpswade/php7.4-fpm-alpine
MAINTAINER Agent Software <[email protected]>
# Install gd, iconv, mbstring, mysql, soap, sockets, zip, and zlib extensions
# see example at https://hub.docker.com/_/php/
RUN apk add --update \
$PHPIZE_DEPS \
freetype-dev \
git \
@tridungpham
tridungpham / vietnamese.rules
Created March 7, 2021 10:22 — forked from hieunguyentrung/vietnamese.rules
PostgreSQL unaccent Vietnamese rules
À A
Á A
Ả A
Ạ A
 A
Ấ A
Ầ A
Ẩ A
Ậ A
Ẫ A
@tridungpham
tridungpham / Laravel-Container.md
Created June 8, 2018 10:22
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

try {
var response = (HttpWebResponse) request.GetResponse();
} catch (Exception e) {
var response = (HttpWebResponse) e.Response;
}
<?php
$comments = [
1 => ['content' => "The first comment", 'parent' => 0],
2 => ['content' => "The second comment", 'parent' => 0],
3 => ['content' => "Reply of first comment", 'parent' => 1],
4 => ['content' => "Another reply of first comemnt", 'parent' => 1],
5 => ['content' => "Reply of a reply of the first comment", 'parent' => 4]
];
@tridungpham
tridungpham / flat2tree.php
Created September 16, 2015 15:30
Transform flat array into tree
<?php
// http://php.net/manual/en/language.references.php
$flat = array(
"7" => array(
"id" => 7,
"parent" => 6
),
"6" => array(
"id" => 6,
var asyncModule = function(name) {
return {
controller: function() {
m.startComputation()
require([name], function(module) {
this.controller = new module.controller()
this.view = module.view
m.endComputation()