Skip to content

Instantly share code, notes, and snippets.

@plammens
plammens / unionenum.py
Last active November 10, 2023 18:39
Enum union in Python
"""
Enum union based on and compatible with the standard library's `enum`.
"""
# MIT License
#
# Copyright (c) 2020 Paolo Lammens
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@OliverJAsh
OliverJAsh / foo.js
Last active September 20, 2022 18:18
GitHub PR snippets
// Expand all collapsed commits
$$('.js-timeline-progressive-disclosure-button').forEach(el => el.click());
// Expand all collapsed conversations
$$('button')
.filter(el => el.innerText === 'Load more…')
.forEach(el => el.click());
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 2, 2024 16:19
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

@juanca
juanca / github_load_all_diffs.js
Created March 2, 2017 18:42
Github PR bookmarklet: Load all file diffs
javascript:
document.querySelectorAll('.load-diff-button').forEach(node => node.click())
@pgjones
pgjones / test_flask_cookie.py
Created February 12, 2017 16:00
Example of how to use the Flask `test_request_context` with a cookie set
@djrobstep
djrobstep / sqlalchemy_dynamic_table_creation.py
Created May 18, 2016 14:28
SQLAlchemy ORM code to create SQL tables from a dynamically defined column list
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from sqlalchemy import Column, MetaData, Table, create_engine
from sqlalchemy import String, Integer, Float, BigInteger, DateTime
from sqlalchemy.schema import DropTable, CreateTable
from sqlalchemy.orm import scoped_session, sessionmaker
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@vkotovv
vkotovv / app.py
Created August 20, 2013 14:08
Clear data for all tables via flask-sqlalchemy
def clear_data(session):
meta = db.metadata
for table in reversed(meta.sorted_tables):
print 'Clear table %s' % table
session.execute(table.delete())
session.commit()
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: