Skip to content

Instantly share code, notes, and snippets.

function mandel(z)
c = z
maxiter = 80
for n = 1:maxiter
if abs(z) > 2
return n-1
end
z = z^2 + c
end
return maxiter
@ggggggggg
ggggggggg / demo.jl
Last active August 29, 2015 14:08
IJulia Notebook Demo
{
"metadata": {
"language": "Julia",
"name": "",
"signature": "sha256:7747d1f82629502d590ed8b134a51a0d231faf6a793701636386fffce40ce0d7"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
@ggggggggg
ggggggggg / emissioncalc.jl
Created January 27, 2015 22:52
xray emission calculations
# see https://www.evernote.com/l/AHCKsZl_vf9Kx4r4YCt4M0iKF_3lD5qnhzs
# μₑfrac absoprtion coeffiecient due to the edge of interest, as a fraction of μt
# μt mu total for incident xrays
# μf mu total for fluoresced xray
# note that all 3 μ's are energy dependent
# θ angle of detector relative to sample surface
# ϕ angle of incident beam relative to sample surface
# t sample thickness
# ϵ probability of fluoresecnce given incident x-ray absorption
@ggggggggg
ggggggggg / howto.md
Last active August 29, 2015 14:14
Julia: How to use a Secret API Key for automated testing on Travis-CI

If you are writing a package to interface with an API that requires a secret key, it is not a good idea to include a copy of the secret key in your git repository. Wihtout the key however, you can't run automated tests. Travis-CI has a workaround for this, and I'll show you how to use it in Julia. First you need to install the travis gem, if you already have ruby installed this is simply gem install travis. Next we're going to use the travis encrypt feature, go into the git reposity you want to access the key from and do

travis encrypt TEST_SECRET=secretvalue --add

This will add some information to your .travis.yml file that looks like

env:
@ggggggggg
ggggggggg / scopefit.py
Last active August 29, 2015 14:14
sampling scope time zero
import numpy as np
import pylab as plt
from scipy.optimize import curve_fit
import gpib_instrument
scope = gpib_instrument.Gpib_Instrument(pad=3)
scope.ask("OUT TRA1")
def ask(s):
scope.write(s)
r = ""
@ggggggggg
ggggggggg / ComVideo.pgm
Created March 6, 2015 22:42
andor basic program to write data to serial port
// setup serial port
baud(2,9600)
Handshake(2,0)
// use background subtracted data
SetDataType(2)
//camera settings
// send timings
@ggggggggg
ggggggggg / masspsuedo.jl
Created March 7, 2015 00:20
psuedocode for mass
function update_channel(ljhfile)
getnewpulses(pulses!, ljhfile)
#summarize
oldsummarizelen = length(p_pretrig_mean)
newsummarizelen = length(pulses)
for j=oldsummarizelen+1:newsummarizelen
summaryj = summarize(pulses[j])
p_pretrig_mean[j] = summaryj[1]
p_pulse_mean[j] = summaryj[2]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ggggggggg
ggggggggg / searchsorted2.jl
Last active August 29, 2015 14:20
searchsorted2
function searchsortedfirst2vec(a,b)
[searchsortedfirst(a,bb, 1, length(a), Base.Sort.Forward) for bb in b]
end
c=searchsorted2(a,b)
# returns an array of indicies into a such that each points is the first value in a[i] greater than b[i]
# assumes both a and b are sorted
function searchsortedfirst2a(a,b,o::Base.Sort.Ordering=Base.Sort.Forward)
alow = 1
@ggggggggg
ggggggggg / chan_bench.go
Created June 30, 2015 16:12
Some go vs julia concurrency comparisons
package main
import "time"
import "fmt"
func counter(c chan int, N int) {
for j := 1; j <= N; j++ {
c <- j
}
}