Skip to content

Instantly share code, notes, and snippets.

@RakibSiddiquee
RakibSiddiquee / formatNumber.php
Created August 5, 2017 07:32
Format number function add K for thousand, M for million and B for Billion...
<?php
function fFormatNumberToKMB($value){
if ($value > 999 && $value <= 999999) {
$result = floor($value / 1000) . ' K';
} elseif ($value > 999999 && $value <= 999999999) {
$result = floor($value / 1000000) . ' M';
} elseif ($value > 999999999){
$result = floor($value / 1000000000) . ' B';
}else {
@RakibSiddiquee
RakibSiddiquee / tinymce-image-browse.txt
Created August 9, 2017 10:38
Upload image with from imagebox of tinymce
1. Add following input file right after textarea field...
<input name="image" type="file" id="upload" class="hidden" onchange="">
2. Add the following code in tinymce jquery code block...
file_picker_callback: function(callback, value, meta) {
if (meta.filetype == 'image') {
$('#upload').trigger('click');
$('#upload').on('change', function() {
var file = this.files[0];
@RakibSiddiquee
RakibSiddiquee / cookie-webpage-sticky.php
Last active August 29, 2017 12:20
Set cookie and show sticky modal ads by blocking full browser window
@RakibSiddiquee
RakibSiddiquee / server-command.txt
Last active September 17, 2017 09:12
The linux server commands...
'nano filename.txt' command to open a file in cmd
'cat filename.txt' command to show the updated file after edit
'chown -R username.username foldername' to change user permission of a folder
<?php
$data = [1,2,3,4,5,6,7,8,9,10];
$i=1;
$count = count($data);
foreach($ar as $a){
if($i == 1) echo '<div class="item">';
echo '<div>'.$i.'</div>';
@RakibSiddiquee
RakibSiddiquee / Laravel-custom-validation-message.txt
Created January 8, 2018 20:31
Laravel custom validation error message
$this->validate($request, [
'heading' => 'required',
'category' => 'required',
'details' => 'required',
],[
'heading.required' => 'লেখার শিরোনাম প্রদান করুন!',
'category.required' => 'একটি ক্যাটাগরি নির্বাচন করুন!',
'details.required' => 'বিস্তারিত লেখা প্রদান করুন!',
]);
@RakibSiddiquee
RakibSiddiquee / recapcha.php
Created January 29, 2018 07:30
Google recapcha v2 implementation in php
<?php
//To start using reCAPTCHA, you need to sign up for an API key pair for your site from https://www.google.com/recaptcha/admin#list
$siteKey = "6LcqlUAUAAAAAFqZqFzhtEHApepRVPtv-Xynkub9";
$secretKey = "6LcqlUAUAAAAADt1b9okVcSrgC0461J9NyTzNqlY";
$gres = $_POST['g-recaptcha-response'];
$ip = $_SERVER['REMOTE_ADDR'];
$suc = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secretKey.'&response='.$gres.'&remoteip='.$ip);
$res = json_decode($suc);
@RakibSiddiquee
RakibSiddiquee / php-pagination.txt
Created February 19, 2018 14:52
Basic php PDO pagination
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fan Club List</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
@RakibSiddiquee
RakibSiddiquee / watermark.php
Created July 17, 2018 10:47
Place watermark over an image in PHP or place any image over another image
<?php
// Load the logo stamp and the photo to apply the watermark to
$logo = imagecreatefrompng('https://cdn.jagonews24.com/media/common/og-logo.png');
//$logo = imagecolorallocate($logo,0,0,0);
$img = imagecreatefromjpeg('https://cdn.jagonews24.com/media/imgAll/2018June/shahin-cover-20180711084009.jpg');
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
@RakibSiddiquee
RakibSiddiquee / unique-number.php
Created September 8, 2018 13:00
PHP unique number generate function
<?php
function uniqueNumber(){
$unqNo = strtotime(date("Ymdhis"))*999;
return $unqNo;
}