Skip to content

Instantly share code, notes, and snippets.

View Zitrax's full-sized avatar
👽

Daniel Bengtsson Zitrax

👽
View GitHub Profile
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:3857270
Created October 9, 2012 08:01
Find unused perl functions
#!/bin/bash
# Note this requires git compiled with USE_LIBPCRE
# to be able to use -P to git grep.
# And currently for some reason the regexp causes a segmentation fault
# when searching for some functions.
NCORES=`grep -c ^processor /proc/cpuinfo`
@Zitrax
Zitrax / gist:90f726a24785844a052d9cd5a4e44c11
Created April 5, 2016 14:33
Random critic review for debug
#!/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
[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:4730967
Created February 7, 2013 13:37
Tiny python script to search for pastebin entries
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/"
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "brainblast-1.0";
src = fetchurl {
url = https://github.com/Zitrax/brainblast/archive/2068025f3a411000ee506f525188d586c327d226.tar.gz;
sha256 = "116pddal9n3bypnj3q6sggrzphzq1rfkqh5skyqfa1ha7mlspl19";
};
@Zitrax
Zitrax / stringformat.cpp
Created December 16, 2017 20:51
string format with auto conversion of std::string
#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) {
@Zitrax
Zitrax / Dockerfile
Last active October 7, 2020 09:38
Critic docker experiment
# 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 / cronlist.sh
Created October 2, 2012 14:17 — forked from nitehawk/cronlist.sh
Script to list all cron events on a system - found on stackoverflow.com: http://bit.ly/nkFwD9 Modified from original to pick up users also in /home.
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@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
#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