Skip to content

Instantly share code, notes, and snippets.

View malikpiara's full-sized avatar
🌙

Malik Piara malikpiara

🌙
View GitHub Profile
@harveenatwal
harveenatwal / githubs-native-drop-zone.txt
Last active July 21, 2024 04:38
Github's native drop zone
// eslint-disable-next-line no-restricted-imports
import {fire} from 'delegated-events'
// eslint-disable-next-line no-restricted-imports
import {observe} from '@github/selector-observer'
// Entire document is drop target.
observe('.js-document-dropzone', {
constructor: HTMLElement,
add(el) {
document.body.addEventListener('dragstart', onDragstart)
@babldev
babldev / README.md
Last active October 14, 2025 13:52
NextJS Background Task

NextJS Background Task Example

An example of how to add a background task (e.g. a queue consumer) to an existing NextJS project.

Setup

  • Add your background task file
  • Add a new worker-tsconfig.json, specifically specifying "module": "commonjs" and targeting only the worker source files.
  • Add convenience functions for building & running to package.json

Then to build once:

@verdverm
verdverm / backup.sh
Created October 14, 2020 18:49
HN Upvotes Backup and JSONify
#!/usr/bin/env bash
set -euo pipefail
COOKIE="user=verdverm&..."
USERNAME="verdverm"
BASEURL="https://news.ycombinator.com/upvoted"
PAGE=0
mkdir -p html
@CrystalOnScript
CrystalOnScript / firstemail.html
Last active October 11, 2025 05:23
Create your first AMP email
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<style amp4email-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
def Input():
var = '/'+'Input <>'+'/'+';\n'
return var
def Output():
var = '/'+'Output <>'+'/'+';\n'
return var
@greyli
greyli / app.py
Last active February 25, 2024 03:04
Photo upload and manage with Flask and Flask-Uploads (Multiple file upload support!).
# -*- coding: utf-8 -*-
import os
import uuid
from flask import Flask, render_template, redirect, url_for, request
from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField
@ajford
ajford / wtformstest.py
Created May 19, 2016 19:14
Example demonstrating the use of WTForms keyword arguments to set disabled state
import wtforms as wtf
class MyForm(wtf.Form):
sel = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
default=1)
class MyDisabledForm(wtf.Form):
sel1 = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
default=1,render_kw={'disabled':'disabled'})
sel2 = wtf.SelectField('Select',choices=[(1,'One'),(2,'Two')],
@farh33n
farh33n / Notepad.java
Created February 26, 2016 15:25
Notepad code
import java.awt.Font;
import java.awt.Color;
// allows us to use JFrame,JMenuBar, JMenu,JMenuItem,JTextArea
import javax.swing.*;
// allows us to import ActionListener
import java.awt.event.*;
import java.util.Scanner;
import java.io.*;
// inherits the class JFrame
@niksumeiko
niksumeiko / disable-html-form-input-autocomplete-autofill.md
Last active April 26, 2026 14:47
Disable HTML form input autocomplete and autofill

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 6, 2026 15:19
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites