Skip to content

Instantly share code, notes, and snippets.

View lantrinh1999's full-sized avatar
🖐️
Out sick

TRAN DUC LINH lantrinh1999

🖐️
Out sick
  • Hanoi
View GitHub Profile
@lantrinh1999
lantrinh1999 / table-to-json.js
Created October 21, 2022 18:36 — forked from johannesjo/table-to-json.js
Snippet to convert html table to json (to be used with google chrome or similiar)
function tableToJson(table) {
var data = [];
// first row needs to be headers
var headers = [];
for (var i=0; i<table.rows[0].cells.length; i++) {
headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
}
// go through cells
@lantrinh1999
lantrinh1999 / docker-for-mac.md
Created October 6, 2022 11:15 — forked from BretFisher/docker-for-mac.md
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@lantrinh1999
lantrinh1999 / macro.md
Created September 9, 2022 18:33 — forked from brunogaspar/macro.md
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@lantrinh1999
lantrinh1999 / rest-api-response-format.md
Created September 9, 2022 17:36 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices
@lantrinh1999
lantrinh1999 / crawler-edit.php
Created February 27, 2022 05:01 — forked from jakzal/crawler-edit.php
Removing nodes with DomCrawler
<?php
<<<CONFIG
packages:
- "symfony/dom-crawler: ~2.3"
- "symfony/css-selector: ~2.3"
CONFIG;
use Symfony\Component\DomCrawler\Crawler;
$html = <<<HTML
@lantrinh1999
lantrinh1999 / mac-setup-redis.md
Created February 7, 2022 06:40 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@lantrinh1999
lantrinh1999 / Custom.txt
Created April 29, 2021 03:20 — forked from mzaman/Custom.txt
Custom data pagination with Laravel 5
<?php namespace App\Http\Controllers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class SearchController extends Controller {
public function search()
{
.
@lantrinh1999
lantrinh1999 / Category.php
Created March 17, 2021 06:20 — forked from brunocmoraes/Category.php
Eloquent: Recursive hasMany Relationship with Unlimited Subcategories
<?php
class Category extends Model
{
public function categories()
{
return $this->hasMany(Category::class);
}
public function childrenCategories()
@lantrinh1999
lantrinh1999 / AppServiceProvider.php
Last active September 1, 2020 02:38 — forked from reinink/AppServiceProvider.php
Multi-page Vue App in Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Factory as ViewFactory;
class AppServiceProvider extends ServiceProvider
{