This file contains 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
run(`wget http://julialang.org/images/logo.png`) | |
# Open png file for reading | |
fp = ccall(:fopen, Ptr{Uint8}, (Ptr{Uint8}, Ptr{Uint8}), "logo.png", "r") | |
# Read first 8 bytes | |
initial_bytes = Array(Uint8, 8) | |
ccall(:fread, Ptr{Uint8}, (Ptr{Uint8}, Uint8, Uint8, Ptr{Uint8}), initial_bytes, 1, 8, fp) | |
# Check that we actually have a png file |
This file contains 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
jason:knox jm843$ host gmail.com | |
gmail.com has address 74.125.239.53 | |
gmail.com has address 74.125.239.54 | |
gmail.com has IPv6 address 2607:f8b0:4010:801::1016 | |
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com. | |
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com. | |
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com. | |
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com. | |
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com. | |
jason:knox jm843$ nc alt3.gmail-smtp-in.l.google.com 25 |
This file contains 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 PowerSeries | |
function series_loop() | |
accum = 0.0 | |
for i = 1:10000 | |
accum += sin(Series(1.0*i, 1.0)).ep | |
end | |
end | |
function dual_loop() |
This file contains 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 Roots | |
# Alternative "mean" definition that operates on the binary representation | |
# of a float. Using this definition, bisection will never take more than | |
# 64 steps. | |
function _middle(x::Float64, y::Float64) | |
# Use the usual float rules for combining non-finite numbers | |
if !isfinite(x) || !isfinite(y) | |
return x + y | |
end |
This file contains 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 genS_jl(I) | |
s0 = 600.0 | |
r = 0.02 | |
sigma = 2.0 | |
T = 1.0 | |
M = 100 | |
dt = T/M | |
a = (r - 0.5*sigma^2)*dt | |
b = sigma*sqrt(dt) |
This file contains 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
const states = ["Healthy", "Fever"] | |
const obsnames = ["normal", "cold", "dizzy"] | |
const start_probability = [0.6, 0.4] | |
const transition_probability = [ | |
0.7 0.3 | |
0.4 0.6 | |
] |
This file contains 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 graythresh_kmeans(img) | |
# Note, without the type annotation, this is slow because | |
# mean appears not to be type stable here | |
thresh = mean(img)::Gray{Float32} | |
while true | |
lastthresh = thresh | |
nplus = 0 | |
nminus = 0 | |
splus = zero(typeof(thresh)) |
This file contains 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
9345,9351c9345,9374 | |
- var previousDrawId = 0; | |
- function domUpdate(newScene) { | |
- previousDrawId = ElmRuntime.draw(previousDrawId, function(_) { | |
- Render.update(elm.node.firstChild, savedScene, newScene); | |
- if (elm.Native.Window) elm.Native.Window.values.resizeIfNeeded(); | |
- savedScene = newScene; | |
- }); | |
+ | |
+ // domUpdate is called whenever the main Signal changes. On domUpdate, |
This file contains 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
'use strict'; | |
var Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {}; | |
var ElmRuntime = {}; ElmRuntime.Render = {}; | |
Elm.Native.Array = {}; | |
Elm.Native.Array.make = function(elm) { | |
elm.Native = elm.Native || {}; | |
elm.Native.Array = elm.Native.Array || {}; | |
if (elm.Native.Array.values) return elm.Native.Array.values; | |
if ('values' in Elm.Native.Array) | |
return elm.Native.Array.values = Elm.Native.Array.values; |
This file contains 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
jwm@jason ~/s/elm-platform> runhaskell src/BuildFromSource.hs master | |
Writing a default package environment file to | |
/Users/jwm/src/elm-platform/Elm-Platform/master/cabal.sandbox.config | |
Creating a new sandbox at /Users/jwm/src/elm-platform/Elm-Platform/master | |
Cloning into 'elm-compiler'... | |
remote: Counting objects: 17753, done. | |
remote: Compressing objects: 100% (100/100), done. | |
remote: Total 17753 (delta 56), reused 0 (delta 0) | |
Receiving objects: 100% (17753/17753), 5.44 MiB | 1.20 MiB/s, done. | |
Resolving deltas: 100% (10044/10044), done. |
OlderNewer