Skip to content

Instantly share code, notes, and snippets.

Erik Engheim ordovician

  • Translusion
  • Oslo, Norway
Block or report user

Report or block ordovician

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
ordovician / dump-pixmap.cpp
Created Jan 9, 2019
[Dump QPixmap to File] This is to help debug code where pixmaps are created #qt
View dump-pixmap.cpp
#include <QtCore/QFile>
#include <QtCore/QDir>
/// Store pixmap in home directory as .png file
static void
DumpPixmapToFile(const QPixmap &pixmap) {
QString filepath = QDir::home().filePath("debug-pattern.png");, "PNG");
ordovician /
Created Oct 18, 2018
[Remove trailing whitespace] Allows you to do through all files in subdirecttory and remove any occurance of trailing whitespace. Make sure you got these files under version control as it will do in place replacement. #unix #shell #sed
find . -type f | xargs sed -i 's/[ \t]*$//'
ordovician / leppo.jl
Last active Oct 3, 2018
[lepton experiment] Trying of new program #experiment #hack
View leppo.jl
for i in 1:length(M)
ordovician / settingstable.swift
Last active Oct 3, 2018
[Tap anywhere in text cell] How to make UITextField first responder when tapping anywhere inside a table view cell. Just like Apple's "Settings" app. #firstresponder #viewcell
View settingstable.swift
class Settings : UITableViewController {
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)
// The cells contentview is the one containing custom added components.
if let subviews = cell?.contentView.subviews {
// Find a subview which is a UITextField. Place cursor in this textfield.
for view in subviews {
if let textfield = view as? UITextField {
ordovician / degrees.go
Last active Oct 3, 2018
[Custom number types in Go] Shows how you can utilize the fact that using the keyword "type" in Go create a new type unlike typedef in C. Allows us work with numbers without mixing up the units.
View degrees.go
package main
import (
type Celsius float64
// Implement Stringer interface, used by %s in Printf
func (deg Celsius) String() string {
ordovician / gocompletion.jl
Last active Oct 3, 2018
[Text Mate Bundle for Go] Method, variable and function completion for the Go language written in Julia. Put this in a TextMate bundle. Currently too slow to be practical due to slow Julia startuptime #tmbundle #go #plugin
View gocompletion.jl
#!/usr/bin/env julia
using PList
import GoTMSupport
bundle_support = ENV["TM_BUNDLE_SUPPORT"]
dialog = ENV["DIALOG"]
gocode = ENV["TM_GOCODE"]
filepath = ENV["TM_FILEPATH"]
row = int(ENV["TM_LINE_NUMBER"])
col = int(ENV["TM_LINE_INDEX"]) + 1
ordovician / EquivalenceRelations.jl
Last active Jan 2, 2016
Equivalence Relations in modulo aritmetic.
View EquivalenceRelations.jl
mod(A, C) == r
# then
mod(A + k*C, C) == r
# so if
mod(A, C) == mod(B, C)
ordovician / CongruenceModulo.jl
Last active Oct 3, 2018
[CongruenceModulo] Functions I made for solving problems in the Khan Academy excercises on Congruence Modulo. Usefull stuff to understand when learning about cryptograpy, like the RSA algorithm used in SSL/TSL as used in HTTPS. If two values A and B gives the same result when doing mod(A, C) and mod(B, C) then they are in the same equivalence cl…
View CongruenceModulo.jl
# check if A is congruent to B modulo C.
in_same_equivalence_class(A, B, C) = mod(A, C) == mod(B, C)
# find all X in Xs where X is congruent to B modulo C
function find_numbers_in_same_equivalence_class(A, C, Xs)
r = mod(A, C)
filter(X->mod(X,C) == r, Xs)
ordovician / .gitconfig
Last active Oct 3, 2018
[Pretty git logs] Pretty logs in git and support for using sourcetree for merging. From #git #config
View .gitconfig
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = /Applications/ \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
trustExitCode = true
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ordovician /
Created May 18, 2013
My configuration file for the fish shell
# Make the blue color for directories more readable
set -x LSCOLORS Exfxcxdxbxegedabagacad
# this is needed to avoid strange python stack backtrace complaining about UTF-8 when
# running sphinx. Found it by googling
set -x LC_ALL en_US.UTF-8
set -x LANG en_US.UTF-8
set -x JULIA_EDITOR textmate
# so our brew install override the commands from the system
You can’t perform that action at this time.