Skip to content

Instantly share code, notes, and snippets.

View Merazsohel's full-sized avatar
🤲
Alhamdulillah For Everything

Md. Meraz Hossain Merazsohel

🤲
Alhamdulillah For Everything
  • Softzino Technologies
  • Dhaka
View GitHub Profile
@Merazsohel
Merazsohel / gist:1929db5f6cf38221d093b484c38d0c13
Created February 3, 2022 14:36
Pagination Serial number sequence
$page = request()->get("page") != "" ? intval(request()->get("page")) : 1;
$sl = ($page - 1) * 100;
{{ ++$sl }}
@Merazsohel
Merazsohel / gist:f5b3d9ca6144ea3dbb8f33ea2408baf3
Created December 30, 2021 11:03
Laravel Custom LengthAwarePaginator
$this->paginate('Here will go your array');
public function paginate($items, $perPage = 50, $page = null, $options = [])
{
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
$items = $items instanceof Collection ? $items : Collection::make($items);
return new LengthAwarePaginator(
$items->forPage($page, $perPage),
$items->count(),
function pad2(n)
{
return (n < 10 ? '0' : '') + n;
}
var date = new Date(date goes here);
var month = pad2(date.getMonth()+1);
var day = pad2(date.getDate());
var year= date.getFullYear();
@Merazsohel
Merazsohel / gist:5b9acb6ef80a2d4e09f07197e405b98c
Created November 24, 2021 07:42
(English to Bangla) money value to words
var IS_SOUTH_ASIAN = true;
var ONES_WORD = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
var TENS_WORD = ['', '', 'Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
var SCALE_WORD_WESTERN = ['', 'Thousand', 'Million', 'Billion', 'Trillion', 'Quadrillion', 'Quintillion', 'Sextillion', 'Septillion', 'Octillion', 'Nonillion'];
var SCALE_WORD_SOUTH_ASIAN = ['', 'Thousand', 'Lakh', 'Crore', 'Hundred Crore', 'Thousand Crore', 'Lakh Crore', 'Crore Crore', 'Hundred Crore Crore', '***', '***'];
var GROUP_SIZE = (typeof IS_SOUTH_ASIAN != "undefined" && IS_SOUTH_ASIAN) ? 2 : 3;
var SCALE_WORD = (typeof IS_SOUTH_ASIAN != "undefined" && IS_SOUTH_ASIAN) ? SCALE_WORD_SOUTH_ASIAN : SCALE_WORD_WESTERN;
function int_to_words(int) {
if (int === 0) return 'Zero';
@Merazsohel
Merazsohel / gist:7755bca88b3fb5b6913a2deb72d44559
Last active September 9, 2021 09:30
Laravel LengthAwarePaginator
$items = new LengthAwarePaginator(
$items->forPage(LengthAwarePaginator::resolveCurrentPage(), 10),
$items->count(),
10,
LengthAwarePaginator::resolveCurrentPage(),
["path" => route("home",["key" => $request->get("value") ])]
);
@Merazsohel
Merazsohel / gist:23316c1f04f549888309cea0dde40103
Created September 7, 2021 06:40
Serially bulk barcode generate
$barcodes = [];
$from = explode("-", $request->input("from"));
$to = explode("-", $request->input("to"));
$totalDigit = strlen($from[1]);
$startFrom = (int) $from[1];
$endTo = (int) $to[1];
// Get me all users who have posts that are to be published in the future.
User::whereHas('posts', function ($query) {
$query->where('published_at', '>', now());
})->get();
we can now refactor and simplify the above to the following:
User::whereRelation('posts', 'published_at', '>', now())->get();
As you can see, we have collapsed the closure into the parameter list of the whereRelation method.
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
</head>
<body>
<div id="app" class="container mt-5">
<h3 class="text-center">Bazar List</h3>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
django-admin
django-admin startproject project-name
pyhton3 manage.py runserver