Skip to content

Instantly share code, notes, and snippets.

View dinhquochan's full-sized avatar
😇
Hello Friend!

Dinh Quoc Han dinhquochan

😇
Hello Friend!
View GitHub Profile
@dinhquochan
dinhquochan / Str.php
Last active November 17, 2016 12:29
String Helpers
<?php
/**
* @package String Helpers
* @version 1.0
* @author Dinh Quoc Han <me@henrydinh.com>
* @link https://henrydinh.com
* @license MIT
*/
class Str
@dinhquochan
dinhquochan / QueriesDate.php
Last active August 12, 2016 17:17
Generating archive list for a blog in Laravel
$links = DB::table('post')
->select(DB::raw('YEAR(created_at) year, MONTH(created_at) month, MONTHNAME(created_at) month_name, COUNT(*) post_count'))
->groupBy('year')
->groupBy('month')
->orderBy('year', 'desc')
->orderBy('month', 'desc')
->get();
@dinhquochan
dinhquochan / facebook-comment.css
Created November 9, 2016 16:12
Responsive Facebook Comment
.fb_iframe_widget,
.fb_iframe_widget span,
.fb_iframe_widget span iframe[style],
.fb-comments span,
.fb-comments iframe {
width: 100% !important;
}
@dinhquochan
dinhquochan / call.html
Last active September 15, 2017 04:46
Call button with CSS & HTML
<a href="tel:<phone number>" title="" class="btn-call">
<span><i class="fa fa-phone"></i></span>
</a>
@dinhquochan
dinhquochan / content.css
Last active April 20, 2018 04:57
A Full and Comprehensive Style Test
.fv-content {
margin: 0 auto;
font-size: 1rem;
line-height: 1.6em;
font-family: Arial, Georgia, serif;
padding: 1vw 2vw 0;
}
@media (max-width: 1170px) {
.fv-content {
@dinhquochan
dinhquochan / GitHub.icls
Last active January 23, 2019 10:01 — forked from freekmurze/GitHub.icls
GitHub PhpStorm Colorscheme
<scheme name="GitHub" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2019-01-23T16:58:34</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2018.3.3.0.0</property>
<property name="modified">2019-01-23T16:58:37</property>
<property name="originalScheme">GitHub</property>
</metaInfo>
<option name="LINE_SPACING" value="1.8" />
@dinhquochan
dinhquochan / git-prompt.sh
Created October 25, 2018 04:07
Git Prompt
PS1='\n'
PS1="$PS1"'\[\033[33m\]'
PS1="$PS1"'\w'
if test -z "$WINELOADERNOEXEC"
then
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
@dinhquochan
dinhquochan / sluggify.js
Last active November 8, 2018 04:50
Generate a URL friendly "slug" from a given string
const sluggify = (title) => {
title = title.replace(/^\s+|\s+$/g, "")
title = title.toLowerCase()
let original = title
let from = "àáảãạäăắằẳẵặâầấẩẫậđèéẻẽẹêềếểễệëìíỉĩịïîòóỏõọöôồốổỗộơờớởỡợùúủũụưừứửữựüûyỳýỷỹỵñç·/_,:;"
let to = "aaaaaaaaaaaaaaaaaadeeeeeeeeeeeeiiiiiiioooooooooooooooooouuuuuuuuuuuuuyyyyyync------"
@dinhquochan
dinhquochan / .zsh_aliases
Created October 31, 2018 14:55
ZSH Aliases
alias laralog="tail -f -n 450 storage/logs/laravel*.log | grep -i -E \"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:\" --color"
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias wip="git add . && git commit -m 'wip'"
alias nah='git reset --hard;git clean -df'
alias art='php artisan'
alias a='php artisan'
alias tinker='php artisan tinker'
alias migarte='php artisan migrate'
alias mfs='php artisan migrate:fresh'
@dinhquochan
dinhquochan / groupBy.php
Last active December 3, 2018 04:37
GroupBy Laravel Posts by Year and Month
<?php
use App\Post;
$posts = Post::query()
->selectRaw(
'YEAR(`published_at`) as `year`, MONTH(`published_at`) as `month`, MONTHNAME(`published_at`) as `month_name`, COUNT(id) as `posts_count`'
)
->groupBy('year')
->groupBy('month')