Skip to content

Instantly share code, notes, and snippets.

import gorilla = require('gorilla/gorilla');
// Initialise the timer
var stateTimer: gorilla.GorillaTimerSequence;
// Add variable to determine delay
var allowedTime: number = 2000; // set original timer to 2 seconds (2000 milliseconds)
// check if textbox is selected
if ($(document.activeElement).attr("type") == "text" || $(document.activeElement).attr("type") == "textarea") {
from PIL import Image # this is used to create the images
import glob # this is used for reading the directory (folder) of images
import random # this is used to choose 25 unique random images
from math import ceil, floor
distractors = glob.glob("Distractor/*") # this is where you need to put your path to directory
cars = glob.glob("Cars/*")
faces = glob.glob("Faces/*")
hf_pareidolia = glob.glob("Highface pareidolia/*")
lf_pareidolia = glob.glob("Lowface pareidolia/*")
mutable struct Sudoku{T <: Integer} <: AbstractMatrix{T}
A::AbstractMatrix{T} where {T <: Integer}
function Sudoku(A::AbstractMatrix{T}) where {T <: Integer}
size(A, 1) == size(A, 2) || throw(error("Sodokus must be square; received matrix of size $(size(A, 1))×$(size(A, 2))."))
isequal(sqrt(size(A, 1)), isqrt(size(A, 1))) || throw(error("Sudokus must be able to split into equal boxes (e.g., a 9×9 Sudoku has three 3×3 squares). Size given is $(size(A, 1))×$(size(A, 2))."))
new{T}(A)
end
# fill in blank sudoku if needed
Sudoku(::Type{T}, n::Int) where {T <: Integer} = new{T}(fill(zero(T), n, n))
using Images
using BenchmarkTools
using Profile
import Base: size, getindex, LinearIndices
using Images: Images, coords_spatial
struct IntegralArray{T, N, A} <: AbstractArray{T, N}
data::A
end
@jakewilliami
jakewilliami / glm_submission.jl
Last active October 27, 2020 00:08
GLM submission for the Humans of Julia
#=
Motivation: I want to model psychometric data to some kind of sigmoid function, but the nature
of psychometric data is that it is forced choice. This means that the output is binary.
GLM doesn't support forced choice models yet——however, with a little bit of work and some
type piracy, the results are attractive.
=#
using GLM, DataFrames, CSV, FreqTables, StatsPlots, Distributions, Statistics
const Dist = Distributions
# imports for overloading
This file has been truncated, but you can view the full file.
julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
1╎1 @Base/char.jl:124; UInt32(::Char)
╎6094 @Base/client.jl:506; _start()
╎ 6094 @Base/client.jl:313; exec_options(::Base.JLOptions)
╎ 6094 @Base/client.jl:383; run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool)
╎ 6094 @Base/essentials.jl:709; invokelatest
╎ 6094 @Base/essentials.jl:710; #invokelatest#1
╎ 6094 @Base/client.jl:399; (::Base.var"#807#809"{Bool,Bool,Bool,Bool})(::Module)
This file has been truncated, but you can view the full file.
julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
2╎2 @Base/char.jl:124; UInt32(::Char)
╎6575 @Base/client.jl:506; _start()
╎ 6575 @Base/client.jl:313; exec_options(::Base.JLOptions)
╎ 6575 @Base/client.jl:383; run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool)
╎ 6575 @Base/essentials.jl:709; invokelatest
╎ 6575 @Base/essentials.jl:710; #invokelatest#1
╎ 6575 @Base/client.jl:399; (::Base.var"#807#809"{Bool,Bool,Bool,Bool})(::Module)
This file has been truncated, but you can view the full file.
julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
1╎1 @Base/char.jl:124; UInt32(::Char)
╎18097 @Base/client.jl:506; _start()
╎ 18097 @Base/client.jl:313; exec_options(::Base.JLOptions)
╎ 18097 @Base/client.jl:383; run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool)
╎ 18097 @Base/essentials.jl:709; invokelatest
╎ 18097 @Base/essentials.jl:710; #invokelatest#1
╎ 18097 @Base/client.jl:399; (::Base.var"#807#809"{Bool,Bool,Bool,Bool})(::Module)
This file has been truncated, but you can view the full file.
julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
╎4505 @Base/client.jl:506; _start()
╎ 4505 @Base/client.jl:313; exec_options(::Base.JLOptions)
╎ 4505 @Base/client.jl:383; run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool)
╎ 4505 @Base/essentials.jl:709; invokelatest
╎ 4505 @Base/essentials.jl:710; #invokelatest#1
╎ 4505 @Base/client.jl:399; (::Base.var"#807#809"{Bool,Bool,Bool,Bool})(::Module)
╎ ╎ 4505 ...e/julia/stdlib/v1.5/REPL/src/REPL.jl:288; run_repl(::REPL.AbstractREPL, ::Any)
@jakewilliami
jakewilliami / mwe-fd-time-efficient.jl
Created October 25, 2020 12:33
Time efficient MWE for algorithm involving image IO (MEMORY INEFFICIENT)
using Images
using BenchmarkTools
import Base: size, getindex, LinearIndices
using Images: Images, coords_spatial
struct IntegralArray{T, N, A} <: AbstractArray{T, N}
data::A
end