Skip to content

Instantly share code, notes, and snippets.

@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]
@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 / 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 / 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 / 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 / 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": [
{
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 / bitarray_test.py
Created September 30, 2014 23:08
faster bit transitions
import bitarray
import time
import numpy as np
a = np.arange(100000, dtype=np.uint64)
def transitions(a):
b = bitarray.bitarray()
b.frombytes(a.tostring())
c=b.itersearch(bitarray.bitarray("01"))
return [d for d in c]
import Base: isempty, copy, eltype, sizehint, push!, union!, pop!, delete!, ==, <, <=, length, start, next, done,
setdiff, symdiff, symdiff!, setdiff!, show, first, last, intersect, intersect!, symdiff, symdiff!
using Base.Test
type IntSetBitVector
b::BitVector # n is in IntSet if s[n+1]==true
fill1s::Bool
IntSetBitVector() = new(falses(256), false)
end
IntSetBitVector(itr) = (s=IntSetBitVector(); for a in itr; push!(s,a); end; s)
@ggggggggg
ggggggggg / submit.md
Created August 3, 2014 14:51
Possible Pkg.submit() info

Pkg has noticed that your local git repository is not ready to create a pull request.

Best practice is to create a feature branch before you make any changes.

git checkout master
git checkout -b yourfeaturebranch

Then make your changes, including adding relevant test cases in to test/runtests.jl, and ensure the tests all pass. Then commit our changes before running Pkg.submit("PackageName") again.

git add .