Skip to content

Instantly share code, notes, and snippets.

View achmadfatoni's full-sized avatar
🏠
Working from home

Achmad Fatoni achmadfatoni

🏠
Working from home
View GitHub Profile
@achmadfatoni
achmadfatoni / delete all merged branch.sh
Last active August 26, 2016 04:56
Delete all merged local branch
git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
@achmadfatoni
achmadfatoni / git status all folder
Created August 25, 2016 09:54
Git status all git in current folder
for D in *; do
if [ -d "${D}" ]; then
echo "${D}" # your processing here
cd "${D}"
git status -s
cd ..
fi
done
@achmadfatoni
achmadfatoni / git-rename-local-branch.md
Last active August 26, 2016 04:07
Git rename local branch

If you want to rename a branch while pointed to any branch, do :

git branch -m <oldname> <newname>

If you want to rename the current branch, you can do:

git branch -m <newname>

A way to remember this, is -m is for "move" (or mv), which is how you rename files.

@achmadfatoni
achmadfatoni / redirect.js
Created September 2, 2016 04:53
Redirect page javascript
window.location = "http://www.yoururl.com";
@achmadfatoni
achmadfatoni / validation.php
Created September 8, 2016 03:00
Laravel unique validation on update
public function rules()
{
$user = User::find($this->users);
switch($this->method())
{
case 'GET':
case 'DELETE':
{
return [];
@achmadfatoni
achmadfatoni / slug-validation.php
Created September 8, 2016 03:36
Laravel slug validation
Validator::extend('slug', function($attribute, $value, $parameters, $validator) {
return preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $value);
});
@achmadfatoni
achmadfatoni / app.blade.php
Created September 17, 2016 00:42
Parent view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
@achmadfatoni
achmadfatoni / create.blade.php
Created September 17, 2016 00:45
create.blade.php
@extends('app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">Todo List</div>
<div class="panel-body">
<form role="form" method="POST" action="{{ url('/todos') }}">
@achmadfatoni
achmadfatoni / index.blade.php
Last active September 17, 2016 01:55
index.blade.php
@extends('app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Todo List</div>
<div class="panel-body">
<a href="{{ url('todos/create') }}" class="btn btn-primary">Add todo</a>
@achmadfatoni
achmadfatoni / edit.blade.php
Last active September 17, 2016 01:56
edit.blade.php
@extends('app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">Todo List</div>
<div class="panel-body">
<form role="form" method="POST" action="{{ url('/todos/' . $todo->id) }}">
{{ csrf_field() }}