Skip to content

Instantly share code, notes, and snippets.

View girisagar46's full-sized avatar
🇯🇵
🚀️

Sagar Giri girisagar46

🇯🇵
🚀️
View GitHub Profile
@kconner
kconner / macOS Internals.md
Last active March 11, 2025 07:16
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

Elon Musk's suspension reversals

The tables below show notable Twitter suspension reversals for each day since Elon Musk took over as owner and CEO.

All dates indicate when the suspension or reversal was detected, and the actual suspension or reversal may have been earlier. For most English-language accounts with large followings, this lag will generally not be longer than a few hours, but for accounts that have a small number of followers or that are outside the networks we are tracking, the difference can be larger, and in some cases an account on the list may have had its suspension reversed before 27 October 2022. These dates will get more precise as we refine the report.

Because of these limitations, this report should be considered a starting point for investigation, not a definitive list of suspension reversals.

@tonybaloney
tonybaloney / InvertBinaryTree.py
Created August 27, 2020 03:04
Invert binary tree in Python
from dataclasses import dataclass
from typing import Any
from xml.etree.ElementTree import Element
@dataclass
class Node():
val: Any
right: "Node"
left: "Node"
@pydanny
pydanny / response-to-abusive-customer.md
Last active August 2, 2020 21:50
Within 12 hours of sending this email I got an apology. Sometimes it's better to write this out than quickly fire a customer.

There is nothing wrong in wanting to feed our families.

If I wanted to profit, I would stop selling digital versions of our books and only do printed versions. The last time we did that was for Two Scoops of Django 1.6, which made more than 1.5, 1.8, and 1.11 combined. That's the only way to put a halt to digital piracy: don't sell digital works. But that denies people in a lot of places access to our works. And means we're about pedagogy over profit.

We give hundreds of unpaid hours per year to open source projects. For years, every single book we've released we've given hundreds of print copies away as charity. Through books, articles, and open source contributions we have furthered people's knowledge around the world for over a decade.

All this means we're running a charity for the Python and Django community. These live classes are our means to hopefully do open source work for a living, with a few classes per month to cover our bills.

Can we make more money building apps for other people? Absolutely

@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var elements = document.body.getElementsByTagName('*');
var items = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerHTML.indexOf('* { background:#000!important;color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }') != -1) {
items.push(elements[i]);
}
}
@girisagar46
girisagar46 / gist:607f1dc49e92d529a5e3f562aaa22006
Created May 8, 2019 07:09 — forked from simonw/gist:7000493
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (
@magicdude4eva
magicdude4eva / zsh-syntax-highlighting paste performance improvement
Last active March 11, 2025 07:10
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
@bradtraversy
bradtraversy / docker_wordpress.md
Last active March 14, 2025 13:09
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@sarthology
sarthology / regexCheatsheet.js
Created January 10, 2019 07:54
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"