Skip to content

Instantly share code, notes, and snippets.

using Luxor
function array2dtogrid(a2d::AbstractArray)
g = Tiler(200, 200, size(a2d)[1:2]..., margin=25)
for (pos, n) in g
setgray(a2d[n])
box(pos, g.tilewidth, g.tileheight, :fill)
setgray(1-a2d[n])
text(string(round(a2d[n], 2)), pos, halign=:center)
end
end
@cormullion
cormullion / gist:2282e543426db27022f5bbc8ee3a6c65
Created May 19, 2017 08:58
Trying to install Plots.jl on julia v0.6 rc-1
MacBook-Pro ~ $ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0-rc1.0 (2017-05-07 00:00 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin13.4.0
@cormullion
cormullion / poincare.jl
Last active January 14, 2021 21:36
poincare section of chaotic network of three neurons
# most of the code is by Rainer Engelken
# updated to Julia 1.0 syntax, tested on 1.4
using Luxor, StaticArrays
# poincare section of chaotic network of three neurons
function spikingnet(n, couplingstrength=1.0)
# number of spikes in calculation
@cormullion
cormullion / getjuliaconyoutube.jl
Last active August 5, 2017 09:08
get JuliaCon2017 videos from YouTube as list
using HTTP, JSON, Query
# get data for the julia channel "UC9IuUwwE2xdjQUT_LMLONoA"
function getrawdata(nextpagetoken, apikey)
d = HTTP.get("https://www.googleapis.com/youtube/v3/search?key=$(apikey)&channelId=UC9IuUwwE2xdjQUT_LMLONoA&pageToken=$(nextpagetoken)&part=snippet,id&order=date&maxResults=50")
return d.body
end
jsonpages = [] # store the json pages, 50 records at a time
vidlinks = [] # to hold the video titles and links
julia> Pkg.status()
37 required packages:
- AstroLib 0.1.0
- Atom 0.6.1
- BenchmarkTools 0.0.8
- Cairo 0.3.0
- ColorSchemes 1.4.0+ master
- Combinatorics 0.4.1
- DataFrames 0.10.0
- Documenter 0.11.1
@cormullion
cormullion / juliapool.jl
Last active September 17, 2022 13:22
julia pool
using Luxor, Colors, Combinatorics, Random
mutable struct Ball
id::Int
position::Point
velocity::Point
color::Union{NTuple, Colorant, String}
ballradius::Float64
end
@cormullion
cormullion / pendulum.jl
Last active October 23, 2022 15:09
pendulum logo
using Luxor
using ODE # I should be using OrdinaryDiff, but that's for another day
function pendulum(t, y)
Y = [6 * (2 * y[3] - 3 * cos(y[1] - y[2]) * y[4])/(16 - 9 * cos(y[1] - y[2])^2);
6 * (8 * y[4] - 3 * cos(y[1] - y[2]) * y[3])/(16 - 9 * cos(y[1] - y[2])^2)]
[Y[1];
Y[2];
- (Y[1] * Y[2] * sin(y[1] - y[2]) + 3 * sin(y[1]))/2;
@cormullion
cormullion / pendulums.jl
Last active October 24, 2022 11:39
George's double pendulums
using Luxor, DynamicalSystems, Colors
function frame(scene, framenumber, datas)
background("black")
# datas contains two datasets
# each dataset is an array of sarrays of 4 floats
d1, d2 = datas
offset = π / 2
L = 200
disksize = 15
@cormullion
cormullion / stripey.jl
Last active October 22, 2017 12:51
a stripey logo
using Luxor
darker_blue = (0.251, 0.388, 0.847)
darker_purple = (0.584, 0.345, 0.698)
darker_green = (0.22, 0.596, 0.149)
darker_red = (0.796, 0.235, 0.2)
@png begin
w = 256
background("white")
origin()
@cormullion
cormullion / calendar-2018.jl
Created December 15, 2017 11:46
calendar-2018.jl
using Luxor
pentagon(pos, radius, ang=0, action=:stroke) = ngon(pos, radius, 5, ang, vertices=true)
function drawmonth(year, month, radius)
# origin is now in center of pentagon
@layer begin
rotate(pi)
fontsize(18)
fontface("DINNextLTPro-Black")