Skip to content

Instantly share code, notes, and snippets.

View DoonDoony's full-sized avatar
🐈

Doon DoonDoony

🐈
View GitHub Profile
@DoonDoony
DoonDoony / .aliases
Created July 15, 2022 02:57
zsh settings (lsd, bat, fzf, pyenv, starship)
alias ls='lsd'
alias ll='ls -l'
alias la='ls -la'
alias lla='ls -la'
alias lt='ls --tree'
alias cat='bat --paging=never --theme=Dracula'
const format = new Intl.NumberFormat('en-Us', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
}).format
function formatCurrency(number) {
return format(number)
}
@DoonDoony
DoonDoony / EXAMPLE.md
Created December 9, 2019 05:44
Insert a line into specific line number with GUN sed

Suppose you insert a line of code below.

import sys

Here's what the one-line code is to be inserted into. (app.py)

 1 import os
@DoonDoony
DoonDoony / smtp.py
Created October 19, 2019 09:07
Send mail via Gmail account
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
mail_content = 'Hi there!'
sender_address = "mailer@example.com"
sender_password = "very_secret_password"
receiver_address = "kind.person@example.com"
@DoonDoony
DoonDoony / prepare-commit-msg
Created October 11, 2019 06:04
prepare-commit-msg hook for jira id prefixed commit message
#!/usr/bin/env python
from __future__ import print_function
import re
import sys
GIT_HEAD_REF = '.git/HEAD'
ticket_number = re.compile(r'\b[A-Z]{2,}-[0-9]+')
branch_ticket_number = re.compile(r'\b[a-z]{2,}-[0-9]+')
@DoonDoony
DoonDoony / pycharm_python_console_shell_plus_script.py
Last active January 20, 2024 15:50
Using `shell_plus` in pycharm django console
# 💡 NOTE: This only works if you are pretend to using `Django Console` feature in Pycharm
# Paste codes below into `Build, Execution, Deployment > Console > Django Console > Starting Script`
# requirements: `django_extensions`, `IPython`
import sys
import django
from IPython.core.getipython import get_ipython
from django_extensions.management.notebook_extension import load_ipython_extension
@DoonDoony
DoonDoony / class_decorator.py
Created April 23, 2019 05:50
Simple Python Class Decorator
import sys
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
class logger:
def __init__(self, function):
self.function = function
self.logger = logging.getLogger(__name__)
@DoonDoony
DoonDoony / read_timeout.py
Created April 23, 2019 05:49
Test handling ReadTimeout Exception
import requests
import logging
from requests.exceptions import ReadTimeout, ConnectionError
logger = logging.getLogger(__name__)
url = 'https://www.google.com:81'
data = { 'username': 'DoonDoony', 'address': '...' }
retries = 3
@DoonDoony
DoonDoony / infinite-scrolling-with-intersection-observer-api.html
Last active March 28, 2019 03:10
Implement 'Infinite Scrolling' with Intersection Observer API with "Cats"!
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Infinite Scrolling 🤞</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css">
<style>
@DoonDoony
DoonDoony / lazy-loading-with-io.html
Created March 28, 2019 01:34
Implement a image lazy loading with Intersection Observer API
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
name="viewport">
<meta content="ie=edge" http-equiv="X-UA-Compatible">
<title>Document</title>
<style>
div.image-box {