This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
compgen -c | sort | uniq | sort -R | tail -n 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dates | |
function findfirst_tuesday(d::Date) | |
fd = dayofweek(firstdayofmonth(d)) | |
return Tuesday - fd + 1 + 7(fd > Tuesday) | |
end | |
findfirst_tuesday(m::Month, y::Year) = findfirst_tuesday(Date(m, y)) | |
function penultimate_tuesday_date(m::Month, y::Year) | |
ft = findfirst_tuesday(m, y) # first Tuesday |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This was my version of Formatting.jl's `format(..., comma = true)` | |
# I did this for fun, not having a look at Formatting.jl's version | |
# It looks like this is how they did it: | |
# https://github.com/JuliaIO/Formatting.jl/blob/master/src/cformat.jl#L77-L93 | |
# Quite different to how I did it...probably benchmarks better though | |
function format_number(n::String, delim::Union{Char, S}) where {S <: AbstractString} | |
len = length(n) | |
io = IOBuffer() | |
for (i, c) in enumerate(reverse(n)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Some{T} | |
val::T | |
function Some{T}(val::T) where {T} | |
isnothing(val) && error("Cannot have some of nothing") | |
return new{T}(val) | |
end | |
end | |
Some(val::T) where {T} = Some{T}(val) | |
struct Option{T} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ported from https://gist.github.com/MicahElliott/719710 | |
# Credit goes to Micah Elliott | |
using Colors | |
using OrderedCollections | |
CLUT = Tuple{String, String}[ # color look-up table | |
# 8-bit, RGB hex | |
# Primary 3-bit (8 colors). Unique representation! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function takeFirst<T>(arr: T[]) { | |
const firstVal: T = arr[0]; | |
arr.splice(0, 1); | |
return firstVal; | |
} | |
SM.addState(State.SubTrial, { | |
onEnter: (machine: stateMachine.Machine, blockStruct: BlockStruct) => { | |
if (blockStruct.trialArrayURLs.length === 0) { | |
// then we need to initialise another trial! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SM.addState(State.FixationCross, { | |
onEnter: (machine: stateMachine.Machine, blockStruct: BlockStruct) => { | |
gorilla.populate('#gorilla', 'fixation', {}); | |
$('#gorilla') | |
.delay(beforeFixationDelay) | |
.queue(function () { | |
$('.fixation-cross').show(); | |
gorilla.refreshLayout(); | |
$(this).dequeue(); | |
})// end queue for '#gorilla' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nztm2longlat(X::T, Y::T) where T <: Number | |
a = 6378137 | |
f = 1 / 298.257222101 | |
ϕ0 = 0 | |
λ0 = 173 | |
N0 = 10000000 | |
E0 = 1600000 | |
k0 = 0.9996 | |
N, E = Y, X | |
b = a * (1 - f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, math | |
def nztm2longlat(X, Y): | |
a = 6378137 | |
f = 1 / 298.257222101 | |
phizero = 0 | |
lambdazero = 173 | |
Nzero = 10000000 | |
Ezero = 1600000 | |
kzero = 0.9996 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# f = open(experiment_path + '/' + 'subject-' + str(subject_nr) + '-auxiliary.csv', 'a') # this will create an auxiliary datafile for participant (`subject_nr` is a predefined variable) | |
f = open(logfile, 'a') # this will append to the log file (`logfile` is a predefined variable) | |
f.write('ISI,\n') | |
for ISI in [[1900, 2000, 2100][random.randint(0, 2)] for _ in range(100)]: | |
f.write(str(ISI) + ',\n') | |
f.close() |
NewerOlder