Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mpartel on github.
  • I am mpartel (https://keybase.io/mpartel) on keybase.
  • I have a public key ASDbFQvnbDIE2N-vAhdcI7DBKF-eHqy167m1jlBO8hm-KQo

To claim this, I am signing this object:

@mpartel
mpartel / xnest_aliases.txt
Created March 6, 2016 20:17
Xnest aliases
alias xnest_on='PREV_DISPLAY=$DISPLAY ; ( Xnest -geometry 1440x900 :99 & ) ; export DISPLAY=:99'
alias xnest_off='export DISPLAY=$PREV_DISPLAY ; unset PREV_DISPLAY ; killall Xnest'
@mpartel
mpartel / gist:891ede826b987b694d26
Created January 19, 2016 10:49
Test case for bindfs issue #28
# Issue #28
testenv("", :title => "many files in a directory") do
mkdir('src/dir')
expected_entries = ['.', '..']
10000.times do |i|
touch("src/dir/#{i}")
expected_entries << i.to_s
end
assert { Dir.entries('mnt/dir').sort == expected_entries.sort }
@mpartel
mpartel / gist:6369493
Created August 28, 2013 18:28
TMC speedrun winners query
c = Course.find(21)
available = AvailablePoint.course_points(c).map(&:name).sort
user_times = User.all.map do |u|
pts = u.awarded_points.where(:course_id => c.id).includes(:submission)
raise 'wtf' if pts.uniq != pts
if pts.map(&:name).sort == available
last = pts.map(&:submission).map(&:created_at).max
[u.username, last]
else
nil
<?php
/**
* Asserts that all data in the fields of $from is present in $to,
* except don't care about $exceptFields in $from.
*
* Works with private fields. Ignores static fields. Ignores empty fields.
*
* This is useful as a basic sanity check that data was copied without
* asserting it field-by-field, which is error-prone.
* If a new field appears in the source object, the test breaks and forces
@mpartel
mpartel / tmc-käppyrät.markdown
Created November 24, 2012 19:11
Profiloijan käppyröiden integrointi TMC:hen

Halutaan, että testien kirjoittajan ei tarvitse sanoa muuta kuin että "tästä tehdään graafi". Kirjasto olkoon muulla tavoin konffattava sen suhteen, mihin graafi menee ja miten se näytetään.

Ehdotan, että profilointikirjasto ei oletuksena tee graafeille mitään. Jos ympäristömuuttuja (nimeltään esim.) PROFILER_VISUALIZATIONS_TO_FILE=tiedostonimi on asetettu, data tallennetaan tuohon tiedostoon.

Jos ympäristömuuttuja PROFILER_VISUALIZATIONS_SHOW=1 on asetettu, testi pysähtyköön ja näyttäköön graafin. Jälkimmäinen olisi hyvä lähinnä kirjaston tai testien debuggaamiseen, mutta se olisi normaalitapauksessa pois päältä. Vaihtoehtoisesti kirjastossa voi olla metodin versio tai parametri, joka pakottaa näyttämään graafin heti.

Siirretään graafien näyttämislogiikka omaan kirjastoonsa, johon on pääkirjastosta riippuvuus. TMC:n NB-plugini käyttää näyttämiskirjastoa ja asettaa tiedostoontallennusympäristömuuttujan. Näyttämiskirjastossa olkoon tapa saada testiluokan ja testimetodin perusteella lista graafeista, jot