Skip to content

Instantly share code, notes, and snippets.

View FinchPowers's full-sized avatar

François-Michel L'Heureux FinchPowers

View GitHub Profile
@pytest.fixture
def capture_logging() -> Generator[StringIO, None, None]:
sio = StringIO()
sh = StreamHandler(stream=sio)
log.addHandler(sh)
yield sio
log.removeHandler(sh)
#!/bin/bash
# Drop this in a project .git/hooks/prepare-commit-msg
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
# SHA1 is not empty if it's a rebase / ammend
SHA1=$3
# template
# summary

Ingrédients

  • 1 kg de courgettes
  • 2 oignons jaunes
  • 2 tomates broyées
  • huile

Épices

I started with the following node creaton loop
for i in range(2):
tx.run(f"MERGE (:Node {{date: datetime('2018-06-01T{i:02}:00:00Z')}})")
tx.run(f"MERGE (:Node {{date: datetime('2018-06-01T{i:02}:00:00-01:00')}})")
Here is a TZ reference table
| UTC | -01:00 |
|-----|--------|
| 0 | 23 |
mutex connCacheMutex;
map<string, weak_ptr<SftpConnection>> connCache;
std::shared_ptr<SftpConnection> getSftpConnForUri(const std::string & uri)
{
string host = hostnameFromUri(uri);
auto it = connCache.find(host);
if (it != connCache.end()) {
if (auto conn = it->second.lock()) {
return conn;
@FinchPowers
FinchPowers / alignement
Last active August 29, 2015 14:22
demo d'alignement
ext_id_it = db_session.query(Campaign) \
.filter(Campaign.external_id
.in_(data['learn_from']))
@FinchPowers
FinchPowers / python string Formatter.py
Last active August 29, 2015 14:13
Why doesn't the second form work?
# ref https://docs.python.org/2/library/string.html#string-formatting
from string import Formatter
class PassThroughFormatter(Formatter):
pass
ptf = PassThroughFormatter()
# works
s = "I am {name} and I am {age} years old"
@FinchPowers
FinchPowers / raii.php
Last active January 1, 2016 06:19
PHP RAII style
<?php
class Toto{
function __construct(){
print "CONSTRUCT!\n";
}
function __destruct(){
echo "DESTROY\n";
}
#pragma once
#include <city.h>
#include <sstream>
void michHashInternal(std::stringstream& ss){}
template<typename first, typename... args>
void michHashInternal(std::stringstream& ss, first&& f, args&&... a){
ss << std::forward<first>(f);
@FinchPowers
FinchPowers / behaviour_domain_py.cc
Created March 20, 2013 14:06
behaviour_domain_py.cc opt example
// script type
void save(BehaviourDomain & dom, const string & filename, ssize_t max)
{
dom.save(filename, max);
}
// object type
void (BehaviourDomain::*save3)(const string &, ssize_t) = &BehaviourDomain::save;