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 / credit_card_input_field.php
Created May 11, 2017 04:30
Format Credit card number while typing in an input field, store, view only last 4 digit and mask the rest.
<?php
//storing the card number in session just for testing, in real, it will be saved in database.
session_start();
if(isset($_POST['submit'])){
$string = str_replace(' ', '', $_POST['card']);
$_SESSION['card'] = $string;
}
echo $_SESSION['card'];
?>
<html>
@devfaysal
devfaysal / get-video-by-channel-id.html
Last active August 2, 2017 04:17
Get video by channel id - YouTube API v3
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<ul id="list"></ul>
@devfaysal
devfaysal / wordpress_metabox.php
Created October 25, 2017 09:21
Sample code for adding metabox to wordpress
/**
* 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' );
$url = "https://www.aliexpress.com/store/product/GGMM-E5-WiFi-Wireless-Speakers-Bluetooth-Receiver-Portable-MP3-Player-Stereo-Hands-free-Call-HiFi-Speaker/602731_32776280965.html?spm=2114.12010612.0.0.GaXHNJ";
$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
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 '';
}
@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;
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 / 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";
@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"
}
]