Skip to content

Instantly share code, notes, and snippets.

View monbang's full-sized avatar
🌴
On vacation

monbang

🌴
On vacation
View GitHub Profile
@monbang
monbang / .vimrc
Created April 25, 2020 05:12
my vimrc
call plug#begin('~/.vim/plugged')
Plug 'sheerun/vim-polyglot'
Plug 'editorconfig/editorconfig-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'justinmk/vim-sneak'
Plug 'lambdalisue/vim-gista'
Plug 'tpope/vim-sensible'
Plug 'jremmen/vim-ripgrep'
@monbang
monbang / new
Created April 22, 2020 06:15
Gate auth
File: AuthServiceProvider
public function boot()
{
$this->registerPolicies();
Gate::define('update-product', function(User $user, Product $product) {
return $product->user->is($user);
});
}
@monbang
monbang / Git
Last active April 21, 2020 14:49
Git
# remove file form a commit
$git reset HEAD^ path/to/file/to/revert
$git commit --amend
# add file to a commit
$git add path/to/file/to/add
$git commit --amend
@monbang
monbang / Frontend authorization
Created April 20, 2020 04:58
Frontend authorization
Frontend authorization:-
=======================================================================================
1. A little bit clunky approach
file: posts.blade.php
<blog-post :post="{{ $post }}" :can-update="@json(auth()->user()->can('update', $post))"></blog-post>
@monbang
monbang / lookup table
Created April 19, 2020 03:08
lookup table
<?php
/**
* Refactor #1:
*/
// Before
if ($user->type === 'admin' || $user->type === 'mod' || $user->type === 'author') {
// Do something.
}
@monbang
monbang / jq
Created April 17, 2020 05:36
jq
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) {
@monbang
monbang / mozilla ssh
Created April 15, 2020 09:49
mozilla ssh
Mozilla SSH
Link: https://infosec.mozilla.org/guidelines/openssh
@monbang
monbang / spa-tips-1
Created April 11, 2020 13:17
spa-tips-1
//app/Http?Kernel.php
'web' => [
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
]
// resources/js/bootstrap.js
window.axios.interceptors.response.use(undefined, function(error) {
switch(error.response.status) {
@monbang
monbang / v-cloak
Created April 11, 2020 05:09
v-cloak
COPIED FROM:- https://gist.githubusercontent.com/adamwathan/3584d1904e4f4c36096f/raw/66b5205fe189203b044eb0988b4fc0920bab897b/v-cloak.md
=================================================================================
Handy helpers for controlling visibility of elements until Vue has compiled.
Use like:
```html
<div v-cloak>
@monbang
monbang / Hierarchical-recursive-query
Created April 8, 2020 06:38
Hierarchical-recursive-query
Hierarchical-recursive-query