Skip to content

Instantly share code, notes, and snippets.

@SebastianGrans
SebastianGrans / redirect-to-wikiwand-with-adguard.txt
Last active June 22, 2023 11:12
Emulate the behaviour of the Wikiwand extension in Safari 13 using an AdGuard JavaScript filter
# Since Safari 13 the Wikiwand plugin is no longer available and they
# don't even list Safari as a supported browser anymore.
#
# Most people use some kind of ad blocker, and personally I'm using "AdGuard for Safari" which allows you
# to define filters that inject javascript code on certain domains.
#
# Simply add this to AdGuards "User filter", and any wikipedia article will be redirected to Wikiwand.
#
@@||wikipedia.org^$generichide,badfilter
@juhaelee
juhaelee / react-typescript.md
Last active May 28, 2024 17:41
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)

@adamJLev
adamJLev / mixins.py
Last active November 14, 2022 15:54
(DEPRECATED) Atomic transactions and Django Rest Framework
# NOTE This is probably no longer needed, now DRF does this
# automatically if you have ATOMIC_REQUESTS enabled.
# https://github.com/encode/django-rest-framework/pull/2887
from django.db import transaction
class AtomicMixin(object):
"""
Ensures we rollback db transactions on exceptions.
@einnocent
einnocent / dotdictify.py
Last active July 24, 2017 20:05
Modified Python Dotdictify
# turn dict into an object that allows access to nested keys via dot notation
# from http://stackoverflow.com/questions/3797957/python-easily-access-deeply-nested-dict-get-and-set
# made three modifications:
# --added `get()` method
# --added `if not dict.__contains__...` to `__contains__()`
# --can now accept None as key
class dotdictify(dict):
def __init__(self, value=None):
if value is None:
pass
@zacharyvoase
zacharyvoase / README.md
Last active May 21, 2020 06:19
A li’l class for data URI manipulation in Python.

DataURI.py

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.

Parsing

@johan
johan / README.md
Last active April 23, 2021 05:00
RFC 5545 compliant (US) Groupon holiday iCal calendar

Groupon US' recognized holidays are:

  • New Year’s Day
  • Memorial Day
  • Independence Day
  • Labor Day
  • Thanksgiving Day
  • day after Thanksgiving
  • day before Christmas
  • Christmas Day
@thomasyip
thomasyip / common [stash] fields.py
Created July 22, 2012 04:19
Updated version of Django BigInt Patch for 64bit Primary Keys
"""
module mydjangolib.bigint_patch
A fix for the rather well-known ticket #399 in the django project.
Create and link to auto-incrementing primary keys of type bigint without
having to reload the model instance after saving it to get the ID set in
the instance.
Logs:
@ryanpitts
ryanpitts / gist:1304725
Created October 21, 2011 19:34
GROUP BY and Select MAX from each group in Django, 2 queries
'''
given a Model with:
category = models.CharField(max_length=32, choices=CATEGORY_CHOICES)
pubdate = models.DateTimeField(default=datetime.now)
<other fields>
Fetch the item from each category with the latest pubdate.
'''