Skip to content

Instantly share code, notes, and snippets.

View karolzlot's full-sized avatar
馃彔
Working from home

Karol Zlot karolzlot

馃彔
Working from home
View GitHub Profile
@SuryaSankar
SuryaSankar / M2M_Association_SQLalchemy.py
Last active September 25, 2023 07:30
An example of a many to many relation via Association Object in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.associationproxy import association_proxy
import uuid
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@mackuba
mackuba / coworking.md
Last active March 17, 2025 14:13
Lista coworking贸w w Krakowie

Coworking w Krakowie

Update 28.04.2018

Otworzy艂o si臋 ostatnio tyle nowych cowork贸w, 偶e nie nad膮偶am tego odwiedza膰 :) B臋d臋 si臋 stara艂 stopniowo aktualizowa膰 list臋, w mi臋dzyczasie polecam przegl膮dn膮膰 komentarze pod postem. (Nie chc臋 szczerze m贸wi膮c przenosi膰 tego do jakiego艣 bardziej zorganizowanego repozytorium, bo chc臋, 偶eby to pozosta艂o takim moim osobistym nieobiektywnym review tych cowork贸w - ci臋偶ko by艂oby uzgadnia膰, czy w danym miejscu jest g艂o艣no, albo czy jest fajna atmosfera... W razie w膮tpliwo艣ci, post jest dost臋pny na licencji WTFPL :)

Przydatne linki:

@allanlaal
allanlaal / currency.sql
Last active December 5, 2021 06:51
SQL table of World currencies (even some expired ones) Source: http://bcmoney-mobiletv.com/blog/2008/12/30/currency-codes-dropdown-and-sql-table/ Cleaned up a bit, uses InnoDB and iso currency code as the PRIMARY key
--
-- Table structure for table `currency`
--
CREATE TABLE IF NOT EXISTS `currency` (
`iso` char(3) CHARACTER SET utf8 NOT NULL DEFAULT '',
`name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`iso`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
@allanlaal
allanlaal / countries.sql
Last active August 30, 2021 02:09 — forked from adhipg/countries.sql
uses InnoDB and UTF8, uses ISO2 code as the primary key
--
-- Table structure for table `country`
--
CREATE TABLE IF NOT EXISTS `country` (
`iso` char(2) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`nicename` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`iso3` char(3) COLLATE utf8_unicode_ci DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
@ayust
ayust / bisect-merges.py
Created March 14, 2012 23:12
Git bisection across only mainline commits (a la git log --first-parent)
#!/usr/bin/env python
import json
import optparse
import os
import subprocess
import sys
def gitdir():
@dsosby
dsosby / config-highlight.cfg
Created August 3, 2011 15:24
A dark highlighting theme for Python's IDLE IDE based on Notepad++'s Obsidian color scheme
[Obsidian]
definition-foreground = #678CB1
error-foreground = #FF0000
string-background = #293134
keyword-foreground = #93C763
normal-foreground = #E0E2E4
comment-background = #293134
hit-foreground = #E0E2E4
builtin-background = #293134
stdout-foreground = #678CB1