Skip to content

Instantly share code, notes, and snippets.

View msonowal's full-sized avatar
I zapp it.

Manash Sonowal msonowal

I zapp it.
View GitHub Profile
@msonowal
msonowal / mysql-docker.sh
Created August 16, 2019 12:28 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@msonowal
msonowal / cookie-server.service.ts
Created July 5, 2019 20:48 — forked from bastienlemaitre/cookie-server.service.ts
ngx-cookie-service for Angular Universal
@msonowal
msonowal / Dockerfile.fails
Created April 11, 2019 10:00 — forked from briceburg/Dockerfile.fails
docker - example adding www-data user to alpine images
FROM nginx:alpine
# stock verison from php:alpine image
# ensure www-data user exists
RUN set -x \
&& addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -G www-data www-data
# 82 is the standard uid/gid for "www-data" in Alpine
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
@msonowal
msonowal / PusherService.js
Created March 25, 2019 06:45 — forked from dobromir-hristov/PusherService.js
Busting SPA chunk cache for active users after a deploy
import Pusher from 'pusher-js'
Pusher.logToConsole = process.env.NODE_ENV === 'development'
export const PusherService = new Pusher(process.env.PUSHER_KEY, {
cluster: 'eu',
encrypted: true
})
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -U postgres
@msonowal
msonowal / scrollTo.md
Created March 13, 2019 11:26 — forked from BryanHeath/scrollTo.md
Laravel Dusk scrollTo Macro
Browser::macro('scrollTo', function($selector) {
    $this->driver->executeScript("$(\"html, body\").animate({scrollTop: $(\"$selector\").offset().top}, 0);");
    return $this;
});
@msonowal
msonowal / Laravel-Container.md
Created January 15, 2019 18:51
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

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).

@msonowal
msonowal / inputTypeNumberPolyfill.js
Created December 10, 2018 10:08 — forked from nbouvrette/inputTypeNumberPolyfill.js
Stand alone JavaScript polyfill allow only numbers on input of type number.
/**
* Stand alone polyfill allow only numbers on input of type number.
*
* While input filtering is already supported by default by some browsers, maximum length has not been implemented by
* any. This script will solve both issue and make sure that only digits can be entered in input elements of type
* number. If the optional attribute `max` is set, it will calculate it's length and mimic the `maxlength` behavior on
* input of type text.
*
* Supports:
*
@msonowal
msonowal / coverage_for_dusk.php
Created September 14, 2018 15:55 — forked from jleonardolemos/coverage_for_dusk.php
generating code coverage for Laravel Dusk tests
<?php
/**
* This is a tool for help coverage generation on Dusk
* This was based on this article: http://tarunlalwani.com/post/php-code-coverage-web-selenium/
*1. add this file to your laravel tests directory
*2. add the following line to your nginx config:
* fastcgi_param PHP_VALUE "auto_prepend_file=\"/absolute_path/tests/coverage_for_dusk.php\"";
* if you are using apache you can use this line on .htaccess:
* php_value auto_prepend_file "/absolute_path/tests/coverage_for_dusk.php"
*3. Sample test:
Route::get('/js/lang.js', function () {
Cache::forget('lang.js');
$strings = Cache::rememberForever('lang.js', function () {
$lang = config('app.locale');
$files = glob(resource_path('lang/' . $lang . '/*.php'));
$strings = [];
foreach ($files as $file) {