Skip to content

Instantly share code, notes, and snippets.


Mishka Nguyen akhsiM

  • Australia
View GitHub Profile
View capitalize.js
const capitalize = (s) => {
if (typeof s !== 'string') return '';
return s.charAt(0).toUpperCase() + s.toLowerCase().slice(1)
View create_multilevel_dropdown.js
function showMultilevelDropdownMenu(title, elementId, data, nameKey, valueKey, childrenKey) {
This function can be used to create a multilevel dropdown menu.
It needs the following arguments:
- title: title of the main Dropdown Button
- elementId: Where the dropdown menu will be generated within.
- data: array of JS object, with the following attributes:
- nameKey: this attribute will be used as the displayed innerHTML/ text of the menu option
- valueKey: this attribute will be used as the "value" attribute of the menu option
View comparer_function.js
In JS the array.sort() function can take a COMPARE function as an argument argument. The purpose of this function is to define an alternative order.
This is useful in cases where we need to sort an array of JS objects, using a key attribute, such as "ordering".
function(a, b) {
return a - b
akhsiM / django-snippets
Last active Dec 14, 2020
Django snippets
View Markdown Page Break
<div style="page-break-after: always; visibility: hidden"> \pagebreak </div>
View clear temp table.sql
-- Clear all temp tables in your space
undef current_schema;
for cur_cleanup in (
select object_name
from user_objects
where object_type = 'TABLE'
and temporary = 'Y'
from datetime import datetime, timedelta
from import tzlocal
def convert_from_utc(input, offset=0, outputstr=True, tz=False):
This operation accepts three arguments:
1. str input: Input with format specified below