Skip to content

Instantly share code, notes, and snippets.

<?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 / 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
@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 / 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 / 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 / BanglaDate.php
Last active August 4, 2017 10:10
Bangla date from english date. First we create a class and include the class in our required page, call the necessary methods and print our date variable.
//make a class...
class BanglaDate
{
private $timestamp; //timestamp as input
private $morning; //when the date will change?
private $engHour; //Current hour of English Date
private $engDate; //Current date of English Date
private $engMonth; //Current month of English Date
private $engYear; //Current year of English Date
@RakibSiddiquee
RakibSiddiquee / copyOnclick.html
Created July 31, 2017 08:14
Copy to clipboard by onclick
<!--Pass the url and id in input field-->
<input type="text" value="{{ config('app.url').config('appconfig.contentImagePath').$photo->img_path }}" id="url-{{ $photo->id }}" class="form-control" readonly>
<!--Pass the id in onclick button-->
<button type="button" onclick="copyUrl({{ $photo->id }})" class="btn btn-primary">Copy</button>
<!--The javascript code-->
<script>
function copyUrl(id){
//alert('hello');
@RakibSiddiquee
RakibSiddiquee / Laravel-Upload-in-cpanel.txt
Created July 18, 2017 12:43
When we upload laravel project in live server or cpanel. We should follow the following instructions...
Clear all view, route, config and cache
Upload the project in live server
After that upload the dot prefixed files in the live server
@RakibSiddiquee
RakibSiddiquee / get-last-7days-data.php
Created May 18, 2017 09:11
Get last 7 days data from database order by relation table's field
<?php
public function test(){
$days = new Carbon();
$bn_contents = BnContent::with('category','subcategory','content_meta')
->leftJoin('bn_content_metas', 'bn_contents.content_id', '=', 'bn_content_metas.content_id')
->where('bn_contents.created_at', '<', $days->subDays(7)->toDateTimeString())
->where('bn_contents.status', 1)->where('bn_contents.deletable', 1)
->orderBy('bn_content_metas.total_hit','desc')->take(5)->get();
return ($bn_contents);
@RakibSiddiquee
RakibSiddiquee / datetime-difference.php
Created May 14, 2017 09:54
Get the difference between two date or two datetime
<?php
// Date time difference
$dt = date_diff(date_create('2017-01-01 02:20:10'), date_create('2017-02-01 23:23:23'));
var_dump($dt);
// Date difference
$d = date_diff(date_create('2017-01-01'), date_create('2017-02-01'));
var_dump($d);