Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@aprilmintacpineda
aprilmintacpineda / Using Multiple SSH keys - Beginner Friendly.md
Last active September 13, 2024 11:49
Beginner Friendly: Using Multiple SSH keys

How to follow this guide

The problem

I have one computer and two different github accounts. One is for work, the other is for my personal stuff. I can't use the same ssh key twice, so I have to use different ssh key for each of my accounts. How do I do that? How do I switch between these ssh keys?

@psychonetic
psychonetic / CustomVeeValidator
Last active April 4, 2020 07:02
Vue-Dropzone and Vee-Validate
// Custom Validator to add errors into vuex store and also handle laravel form errors.
import { mapGetters } from 'vuex';
import { CLEAR_FORM_ERRORS, ERROR } from '../vuex/types';
import Vue from 'vue';
export default {
data() {
return {
errors: [],
keepServerErrors: ['unique', 'boolean', 'exists', 'regular_chars', 'identifier', 'date'],
@meSingh
meSingh / JsonMiddleware.php
Last active July 11, 2022 09:19
If you are using laravel as api only, you might want to return JSON on every request, even on errors/exceptions. The easiest way to do so is using this middleware globally.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class JsonMiddleware
{
public function handle(Request $request, Closure $next)
@brunogaspar
brunogaspar / macro.md
Last active September 15, 2024 18:42
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

@Konafets
Konafets / EditInlineTemplate.blade.php
Last active January 22, 2019 08:28
VueJS Inline Template in Blade
<my-component inline-template>
<h1>@lang('users.edit') {{ $user->name }}</h1>
<form method="post" action="{{ route('users.update', ['user' => $user]) }}">
{!! csrf_field() !!}
<input name="_method" type="hidden" value="PATCH">
<!-- Some form fields -->
<button type="submit">{{ __('button.update') }}</button>
</form>
@cyberfly
cyberfly / CheckRequestPermission.php
Last active November 28, 2017 06:40
Form Request trait for route validation and role permission
<?php namespace App\Traits;
use App\MeetingApprovalCommittee;
use App\Role;
trait CheckRequestPermission {
/**
* Check role permission to form request class to be validated
*
@NishiGaba
NishiGaba / iterate-over-array.js
Last active November 29, 2023 10:27
8 Methods to Iterate through Array
//8 Methods to Iterate through Array
//forEach (Do Operation for Each Item in the Array)
[1,2,3].forEach(function(item,index) {
console.log('item:',item,'index:',index);
});
//map (Translate/Map all Elements in an Array to Another Set of Values.)
const oneArray = [1,2,3];
const doubledArray = oneArray.map(function(item) {
@cyberfly
cyberfly / gittips.txt
Created May 24, 2017 01:56
How do I resolve git saying “Commit your changes or stash them before you can merge”? https://stackoverflow.com/a/15745424/417899
You can't merge with local modifications. Git protects you from losing potentially important changes.
You have three options.
1. Commit the change using
git commit -m "My message"
2. Stash it.
Stashing acts as a stack, where you can push changes, and you pop them in reverse order.
@cyberfly
cyberfly / new_gist_file_0
Created May 9, 2017 07:20
GIT untracked changes to local config file
You could update your index:
cd /root/folder/of/your/repo
git update-index --assume-unchanged nbproject/project.properties
and make sure it never shows as "updated" in your current repo.
That means it won't ever been pushed, but it is still present in the index.
(and it can be modified at will in your local working tree).
@cyberfly
cyberfly / gist:5f1f95981bfc11a7bcb5343ed03ccfff
Last active April 18, 2017 04:44
NPM, Bower and Grunt Command when working with AngularJS project
//things to do after clone angular project
npm install
bower install
grunt wiredep
grunt server
//check version of all installed bower packages
bower list --json=0 --offline
//update angular version using bower