Skip to content

Instantly share code, notes, and snippets.

View antonybudianto's full-sized avatar
💪
Build up!

Antony Budianto antonybudianto

💪
Build up!
View GitHub Profile
@antonybudianto
antonybudianto / route51
Last active August 29, 2015 14:22
Auth Route Laravel 5.1
// Route for authentication
Route::group(['namespace' => 'Auth'], function() {
Route::group(['prefix' => 'auth'], function() {
// Authentication routes...
get('login', 'AuthController@getLogin');
get('logout', 'AuthController@getLogout');
post('login', 'AuthController@postLogin');
// Registration routes...
get('register', 'AuthController@getRegister');
if($request->hasFile('image'))
{
$file = $request->file('image');
$fileName = 'IMGP'.date('YmdHis').rand(1,100).'.'.$file->getClientOriginalExtension();
$file->move('img/post', $fileName);
$data['image'] = $fileName;
}
else
{
return redirect(route('admin.post').'/create')->withErrors(['Please choose the image to upload']);
@antonybudianto
antonybudianto / helpers
Last active August 29, 2015 14:22
Helper for form in L5.1
<?php
if(! function_exists('form_model')) {
function form_model($object = false)
{
return function($name) use ($object)
{
if(!$object) return old($name);
else return isset($object) ? $object->$name : old($name);
};
}
@antonybudianto
antonybudianto / Squash Commit PR
Created August 5, 2015 01:41
Squash Commit PR
Squash PR Commits to One Commit:
1. Clone branchnya (misalkan nama branchnya patch-1)
git clone http://github.com/repo --branch patch-1 D:/test
2. git pull origin patch-1
3. git status, pastiin udah match origin ama local
4. Cek statusnya pake git log, pastikan commit yg mau digabung ada disana
5. git rebase -i HEAD~2 (2 berarti 2 commit terakhir)
6. Pas muncul, PASTIKAN cuma 2 commit yang kelist
# kalau isinya "noop" ato malah semua commit kelist:
# batalin aja: ctrl-c -> tutup buka lagi -> git rebase --abort
@antonybudianto
antonybudianto / htaccess-laravel5
Created August 11, 2015 17:06
htaccess for Laravel 5 public_html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
#!/bin/bash
ID_RSA="$OPENSHIFT_DATA_DIR/.ssh/id_rsa"
KNOWN_HOSTS="$OPENSHIFT_DATA_DIR/.ssh/known_hosts"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $ID_RSA $1 $2
# JavaScript Design Pattern
## Prototype Inheritance
function __extends(Child, Parent) {
Child.prototype = new Parent();
}
function Person(name) {
this.name = name;
this.hello = function() {
git fetch origin # Updates origin/master
git rebase origin/master # Rebases current branch onto origin/master
git rebase -i HEAD~3 # Rebases last 3 commits
<% _.forEach(env, function(v, k) { %>
global.___ENV__['<%= k %>'] = '<%= v %>';
<% }) %>
function hasPairOfSum(arr, sum){
var flag;
for(let i=0;i<arr.length;i++) {
if (flag === arr[i]) { return true; }
else if (arr[i] !== sum/2) { continue; }
else if(!flag) { flag = arr[i]; }
}
return false;
}