Skip to content

Instantly share code, notes, and snippets.

View afiqiqmal's full-sized avatar
👻
I may be slow to respond.

Hafiq afiqiqmal

👻
I may be slow to respond.
View GitHub Profile
@afiqiqmal
afiqiqmal / SocialController.php
Last active January 12, 2024 03:25
Example usage of Socialite with one Controller in Laravel
<?php
namespace App\Http\Controllers;
use App\Traits\SocialUsers;
use Illuminate\Http\Request;
use Laravel\Socialite\Facades\Socialite;
class SocialController extends Controller
{
@afiqiqmal
afiqiqmal / ALaravelPipelineReadme.md
Last active December 27, 2023 10:24
Laravel Query Filter using Pipeline

Donate

Laravel Query Filter using Pipeline

Basically, with a pipeline we can pass an object through a stack of tasks and get the result via a callback.

Refer Here -> https://laravel.com/api/7.x/Illuminate/Pipeline/Pipeline.html

The method handle used to execute the task receives two parameters, the first is the object that we passed to our pipeline, the second is a closure, where the object will be sent to run the next task.

@afiqiqmal
afiqiqmal / 2019_11_03_081136_alter_all_table_id.php
Last active July 28, 2023 21:57
Migrate bigIncrements to increments with foreign key attached
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 03/11/2019
* Time: 11:36 PM
*/
use Illuminate\Support\Facades\Schema;
@afiqiqmal
afiqiqmal / ImageMaliciousDetectionRule.php
Last active June 19, 2023 23:22
Simple Laravel Validation Rule for Image Content Validation.
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class ImageMaliciousDetectionRule implements Rule
{
protected $malicious_keywords = [
'\\/bin\\/bash',
@afiqiqmal
afiqiqmal / GoogleGeocode.php
Created February 10, 2022 13:48
Helper class for geocode mapping
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Http;
class GoogleGeocode
{
private $url = "https://maps.googleapis.com/maps/api/geocode/json";
@afiqiqmal
afiqiqmal / perfom.conf
Last active April 19, 2022 14:23
Detect Mobile Phone Agent in Nginx
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|ide
set $mobile_rewrite do_not_perform;
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|ide
@afiqiqmal
afiqiqmal / CustomIncomingMessage.php
Last active April 1, 2022 11:51
Laravel Botman Custom Driver Just for Combining Multiple Attachment to Single Upload Attachment
<?php
/**
* Created by PhpStorm.
* User: hafiq
* Date: 18/03/2018
* Time: 11:59 PM
*/
namespace App\Conversation\Custom;
@afiqiqmal
afiqiqmal / jstimeout.js
Created November 8, 2021 00:29
SetTimeout using Vuex Store
export const state = () => ({
intervalList: []
})
export const mutations = {
addWithArgument(state, {callback, args}) {
if (callback.name === undefined) {
return;
}
@afiqiqmal
afiqiqmal / PasswordValidator.java
Created November 1, 2017 17:15
This just a sample java code for password validator
public class PasswordValidator {
public static boolean validate(String password) {
if (password.matches("((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,20})"))
return true;
return false;
}
public static boolean symbol(String password) {
if (password.matches(".*[@#$%].*"))