Skip to content

Instantly share code, notes, and snippets.

View luqmanrom's full-sized avatar

Luqman Rom luqmanrom

View GitHub Profile
@luqmanrom
luqmanrom / createVhost.sh
Created July 18, 2016 10:25 — forked from tombeynon/createVhost.sh
Programmatically create Apache VHost
#!/bin/bash
# /usr/local/bin/createSite.sh -d domain -t com -u user -p password -r git@github.com:user/repo.git
# TODO: SCP could be done in reverse
domain=''
tld=''
username=''
password=''

APACHE

  • Add headers field to allow CORS
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
$begin = new DateTime( '2010-05-01' );
$end = new DateTime( '2010-05-10' );
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
foreach ( $period as $dt )
echo $dt->format( "l Y-m-d H:i:s\n" );
@luqmanrom
luqmanrom / git.sh
Last active July 30, 2018 10:10
Showing git branch on command line and also git alias for commands that are commonly used
# For showing branch on command line
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
# Alias for git
alias gs='git status '
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="luqman.rom@falcon-agency.com"
CORRECT_NAME="Luqman Rom"
CORRECT_EMAIL="luqmanrom@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
@luqmanrom
luqmanrom / seed.php
Created May 17, 2016 02:55
Seed many to many relationship
public function run()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('user_account')->truncate();
$users = \App\User::all();
$account_ids = \DB::table('accounts')->select('id')->lists('id');
@luqmanrom
luqmanrom / laravel_db.php
Created May 16, 2016 03:31
Listen database operation and dump the sql query
DB::listen(function($query) { var_dump($query->sql); });
$from = new \DateTime($from);
$from_iso_week = date_format($from,"W");
$from_year = date_format($from,"o");
@luqmanrom
luqmanrom / README.md
Created May 9, 2016 02:21 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@luqmanrom
luqmanrom / deleteBranch.sh
Created May 9, 2016 02:14
Delete git branch using regex pattern
#!/bin/bash
git branch -D `git branch | grep -E 'lr*'`