Skip to content

Instantly share code, notes, and snippets.

Working from home

Faysal Ahamed devfaysal

Working from home
View GitHub Profile
devfaysal / credit_card_input_field.php
Created May 11, 2017
Format Credit card number while typing in an input field, store, view only last 4 digit and mask the rest.
View credit_card_input_field.php
//storing the card number in session just for testing, in real, it will be saved in database.
$string = str_replace(' ', '', $_POST['card']);
$_SESSION['card'] = $string;
echo $_SESSION['card'];
View Get related video by video id - YouTube API v3
devfaysal / get-video-by-channel-id.html
Last active Aug 2, 2017
Get video by channel id - YouTube API v3
View get-video-by-channel-id.html
<!DOCTYPE html>
<meta charset="UTF-8">
<ul id="list"></ul>
devfaysal / wordpress_metabox.php
Created Oct 25, 2017
Sample code for adding metabox to wordpress
View wordpress_metabox.php
* Adding Metabox for adding a checkbox to hide or unhide the page title
function fay_add_meta_box_for_page_title_display()
add_meta_box( 'fay-meta-box-for-page-title', 'Page Title', 'fay_add_meta_box_for_page_title_display_callback', 'page', 'side', 'high' );
add_action( 'add_meta_boxes', 'fay_add_meta_box_for_page_title_display' );
View aliexpress_image_download.php
$url = "";
$name = 'e5';
$oldmask = umask(0);
mkdir('/home/faysal/Downloads/aliexpress/'.$name, 0777);
$output = file_get_contents($url);
preg_match_all('/([-a-z0-9_\/:.]+\.(jpg))/i', $output, $url_matches);
devfaysal / email_scrape.php
Created Sep 10, 2018 — forked from aramk/email_scrape.php
Scrape emails from a given URL in PHP. Using it to invite people to Google+, for now :)
View email_scrape.php
$url = '';
$emails = scrape_email($url);
echo implode($emails, ' ');
function scrape_email($url) {
if ( !is_string($url) ) {
return '';
devfaysal / image-preview.js
Created Nov 13, 2018
Preview Image while uploading
View image-preview.js
//<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;
View override-search-title-meta.php
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 / app.scss
Last active Aug 20, 2019
Up and running Tailwindcss in Laravel app
View app.scss
@import "./node_modules/tailwindcss/base";
@import "./node_modules/tailwindcss/components";
@import "./node_modules/tailwindcss/utilities";
View csv-to-json.php
* Converts CSV to JSON
* Example uses the csv file of this gist
//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);