Skip to content

Instantly share code, notes, and snippets.

View NazemMahmud's full-sized avatar

Nazem Mahmud Piash NazemMahmud

View GitHub Profile
@NazemMahmud
NazemMahmud / ffmpeg_cli.md
Last active March 30, 2026 03:43
ffmpeg CLI commands

1. save last frame of the video

ffmpeg -sseof -3 -i input.mp4 -update 1 -q:v 1 last.jpg

If you want PNG:

ffmpeg -sseof -3 -i input.mp4 -update 1 last.png

Notes:

@NazemMahmud
NazemMahmud / ImageMigrationService.php
Created June 11, 2025 19:19
Laravel: Image migration after file download
<?php
namespace App\Services;
use App\Services\FileDownloadService;
use Illuminate\Http\UploadedFile;
class ImageMigrationService
{
/**
@NazemMahmud
NazemMahmud / FileDownloadService.php
Last active June 11, 2025 19:21
Laravel: Download an image from URL and return UploadedFile instance.
<?php
namespace App\Services; // this will be the namespace according to your file path
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Exception;
/**
* Follow this gist to find out how to finally unlink and upload image
@NazemMahmud
NazemMahmud / FileDownloadAndImageMigrationService.php
Last active June 11, 2025 19:12
downloading images from URLs and uploading them to your storage. It Includes proper error handling, validation, and cleanup.
<?php
namespace App\Services; // this will be the namespace according to your file path
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Exception;
class ImageMigrationService
@NazemMahmud
NazemMahmud / airwrk_interview.php
Last active December 21, 2022 17:18
Airwrk interview tasks
<?php
// Problem 1
function findPairs($nums) {
$count = 0;
$len = count($nums);
if ($len <= 1) { return 0; }
for ($i=0; $i < $len; $i++) {
for ($j=$i+1; $j < $len; $j++) {
@NazemMahmud
NazemMahmud / main.service.ts
Last active December 18, 2021 11:14
Angular Material: main service ts file for pagination sample
import {Injectable} from '@angular/core';
import {HttpClient, HttpParams} from '@angular/common/http';
@Injectable()
export class MainService {
constructor(protected http: HttpClient) {}
private readonly baseUrl = "127.0.0.1:8000/api"; // here use your project's base url
private additionalUrl = "/employees"; // here use your remaining route url
protected _url = `${this.baseUrl}${this.additionalUrl}`;
@NazemMahmud
NazemMahmud / main.component.ts
Last active December 18, 2021 11:10
Angular Material: main component ts file for pagination sample
import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {MatTableDataSource} from '@angular/material';
import {MainService} from './service/main.service';
// this will be your shared component path
import {BasicPaginationComponent} from '../shared/components/basic-pagination/basic-pagination.component';
@Component({
@NazemMahmud
NazemMahmud / main.component.html
Last active December 18, 2021 10:39
Angular Material: main component html file for pagination sample
<table mat-table *ngIf="dataSource; else noDataFound" [dataSource]="dataSource">
<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name</th>
<td mat-cell *matCellDef="let row"> {{row.name}} </td>
</ng-container>
<!-- Email Column -->
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Email </th>
@NazemMahmud
NazemMahmud / KMP-substring-search.js
Last active December 11, 2021 20:30
KMP algorithm for substring search
/**
* @param {string} haystack
* @param {string} needle
* @return {number}
*/
function KMP(text, pattern){
let LPS = preProcess(pattern);
let i=0, j=0;
while(i < text.length && j < pattern.length){
if(text[i] == pattern[j]){
@NazemMahmud
NazemMahmud / KMP preprocess pattern.js
Last active December 11, 2021 20:22
Pre process pattern string for KMP algorithm
function preProcess(pattern) {
let lps = new Array(pattern.length);
let i = 0, j = 1; lps[0] = 0;
while (j < pattern.length) {
if(pattern[j] == pattern[i]) {
lps[j] = i + 1;
i++;
j++;
} else if(i != 0) {
i = lps[i-1];