Skip to content

Instantly share code, notes, and snippets.

View squeaky-pl's full-sized avatar

Paweł Piotr Przeradowski squeaky-pl

View GitHub Profile
@cairabbit
cairabbit / cte.sqlalchemy.py
Last active April 15, 2024 16:03
SqlAlchemy CTE recursive sample
from sqlalchemy.orm import sessionmaker, relationship, aliased
from sqlalchemy import cast, Integer, Text, Column, ForeignKey, literal, null
from sqlalchemy.sql import column, label
class Catalog(Base):
__tablename__ = 'catalog'
id = Column(String, primary_key=True)
parentid = Column(String, ForeignKey('catalog.id'))
name = Column(String)
parent = relationship("Catalog", remote_side=[id])
@gene1wood
gene1wood / all_aws_managed_policies.json
Last active April 4, 2024 18:11
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
This file has been truncated, but you can view the full file.
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 0,
"CreateDate": "2019-10-22T18:22:01+00:00",
"DefaultVersionId": "v6",
"Document": {
"Statement": [
{
"Action": [
@quiver
quiver / retrieve-EC2-region-information-from-metadata.md
Last active March 14, 2024 16:42
retrieve EC2's region from instance metadata

Sometimes you want to retrieve EC2 insntances' region information.

You can query that information through instance metadata(169.254.169.254).

$ curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "privateIp" : "172.31.2.15",
  "instanceId" : "i-12341ee8",
  "billingProducts" : null,
 "instanceType" : "t2.small",
@nrc
nrc / tools.md
Last active August 2, 2023 16:40
Rust tooling

Rust developer tools - status and strategy

Availability and quality of developer tools are an important factor in the success of a programming language. C/C++ has remained dominant in the systems space in part because of the huge number of tools tailored to these lanaguages. Succesful modern languages have had excellent tool support (Java in particular, Scala, Javascript, etc.). Finally, LLVM has been successful in part because it is much easier to extend than GCC. So far, Rust has done pretty well with developer tools, we have a compiler which produces good quality code in reasonable time, good support for debug symbols which lets us leverage C++/lanaguge agnostic tools such as debuggers, profilers, etc., there are also syntax highlighting, cross-reference, code completion, and documentation tools.

In this document I want to layout what Rust tools exist and where to find them, highlight opportunities for tool developement in the short and long term, and start a discussion about where to focus our time an

When I need to remember the spelling for a list comprehension with more than one loop in Python, I find the following mnemonic helpful:

write the for statements in the same order you would write a nested loop

For example, suppose we have a nested list that we wish to flatten:

>>> nested_list = [[1, 2, '5!'], (3, 'sir!')]