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>
@antonybudianto
antonybudianto / htaccess laravel public in shared hosting
Last active October 16, 2021 16:58
remove /public when deploy Laravel on shared hosting
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
echo "Installing composer dependencies..."
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev --ignore-platform-reqs
rm -f composer.phar
#rm -rf $OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npmrc
#mkdir -p $OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npmrc
#export NPM_CONFIG_USERCONFIG=$OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npmrc
#rm -rf $OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npm
#mkdir -p $OPENSHIFT_HOMEDIR/app-root/build-dependencies/.npm
#!/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