Skip to content

Instantly share code, notes, and snippets.

View ourway's full-sized avatar
🏆

Farshid Ashouri ourway

🏆
View GitHub Profile
@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()
@kevinSuttle
kevinSuttle / meta-tags.md
Last active March 31, 2024 14:26 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@jonathonbyrdziak
jonathonbyrdziak / negative-keywords-porn.js
Last active December 28, 2023 02:02
Giant List of Negative Porn Keywords To Exclude From Google Adwords
// Giant List of Negative Porn Keywords To Exclude From Google Adwords
adult film
adult movie
adult video
anal
ass
bara
barely legal
bdsm
bestiality
@marko-asplund
marko-asplund / advanced-psql-examples.sql
Last active June 15, 2023 02:15
Advanced PostgreSQL feature examples. Includes table DDL, example data and queries.
--
-- ** setting up example tables and data **
--
--
CREATE TABLE task (
id BIGSERIAL ,
name TEXT,
parent_id BIGINT REFERENCES task(id),
PRIMARY KEY (id)
@brainsik
brainsik / color_log.py
Created September 24, 2011 03:51
ANSI colored Python logging
import logging
from termcolor import colored
class ColorLog(object):
colormap = dict(
debug=dict(color='grey', attrs=['bold']),
info=dict(color='white'),
warn=dict(color='yellow', attrs=['bold']),
@letmaik
letmaik / models_committed.py
Created May 22, 2014 14:54
delete, insert, update events after a commit for SQLAlchemy
from sqlalchemy import create_engine, event, orm
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import Session as SessionBase, object_session
from sqlalchemy.event.api import listen
# The following adds delete, insert, and update events after successful commits.
# SQLAlchemy provides only events after flushes, but not after commits.
# The classes are adapted from Flask-SQLAlchemy.
# see also https://stackoverflow.com/a/12026787/60982
@rwalk
rwalk / elasticsearch_quickstart.py
Created September 17, 2015 21:08
Quickstart elasticsearch with Python
#!/usr/bin/python3
# This script is a simple introduction to the python elasticsearch API.
#
# This script will populate an elasticsearch index from a file and then give a simple command line query interface.
# Each line of the input file will be mapped into a JSON document of the form { "text": "my file line..." } and added
# to the index.
#
# You can use Docker to spin up a local elasticsearch instance to play around with, e.g.
# docker run --name elasticsearch -d -p 9200:9200 elasticsearch:latest
#
@mprymek
mprymek / gist:8379066
Last active July 22, 2022 09:18
Elixir metaprogramming example
# This is an example of metaprogramming in the Elixir language.
#
# We will define a domain specific language (DSL) for the definition
# of a service which is watched by several sensors.
# Each sensor watches some property/functionality of the service and
# returns the result of the check.
#
# To determine if the service is functioning properly, we need functions
# to run all the sensors' code and gather the returned data.
#
/.vscode
__pycache__
.pytest_cache
log.txt
@sinkers
sinkers / gist:5cc2854e01a05a2db650
Created July 11, 2014 07:07
Creating multiple DASH renditions with a bitrate text overlay, using ffmpeg and Bento
#!/bin/sh
# encode_bitrate_overlay.sh
#
#
# Created by Andrew Sinclair on 11/07/2014.
#
#!/bin/bash
VIDSOURCE=$1
OUTNAME=$2