Skip to content

Instantly share code, notes, and snippets.

View morshedx's full-sized avatar
💭
I may be slow to respond.

morshedx morshedx

💭
I may be slow to respond.
View GitHub Profile
@morshedx
morshedx / docker-compose.yml
Last active October 4, 2024 05:45
homeassistant docker compose for mac
services:
homeassistant:
container_name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
volumes:
- '/Users/morshed/homeassistant:/config'
environment:
- TZ=Asia/Dhaka # get your Time Zone from - https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# network_mode: host
ports:
@morshedx
morshedx / functions.php
Created August 17, 2021 03:45
WooCommerce REST API - get product resized images url wtih width and height?
/**
* Return all image size name in rest api
* And i also modified to add width and height
*
* Main idea is taking from here
* @link https://stackoverflow.com/a/50853300/3087033
*/
function prepare_product_images($response) {
global $_wp_additional_image_sizes;
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
@morshedx
morshedx / axios-catch-error.js
Created March 18, 2021 06:49 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@morshedx
morshedx / .eslintignore
Created November 5, 2020 10:30 — forked from remy/.eslintignore
My Next.js eslint config + `npm install --save-dev eslint eslint-plugin-react babel-eslint`
.next
out
@morshedx
morshedx / app.js
Created June 15, 2020 09:44 — forked from omarkhatibco/app.js
Counter with react-countup only when the counter in viewport
import Counter from './counter';
const App = () => (
<div className='flex flex-wrap justify-between md:justify-center'>
<Counter target={150} title='Customer' duration={1} />
<Counter target={20000} title='Rooms' duration={2} />
<Counter target={40000} title='Places' duration={3} />
<Counter target={1200000} title='Users' duration={4} />
</div>
);
@morshedx
morshedx / Laravel-unique-slug.php
Created June 28, 2019 05:05
Create a unique slug from title
/**
* Create a unique slug from title.
*
* @link https://stackoverflow.com/questions/38800581/laravel-str-slug-not-working-for-unicode-bangla/38800717
* @link https://laracasts.com/discuss/channels/general-discussion/l5-routing-1
* @param string $title
* @return string
*/
public function makeSlugFromTitle($title)
{
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Odometer</title>
<script src="https://raw.github.com/morr/jquery.appear/master/jquery.appear.js"></script>
<script src="https://raw.githubusercontent.com/HubSpot/odometer/master/odometer.min.js"></script>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Style Switcher</title>
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<style type="text/css">
.clear:before,
.clear:after {
content: " ";