Skip to content

Instantly share code, notes, and snippets.

View AnowarCST's full-sized avatar

Anowar Hossain AnowarCST

View GitHub Profile
@AnowarCST
AnowarCST / ProfileTest.php
Last active January 29, 2020 11:26
Test Case for ProfileController
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use Faker\Generator as Faker;
@AnowarCST
AnowarCST / ProfileController.php
Last active January 29, 2020 14:06
Sample ProfileController for Medium Post
<?php
namespace App\Http\Controllers\API\V1;
use App\Http\Controllers\Controller;
use App\Http\Requests\Users\ChangePasswordRequest;
use App\Http\Requests\Users\ProfileUpdateRequest;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
# Install these packages (use your favorite AUR tool here)
yay -S minikube-bin kubectl-bin docker-machine-driver-kvm2 libvirt qemu-headless docker-machine ebtables
# Get libvirt going
sudo systemctl enable libvirtd.service
sudo usermod -a -G libvirt $(whoami)
# This fix thanks to http://blog.programmableproduction.com/2018/03/08/Archlinux-Setup-Minikube-using-KVM/
sudo virsh net-autostart default
@AnowarCST
AnowarCST / MobileNumberValidator.php
Created October 10, 2018 09:34
Validate local and international mobile no. Extract local mobile no.
<?php
namespace App\Http\Requests;
class MobileNumberValidator
{
/**
* Validate local/international Mobile No
*
@AnowarCST
AnowarCST / motionSensor.cpp
Last active April 27, 2017 16:03
PIR Motion Sensor with Arduino
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;
//the time when the sensor outputs a low impulse
long unsigned int lowIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000;
@AnowarCST
AnowarCST / fish.html
Created August 14, 2016 18:21
just fun: javascript fish
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fish</title>
<style>
*{
line-height: 15px;
}
.color{
@AnowarCST
AnowarCST / 01_Laravel 5 Simple ACL manager_Readme.md
Created August 2, 2016 10:08 — forked from amochohan/01_Laravel 5 Simple ACL manager_Readme.md
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@AnowarCST
AnowarCST / Convert.php
Last active July 28, 2016 11:58
convertUTF8
public static function convertUTF8($string)
{
//$sampleString = 'u0986u09a8u09c7u09beu09dfu09beu09b0 u09b9u09c7u09beu09b8u09beu0987u09a8';
$string = preg_replace('/u([0-9a-fA-F]+)/', '&#x$1;', $string);
return html_entity_decode($string, ENT_COMPAT, 'UTF-8');
}
<?php
/**
* Description of NameCompare
*
* @abstract String/Name compare with metaphone like soundex
* @return Percentage of matching with two string
* @description [The metaphone() function calculates the metaphone key of a string.
* It's more accurate than soundex() as it knows the basic rules of English pronunciation.
* The metaphone() function can be used for spelling applications.]
@AnowarCST
AnowarCST / exportCSV_Zip.php
Created August 6, 2015 07:43
export data in CSV with Zip. (Its so usefull to download the big size data)
<?php
function exportCSV_Zip($id, $data) {
$this->load->library('zip'); //load CodeIgniter Zip Library
$csv_data = '';
if ($data && count($data[0]) > 0) {
$rc = 0;
foreach ($data[0] as $key => $value) {
if ($rc > 0) {
$csv_data .= ',';