Skip to content

Instantly share code, notes, and snippets.

View aldanor's full-sized avatar

Ivan Smirnov aldanor

  • xAI
  • London, UK
View GitHub Profile
from sqlalchemy import exists, text, exc, select, and_, literal, cast
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement
class InsertFromSelect(Executable, ClauseElement):
""" Insert from select"""
def __init__(self, table, select, *fields, **kw):
self.table = table
self.select = select
@prschmid
prschmid / webservicethreadingtestcase.py
Last active March 31, 2022 13:21
An example of how to perform a multi-threaded unit test of a web service. The particulars of this example make use of some conventions used when developing a web service when using the Flask microframework, but can be modified to fit most needs.
"""An example of how to perform a multi-threaded unit test of a web service.
The particulars of this example make use of some conventions used when
developing a web service when using the Flask microframework, but can be
modified to fit most needs.
"""
import json
import threading
import time
@timcharper
timcharper / how-to-build-ruby-2.0.0-on-mac-os-x.md
Last active December 18, 2015 11:49
For rbenv and without using ruby-build, how to install ruby-2.0.0-p195 with a working openssl.

ruby-build failed me, so I took matters into my own hands. Here's what worked

download and extract ruby 2.0.0p-195 to ~/.rbenv/src/ruby-2.0.0p195

mkdir $HOME/.rbenv/src
cd $HOME/.rbenv/src
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
tar xzf ruby-2.0.0-p195.tar.gz
@minrk
minrk / nbstripout
Last active March 12, 2025 18:41
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@aras-p
aras-p / preprocessor_fun.h
Last active July 14, 2025 13:08
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
anonymous
anonymous / gist:6687587
Created September 24, 2013 16:44
Getting Flask Debug trace working while using gevent-socketio
import os
from gevent import monkey
from socketio.server import SocketIOServer
from flask import Flask, request, render_template
from werkzeug.debug import DebuggedApplication
monkey.patch_all()
app = Flask(__name__)
@jbenet
jbenet / simple-git-branching-model.md
Last active July 21, 2025 21:02
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@wsargent
wsargent / docker_cheat.md
Last active August 2, 2025 19:24
Docker cheat sheet
@wrburgess
wrburgess / ruby_rails_resources.md
Created October 25, 2013 19:55
Resources for learning Ruby and Rails