Skip to content

Instantly share code, notes, and snippets.

View devfaysal's full-sized avatar
🏠
Working from home

Faysal Ahamed devfaysal

🏠
Working from home
View GitHub Profile
@devfaysal
devfaysal / countdown_timer.js
Last active February 4, 2021 06:20
Countdown Timer
var endDate = new Date("Feb 5, 2021 12:00:00 GMT-0800").getTime();
var timer = setInterval(function() {
let now = new Date().getTime();
let t = endDate - now;
if (t >= 0) {
let days = Math.floor(t / (1000 * 60 * 60 * 24));
@devfaysal
devfaysal / OpenGraphImageController.php
Created October 8, 2020 09:50
OpenGraphImageController
<?php
namespace App\Http\Controllers;
use GDText\Box;
use GDText\Color;
use App\Post;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
@devfaysal
devfaysal / vscode shortcut.txt
Created May 1, 2020 04:36
vscode shortcuts
Bulk Multiple cursor:
Mark all then Atl + shift + i
@devfaysal
devfaysal / History|-1024bc6d|entries.json
Last active December 31, 2022 04:11
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///var/www/html/laravel/filament/app/Models/User.php","entries":[{"id":"gjXE.php","timestamp":1663760020239},{"id":"xJ9X.php","timestamp":1663760031893}]}
@devfaysal
devfaysal / composer.json
Last active December 14, 2019 08:36
Add local composer package
"repositories": [
{
"type": "path",
"url": "../pkg/laravel-admin"
},
{
"type": "vcs",
"url": "git@bitbucket.org:vendor/my-private-repo.git"
}
]
@devfaysal
devfaysal / csv-to-json.php
Last active February 6, 2023 10:04
CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses the csv file of this gist
*/
$feed="https://gist.githubusercontent.com/devfaysal/9143ca22afcbf252d521f5bf2bdc6194/raw/ec46f6c2017325345e7df2483d8829231049bce8/data.csv";
//Read the csv and return as array
$data = array_map('str_getcsv', file($feed));
//Get the first raw as the key
$keys = array_shift($data);
@devfaysal
devfaysal / app.scss
Last active August 20, 2019 05:09
Up and running Tailwindcss in Laravel app
@import "./node_modules/tailwindcss/base";
@import "./node_modules/tailwindcss/components";
@import "./node_modules/tailwindcss/utilities";
function custom_title($title_parts) {
if ( is_search() ) {
$title_parts['title'] = get_search_query();
}
return $title_parts;
}
add_filter( 'document_title_parts', 'custom_title' );
@devfaysal
devfaysal / image-preview.js
Created November 13, 2018 06:12
Preview Image while uploading
//<input onchange="previewFile('#logo_preview', '#logo')" id="logo" type="file" name="logo">
//<img id="logo_preview" src="">
function previewFile(preview, source) {
var preview = document.querySelector(preview);
var file = document.querySelector(source).files[0];
var reader = new FileReader();
reader.onloadend = function () {
preview.src = reader.result;
@devfaysal
devfaysal / email_scrape.php
Created September 10, 2018 11:31 — forked from aramk/email_scrape.php
Scrape emails from a given URL in PHP. Using it to invite people to Google+, for now :)
<?php
$url = 'http://computerandu.wordpress.com/2011/06/29/how-to-get-google-invite/';
$emails = scrape_email($url);
echo implode($emails, ' ');
function scrape_email($url) {
if ( !is_string($url) ) {
return '';
}