Skip to content

Instantly share code, notes, and snippets.

@dubslow
dubslow / custom_inheritor.py
Last active December 15, 2019 16:53
Python recipe to "automatically delegate method calls to a proxy attribute", aka "customized inheritance"
# Following class and decorator totally jacked from Jacob Zimmerman, with a few tweaks/renames
# https://programmingideaswithjake.wordpress.com/2015/05/23/python-decorator-for-simplifying-delegate-pattern/
# (I couldn't get the default copying of the entire baseclass dict to work, because that delegates __new__,
# which chokes on the non-subclass subclass. So just remove it for now)
# What this does: allows you to "subclass" an arbitrary baseclass by delegating certain methods/fields on
# your 'subclass' to the delegate-attribute without boilerplate for each individual method/field
# Equally valid interpretation of the same semantics: "subclass" a baseclass, but allows you to exclude
# certain methods from being used on the "subclass".
# Possible use cases include: making a read-only/immutable "subclass" of the builtin/superspeed dict
@dubslow
dubslow / opnfiles.py
Last active October 30, 2017 09:19
Sort the OPN most wanted roadblocks file
#! /usr/bin/env python3
# indent width: 5 spaces
# default sort method to use:
sortkey = lambda line: line.snfs_difficulty()
###############################################################################
from math import log10
from abc import ABCMeta, abstractmethod
bill@Gravemind⌚0507 ~/cado/A4788_i5246_C195 ∰∂ nice -n 19 ../cado-nfs.py --parameters ../parameters/factor/params.c190 105720747827131650775565137946594727648048676926428801477497713261333062158444658783837181718187127016255169032147325982158719006483898971407998273736975091062494070213867530300194317862973608499
Info:root: Created temporary directory /tmp/cado.78w7oiwc
Info:root: Set tasks.threads=4 based on detected physical cpus
Info:root: tasks.polyselect.threads = 2
Info:root: tasks.sieve.sieving.threads = 2
Info:root: Command line parameters: ../cado-nfs.py --parameters ../parameters/factor/params.c190 105720747827131650775565137946594727648048676926428801477497713261333062158444658783837181718187127016255169032147325982158719006483898971407998273736975091062494070213867530300194317862973608499
Info:root: If this computation gets interrupted, it can be resumed with ../cado-nfs.py /tmp/cado.78w7oiwc/c190.parameters_snapshot.0
Info:HTTP server: Using non-threaded HTTPS server
Info:Complete Factorization:
@dubslow
dubslow / ecmnfs.py
Last active March 5, 2016 09:07
ECM to NFS crossover calculator
#! /usr/bin/python3
# Some functions to decide the crossover between NFS and ECM, given: thread hours required for NFS
# and thread hours required per curve at the given ECM level
# The premise for this module is that while ECM-work-done/odds-of-success-for-that-work is less than
# the total NFS work required, keep going.
# Thus, given the relevant parameters, this module will calculate the effective ECM-work-done
# crossover point, where it becomes more effective to switch to NFS.
@dubslow
dubslow / CCefficiency.js
Last active February 21, 2016 20:13
A simple JS script to make purchasing decisions easier in CookieClicker
/* This is a small addon script for CookieClicker to display building purchase efficiencies, in a
manner similar to FrozenCookie (though several orders of magnitude more primitive). No decisions
or playing is done on behalf of the player, this is merely some extra passive calculations. */
// first a small helper
function guardedSave(obj, funcname)
{ // if obj.oldfuncname exists, do nothing
// else: save the funcname to oldfuncname, so that funcname may be overwritten
// this protects against crashing after accidentally running this js twice
var oldfuncname = 'old' + funcname;
git diff
diff --git a/src/misc/qrwidget.cpp b/src/misc/qrwidget.cpp
index 10e971a..8070e58 100644
--- a/src/misc/qrwidget.cpp
+++ b/src/misc/qrwidget.cpp
@@ -3,8 +3,7 @@
#include <QDebug>
#include <QBuffer>
#include <QImage>
-#include "qrcodewindow.h"
What’s new under the hood
Cinnamon Backend 2.0
Prior to version 2.0, and similar to Shell or Unity, Cinnamon was a frontend on top of the GNOME desktop.
In version 2.0, and similar to MATE or Xfce, Cinnamon is an entire desktop environment built on GNOME technologies. It still uses toolkits and libraries such as GTK or Clutter and it is still compatible with all GNOME applications, but it no longer requires GNOME itself to be installed. It now communicates directly with its own backend services, libraries and daemons: cinnamon-desktop, cinnamon-session and cinnamon-settings-daemon.
Better compatibility and portability
Another very tangible gain is backward compatibility and portability. Until now Cinnamon was designed to work on top of GNOME 3… a desktop which is being actively designed and features radical changes every 6 months. For instance, it is not possible to communicate with gnome-settings-daemon 3.8 the same way as with gnome-settings-daemon 3.6. The communication protocols and ABI keep changing a
bill@Gravemind⌚1644 ~/qtox/libs/libtoxcore-latest ∰∂ git checkout master
Switched to branch 'master'
bill@Gravemind⌚1656 ~/qtox/libs/libtoxcore-latest ∰∂ git branch -D new_api
Deleted branch new_api (was eac0d43).
bill@Gravemind⌚1656 ~/qtox/libs/libtoxcore-latest ∰∂ git checkout new_api
error: pathspec 'new_api' did not match any file(s) known to git.
@dubslow
dubslow / gist:dab61346cc06d6b9cf7b
Created February 13, 2015 22:37
Git refusing to do upstream branches
bill@Gravemind⌚1630 ~/qtox/libs/libtoxcore-latest ∰∂ git checkout --track origin/new_api
fatal: Cannot update paths and switch to branch 'new_api' at the same time.
Did you intend to checkout 'origin/new_api' which can not be resolved as commit?
bill@Gravemind⌚1630 ~/qtox/libs/libtoxcore-latest ∰∂ git fetch origin
From https://github.com/irungentoo/toxcore
* branch master -> FETCH_HEAD
bill@Gravemind⌚1630 ~/qtox/libs/libtoxcore-latest ∰∂ man git fetch
bill@Gravemind⌚1631 ~/qtox/libs/libtoxcore-latest ∰∂ git remote -v
origin https://github.com/irungentoo/toxcore.git (fetch)
origin https://github.com/irungentoo/toxcore.git (push)
@dubslow
dubslow / gist:3d9d082286389be6fc41
Created February 9, 2015 00:17
SCHED_PATHOLOGY and also yafu errors
yafu "snfs(237250154152941828313706973109892307074156361791^4-1, 791919249586772436696176199809718913775207631821562640489784354274509014504024710600012012021393441994052098088717)"
02/08/15 18:12:02 v1.34.5 @ Gravemind, System/Build Info:
Using GMP-ECM 7.0-dev, Powered by GMP 6.0.0
detected Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
detected L1 = 32768 bytes, L2 = 8388608 bytes, CL = 64 bytes
measured cpu frequency ~= 3392.288560
using 1 random witnesses for Rabin-Miller PRP checks