Skip to content

Instantly share code, notes, and snippets.

View mzaman's full-sized avatar

Masud Zaman mzaman

View GitHub Profile
@mzaman
mzaman / remove-all-from-docker.sh
Created August 31, 2024 18:26 — forked from beeman/remove-all-from-docker.sh
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@mzaman
mzaman / localStorage.js
Created February 1, 2019 22:49 — forked from anhang/localStorage.js
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@mzaman
mzaman / javascript-localstorage-expiry.js
Created February 1, 2019 22:47 — forked from shaik2many/javascript-localstorage-expiry.js
set timeout for localStorage or sessionStorage
http://apassant.net/2012/01/16/timeout-for-html5-localstorage/
var hours = 24; // Reset when storage is more than 24hours
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if (setupTime == null) {
localStorage.setItem('setupTime', now)
} else {
if(now-setupTime > hours*60*60*1000) {
localStorage.clear()
@mzaman
mzaman / airports.json
Created September 17, 2018 16:49 — forked from tdreyno/airports.json
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
@mzaman
mzaman / index.html
Created August 15, 2018 22:07 — forked from ryanbaumann/index.html
Example of loading large geojson into Mapbox GL JS
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.42.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.42.2/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
@mzaman
mzaman / isAutoplaySupported.js
Created June 26, 2018 04:04 — forked from nathansearles/isAutoplaySupported.js
Test if HTML5 video autoplay is supported
// isAutoplaySupported(callback);
// Test if HTML5 video autoplay is supported
isAutoplaySupported = function(callback) {
// Is the callback a function?
if (typeof callback !== 'function') {
console.log('isAutoplaySupported: Callback must be a function!');
return false;
}
// Check if sessionStorage exist for autoplaySupported,
// if so we don't need to check for support again
@mzaman
mzaman / BCHTML5GATracker.js
Created April 21, 2017 03:48 — forked from Daphonia/BCHTML5GATracker.js
Google Analytics Tracker Plugin for BC HTML5 Players
/**
* Brightcove HTML5 Player Google Analytics Tracker 1.0.0 Alpha (02 Sep 2012)
*
* REFERENCES:
* Website:
* Source:
*
* AUTHORS:
* Darius Oleskevicius <doleskevicius@brightcove.com>
*
@mzaman
mzaman / html5_video_events.js
Created April 21, 2017 03:48 — forked from evitolins/html5_video_events.js
Attach alerts for every video event available.
var video_events = {
'abort' : 'abort : The loading of an audio/video is aborted',
'canplay' : 'canplay : The browser can start playing the audio/video',
'canplaythrough' : 'canplaythrough : The browser can play through the audio/video without stopping for buffering',
'durationchange' : 'durationchange : The duration of the audio/video is changed',
'emptied' : 'emptied : The current playlist is empty',
'ended' : 'ended : The current playlist is ended',
'error' : 'error : An error occurred during the loading of an audio/video',
'loadeddata' : 'loadeddata : The browser has loaded the current frame of the audio/video',
'loadedmetadata' : 'loadedmetadata : The browser has loaded meta data for the audio/video',
@mzaman
mzaman / Custom.txt
Created April 12, 2017 21:55 — forked from phamngsinh/Custom.txt
Custom data pagination with Laravel 5
<?php namespace App\Http\Controllers;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class SearchController extends Controller {
public function search()
{
.
@mzaman
mzaman / paginate.php
Created April 12, 2017 21:35 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator