Skip to content

Instantly share code, notes, and snippets.

👽

Daniel Bengtsson Zitrax

👽
  • Norway
Block or report user

Report or block Zitrax

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Zitrax
Zitrax / Dockerfile
Last active Apr 21, 2018
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 Oct 9, 2019
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 Dec 17, 2017
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 Dec 16, 2017
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\"' -
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 Jul 16, 2019
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 Feb 7, 2013
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/"
You can’t perform that action at this time.