Skip to content

Instantly share code, notes, and snippets.

@klowrey
klowrey / mjderiv.jl
Created April 17, 2021 03:08
port of derivative.cpp from Mujoco camples to Julia
using BangBang
using StaticArrays
using MuJoCo
struct MJDeriv
m::jlModel
dmain::jlData
datas::Vector{jlData}
@klowrey
klowrey / speed.jl
Last active December 14, 2018 20:02
faster faster!
using SIMD
using BenchmarkTools
foo(x, s, t) = x[ x .< s] .= t
foo2(x, s, t) = for i in eachindex(x) x[i] = x[i] < s ? t : x[i] end
foo3(x, s, t) = @inbounds for i in eachindex(x) x[i] = x[i] < s ? t : x[i] end
function foo3b(x, s, t)
@inbounds for i in eachindex(x)
(x[i] < s) && (x[i] = t)
end
@klowrey
klowrey / rollouts.jl
Last active November 28, 2018 22:40
mujoco.jl rollouts
using MuJoCo
function dorollout(f, T)
pm = mj_loadXML(f)
pd = mj_makeData(pm)
m = mj.mapmodel(pm)
datas = [ mj.mapdata(pm, mj_makeData(pm)) for t=1:Threads.nthreads() ]
@time begin
@klowrey
klowrey / sudo crontab -u root -e
Last active January 2, 2018 01:00
crontab for slidshow on raspberry pi
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system