Skip to content

Instantly share code, notes, and snippets.

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

WAI MYO KYAW waikyaw9999

🏠
Working from home
View GitHub Profile
@waikyaw9999
waikyaw9999 / wp-menu-item-name.php
Created February 1, 2024 04:35 — forked from gmaggio/wp-menu-item-name.php
[Wordpress] Get the Menu Name of the current page
<?php
/**
* Get the Menu Name of the current page
*
* $loc is the location name of the nav menu
*
* Source:
* http://wordpress.stackexchange.com/a/155833/1044
*
*/
@waikyaw9999
waikyaw9999 / gulp-cjs-to-esm.md
Created January 17, 2024 03:22 — forked from noraj/gulp-cjs-to-esm.md
Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Moving gulpfile from CommonJS (CJS) to ECMAScript Modules (ESM)

Context

del v7.0.0 moved to pure ESM (no dual support), which forced me to move my gulpfile to ESM to be able to continue to use del.

The author sindresorhus maintains a lot of npm packages and does not want to provides an upgrade guide for each package so he provided a generic guide. But this guide is a bit vague because it's generic and not helping for gulp, hence this guide.

Guide

@waikyaw9999
waikyaw9999 / mongoengine_jsonencoder.py
Created December 26, 2020 10:25 — forked from corydolphin/mongoengine_jsonencoder.py
Fix: TypeError: ObjectId is not JSON serializable: A Flask JSONEncoder for Mongoengine documents. Specifically useful for use with Flask-Mongoengine.
from flask import Flask
from flask.json import JSONEncoder
from bson import json_util
from mongoengine.base import BaseDocument
from mongoengine.queryset.base import BaseQuerySet
class MongoEngineJSONEncoder(JSONEncoder):
def default(self,obj):
if isinstance(obj,BaseDocument):
return json_util._json_convert(obj.to_mongo())
@waikyaw9999
waikyaw9999 / bobp-python.md
Created November 21, 2020 13:31 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens