Skip to content

Instantly share code, notes, and snippets.

Avatar
👽

Daniel Bengtsson Zitrax

👽
View GitHub Profile
@Zitrax
Zitrax / Dockerfile
Last active October 7, 2020 09:38
Critic docker experiment
View Dockerfile
# OperaCritic
#
# VERSION 0.1.0
# Note, a pre-release of 18.04 was tested but posgres did not want to start
# there. And in ubuntu 16.04 apache crashed (possibly due to old mod_wsgi, not
# tested with the pip version)
FROM ubuntu:17.10
# Originally based on https://hub.docker.com/r/tjarosik/critic/
MAINTAINER Daniel Bengtsson <daniel@bengtssons.info>
@Zitrax
Zitrax / stringformat_constexpr_if.cpp
Last active April 27, 2023 18:07
stringformat with constexpr if
View stringformat_constexpr_if.cpp
#include <string>
#include <iostream>
#include <memory>
/**
* Convert all std::strings to const char* using constexpr if (C++17)
*/
template<typename T>
auto convert(T&& t) {
@Zitrax
Zitrax / stringformat_const.cpp
Created December 17, 2017 10:38
string format with auto conversion and avoidance of duplications for the const vs non const case
View stringformat_const.cpp
#include <string>
#include <iostream>
#include <memory>
// Since it's not possible to partially specialize a function
// template we use overloads with a rank to try the overloads
// in a specific order.
//
// Using rank introduces "priority" because implicit conversions are required to
// convert a rank<X> to a rank<Y> when X > Y. dispatch first tries to call dummy
@Zitrax
Zitrax / stringformat.cpp
Created December 16, 2017 20:51
string format with auto conversion of std::string
View stringformat.cpp
#include <string>
#include <iostream>
#include <memory>
template<typename T, typename U=T>
U convert(T&& t) {
return std::forward<T>(t);
}
const char* convert(const std::string& s) {
View brainblast.nix
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "brainblast-1.0";
src = fetchurl {
url = https://github.com/Zitrax/brainblast/archive/2068025f3a411000ee506f525188d586c327d226.tar.gz;
sha256 = "116pddal9n3bypnj3q6sggrzphzq1rfkqh5skyqfa1ha7mlspl19";
};
View gist:fe01e7422817f4ba377348bac56afd10
[alias]
fixup = !sh -c 'git commit -a --fixup=`git rev-list master.. | tail -1` && git commit --amend -m\"`git show -s --format=%s`\" -m\"$1\"' -
@Zitrax
Zitrax / gist:90f726a24785844a052d9cd5a4e44c11
Created April 5, 2016 14:33
Random critic review for debug
View gist:90f726a24785844a052d9cd5a4e44c11
#!/bin/bash
br=`pwgen -n 5 -c 1` && git checkout -b $br && echo $br >> file && git commit -am"$br" && git push critic $br:r/$br
@Zitrax
Zitrax / ubuntu-deps.py
Last active July 26, 2022 08:00
Download all dependencies for a ubuntu package.
View ubuntu-deps.py
import argparse
import hashlib
import os
from collections import defaultdict
import sys
from bs4 import BeautifulSoup as bs
import re
import requests
View mysql_speedtest.py
import time
import sqlite3
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
Base = declarative_base()
DBSession = scoped_session(sessionmaker())
@Zitrax
Zitrax / gist:4730967
Created February 7, 2013 13:37
Tiny python script to search for pastebin entries
View gist:4730967
import urllib2
import re
import sys
import getpass
# FILL IN
username = "test"
passwd = getpass.getpass("Enter password for %s: " % username)
realm = "test"
base_url = "http://test/"