Skip to content

Instantly share code, notes, and snippets.

View manh-dan's full-sized avatar
🎯
Focusing

Huynh Manh Dan manh-dan

🎯
Focusing
View GitHub Profile
@manh-dan
manh-dan / in_your_functions.php
Created October 20, 2020 02:24 — forked from kwbtdisk/in_your_functions.php
[WordPress] Integration with Ajax Search Lite & Bogo (Adjust the seach query for the page's language)
// Adjust the seach query of Ajax Search Lite with Bogo
add_action('asl_query_add_args', 'ajax_search_light_and_bogo_integration', 100, 1);
function ajax_search_light_and_bogo_integration( $args ) {
global $wpdb;
// Bogo saves the page language into the cookie, so we can just pick it.
$loc = $_COOKIE['lang'];
if(!$loc) { return $args; }
$args['where'] .= <<<SQL
AND ID IN ((
@manh-dan
manh-dan / gist:0b6cfe21e1991fb871ff9f851fbe42f3
Created October 20, 2020 02:28 — forked from thachpham92/gist:d57b18cf02e3550acdb5
Tất cả các tham số trong WP_Query
// Source: https://gist.github.com/luetkemj/2023628
// Xem hướng dẫn WP_Query toàn tập: http://goo.gl/kRpzTz
<?php
$args = array(
//////Author Parameters - Tham số lấy bài viết theo tác giả
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
'author' => '1,2,3,', //(int) - Các ID tác giả cần lấy bài viết (thêm dấu - vào để loại trừ tác giả, ví dụ: -14, -20)
'author_name' => 'luetkemj', //(string) - Lấy bài viết dựa theo tên nick name của tác giả
'author__in' => array( 2, 6 ), //(array) - Lấy bài dựa theo ID của tác giả
@manh-dan
manh-dan / Start-Vagrant.bat
Created October 27, 2020 02:27 — forked from Iristyle/Start-Vagrant.bat
Windows startup script to fire up a Vagrant VM safely on boot (using Run registry key for instance)
ECHO OFF
cd /d %~dp0
for /f "tokens=2* delims= " %%F IN ('vagrant status ^| find /I "default"') DO (SET "STATE=%%F%%G")
ECHO Close this window if it remains open, and http://localhost:8081 is responsive
IF "%STATE%" NEQ "saved" (
ECHO Starting Vagrant VM from powered down state...
vagrant up
) ELSE (
@manh-dan
manh-dan / README.md
Created November 4, 2020 15:22 — forked from mul14/README.md
Simple Laravel Search Trait

Usage

Put SearchTrait.php in app directory. Then use SearchTrait in your model, like so

use App\SearchTrait;
use Illuminate\Database\Eloquent\Model;

class Article extends Model 
{
@manh-dan
manh-dan / CheckForMaintenanceMode.php
Created November 5, 2020 09:56 — forked from harini-ua/CheckForMaintenanceMode.php
Custom middleware Laravel 5 check for maintenance mode.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Routing\Route;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Original;
@manh-dan
manh-dan / android-generate-keystores.md
Created December 28, 2020 13:53 — forked from henriquemenezes/android-generate-keystores.md
Android: Generate Release/Debug Keystores

Android: Generate Release/Debug Keystores

Generate Keystores

Debug Keystore

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
@manh-dan
manh-dan / social.blade.php
Created January 5, 2021 04:46 — forked from james2doyle/social.blade.php
Social Share Links in Laravel Blade syntax
<a href="https://www.facebook.com/sharer.php?u={{ $url }}" rel="me" title="Facebook" target="_blank"><i class="fa facebook"></i></a>
<a href="https://twitter.com/share?url={{ $url }}&text={{ $title }}" rel="me" title="Twitter" target="_blank"><i class="fa twitter"></i></a>
<a href="https://pinterest.com/pin/create/button/?url={{ $url }}&media={{ $image }}&description={{ $title }}" rel="me" title="Pinterest" target="_blank"><i class="fa pinterest"></i></a>
<a href="https://www.thefancy.com/fancyit?ItemURL={{ $url }}&Title={{ $title }}&Category={{ $category }}&ImageURL={{ $image }}" rel="me" title="Fancy" target="_blank"><i class="fa fancy"></i></a>
<a href="https://plus.google.com/share?url={{ $url }}" rel="me" title="Google Plus" target="_blank"><i class="fa google"></i></a>
@manh-dan
manh-dan / gist:1f39e55bf99d8902e168fa5a7423a099
Created April 10, 2021 05:54 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@manh-dan
manh-dan / strong-passwords.php
Created April 21, 2021 08:27 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@manh-dan
manh-dan / laravel-queue.service
Created May 5, 2021 06:37 — forked from thomasjsn/laravel-queue.service
Laravel queue worker using systemd.
# Laravel queue worker using systemd
# ----------------------------------
#
# /lib/systemd/system/queue.service
#
# run this command to enable service:
# systemctl enable queue.service
[Unit]
Description=Laravel queue worker