Skip to content

Instantly share code, notes, and snippets.

View mailtodanish's full-sized avatar
:octocat:
Working From Home

Mohd Ahshan Danish mailtodanish

:octocat:
Working From Home
View GitHub Profile
@mailtodanish
mailtodanish / QuickSort.js
Created December 23, 2023 15:11
QuickSort in JavaScript
/*
The quicksort algorithm picks a pivot element and then divide the array.
Puts the smaller elements on the left side of the pivot and the larger ones on the right side.
https://www.linkedin.com/in/mohdahshandanish/
*/
function QickSort(array){
let rightArr =[]
let leftArr = []
@mailtodanish
mailtodanish / customfilter.py
Last active November 20, 2022 17:19
custom filter in admin.py
from datetime import date
from django.contrib import admin
from .models import Question
from django.utils.translation import gettext_lazy as _
class CustomListFilter(admin.SimpleListFilter):
title = _('pub_date')
parameter_name = 'pubdate'
@mailtodanish
mailtodanish / demo.js
Last active November 6, 2022 05:33
calculate min variable using Knockout
this.min = ko.computed(function () {
let toDateObj = new Date(this.to_date());
toDateObj.setFullYear(toDateObj.getFullYear() - 1);
return ko.observable(ojconverterutils_i18n_1.IntlConverterUtils.dateToLocalIso(toDateObj));
}, this);
@mailtodanish
mailtodanish / demo.html
Last active November 6, 2022 05:22
oj-input-date
<oj-input-date autocomplete="off"
class="oj-form-control-max-width-sm oj-form-control-width-sm oj-form-control-text-align-start "
value="{{from_date}}" label-hint="From" required min="[[min()]]" max="[[form.to_date]]">
</oj-input-date>
<oj-input-date autocomplete="off"
class="oj-form-control-max-width-sm oj-form-control-width-sm oj-form-control-text-align-start "
value="{{to_date}}" label-hint="To" required :id="[['form-to-date-id'+$uniqueId]]"
max="[[(new Date()).toISOString()]]">
</oj-input-date>
@mailtodanish
mailtodanish / demo.css
Created November 5, 2022 02:36
oj-single-select style
.custom-list-item {
--oj-collection-list-row-height: 25px !important;
--oj-collection-list-cell-padding-vertical: 2px;
--oj-list-view-item-padding-horizontal: 2px;
--oj-core-bg-color-selected: #faa51973;
--oj-core-text-color-primary: #004e95;
text-transform: capitalize;
}
@mailtodanish
mailtodanish / demo.js
Created November 5, 2022 02:14
demo-oj-select-single
<oj-select-single
class="oj-form-control-max-width-sm oj-form-control-width-sm oj-form-control-text-align-start __input_txt"
value="{{form.accountNumber}}" data="[[accountNumbers]]" label-hint="Account Number"
:id="[['selected-account-id'+$uniqueId]]" required placeholder="Select Account "
item-text="[[getItemText]]">
<template slot="collectionTemplate" data-oj-as="collection">
<oj-list-view aria-label="select" gridlines.item="visibleExceptLast" selection-mode="single"
class="oj-select-results custom-list-item" data="[[collection.data]]" selected="[[collection.selected]]"
current-item="{{collection.currentRow.rowKey}}" on-oj-item-action="[[collection.handleRowAction]]">
<template slot="itemTemplate" data-oj-as="item">
@mailtodanish
mailtodanish / demo.service
Created October 15, 2022 15:54
systemd service for pipenv
[Unit]
Description=flask service 2001
After=multi-user.target
[Service]
Restart=always
RestartSec=1
WorkingDirectory=/opt/sqlite/gk-backend-sqlite
ExecStart=/usr/local/bin/pipenv run gunicorn --bind 0.0.0.0:5000 --log-level=error --error-logfile /var/www/2021/gunicorn-error.log --access-logfile /var/www/2021/gunicorn-access.log wsgi:app
StandardInput=tty-force
[Install]
@mailtodanish
mailtodanish / viewmodel.js
Created September 24, 2022 11:17
multi language in vbcs
define(["jquery"], ($) => {
'use strict';
class PageModule {
constructor() {
let lang = oj.Config.getLocale();
$("html").attr("lang", lang);
if (lang === "ar") {
$("html").attr("dir", "rtl");
} else {
server {
server_name danishwebs.co.in www.danishwebs.co.in;
access_log /var/log/nginx/danishwebs-access.log;
error_log /var/log/nginx/danishwebs-error.log;
root /var/www/react/html;
location ^~ /api {
@mailtodanish
mailtodanish / nginx.conf
Last active September 20, 2022 04:30
Nginx config for React
server {
server_name danishwebs.co.in www.danishwebs.co.in;
access_log /var/log/nginx/danishwebs-access.log;
error_log /var/log/nginx/danishwebs-error.log;
root /var/www/react/html;
location / {
try_files $uri /index.html;