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 / FizzBuzz.java
Created November 1, 2017 17:14
FizzBuzz Problem
public static void main(String[] args){
for(int x=1;x<=100;x++){
if(x%3==0){
System.out.print("Fizz");
if(x%5==0){
System.out.print("Buzz");
}
@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(".*[@#$%].*"))
@afiqiqmal
afiqiqmal / Bash alias
Created November 3, 2017 06:34 — forked from xmhafiz/Bash alias
Some lazy bash aliases
#laravel
alias pa="php artisan"
#git
alias gi="git init"
alias gs="git status"
alias ga="git add"
alias gc="git commit -m"
alias gac="git add .;git commit -m"
alias gp="git push"
@afiqiqmal
afiqiqmal / Birthdate Parser.js
Created November 9, 2017 09:33 — forked from crynobone/Birthdate Parser.js
Malaysia Indentification Card Number to Birthdate
var ic = '090303086521';
if(ic.match(/^(\d{2})(\d{2})(\d{2})-?\d{2}-?\d{4}$/)) {
var year = RegExp.$1;
var month = RegExp.$2;
var day = RegExp.$3;
console.log(year, month, day);
var now = new Date().getFullYear().toString();
@afiqiqmal
afiqiqmal / AppServiceProvider.php
Last active May 26, 2018 13:19
Creating custom path in laravel
public function boot()
{
...
...
$this->app->bind('path.tenant', function () use ($tenant) {
return "tenant_{$tenant->id}";
});
...
}
@afiqiqmal
afiqiqmal / helpers.php
Last active January 17, 2018 13:32
Helper function for focusing on Laravel Storage. Easier to save and get files
<?php
if (! function_exists('store_file')) {
/**
* @param $file
* @param string $disk
* @param bool $add_time
* @param bool $replace_space
* @param null $prefix
@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 / dependencies.gradle
Created December 9, 2017 02:30
Excluding multiple group from Android dependencies gradle
dependencies {
compile ('pl.charmas.android:android-reactive-location2:2.0@aar') {
['com.android.support', 'com.google.android.gms', 'io.reactivex.rxjava2'].each{
exclude group: it
}
}
}
@afiqiqmal
afiqiqmal / ItemClickCallback.java
Last active December 10, 2017 02:02
Recyclerview Android Single Choice with Callback
public interface ItemClickCallback<Item> {
public void onItemClick(Item item);
}
@afiqiqmal
afiqiqmal / FragmentA.java
Created January 3, 2018 03:29
Set On Activity Result with fragment
Fragment fragment = new TaskFormFragment();
fragment.setTargetFragment(this, 1000);
getFragmentManager()
.beginTransaction()
.replace(R.id.frame_map, fragment, "form")
.addToBackStack("form")
.commit();