Skip to content

Instantly share code, notes, and snippets.

Hessam Mehr hessammehr

View GitHub Profile
View Angular momentum.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View efficient_flatten.jl
function Base.iterate(mf::MyFlatten{I,T}, state=nothing) where {I,T}
if state===nothing
val = iterate(mf.a)
val === nothing && return nothing
itr, s = val
res = iterate(itr)
else
itr, s, inner_s = state
res = iterate(itr, inner_s)
end
View plot.jl
using RecipesBase
using StatPlots
@userplot MeanPlot
@userplot AutocorPlot
@userplot HistogramPlot
@userplot DensityPlot
@userplot MixedDensityPlot
@userplot TracePlot
View Julia 0.6.4 - IJulia debug + jupyter notebook --debug
(base) C:\Users\User>jupyter notebook --debug
[D 21:42:25.972 NotebookApp] Searching ['C:\\Users\\User', 'C:\\Users\\User\\.jupyter', 'C:\\Users\\User\\Miniconda3\\etc\\jupyter', 'C:\\ProgramData\\jupyter'] for config files
[D 21:42:25.972 NotebookApp] Looking for jupyter_config in C:\ProgramData\jupyter
[D 21:42:25.973 NotebookApp] Looking for jupyter_config in C:\Users\User\Miniconda3\etc\jupyter
[D 21:42:25.973 NotebookApp] Looking for jupyter_config in C:\Users\User\.jupyter
[D 21:42:25.973 NotebookApp] Looking for jupyter_config in C:\Users\User
[D 21:42:25.974 NotebookApp] Looking for jupyter_notebook_config in C:\ProgramData\jupyter
[D 21:42:25.974 NotebookApp] Looking for jupyter_notebook_config in C:\Users\User\Miniconda3\etc\jupyter
[D 21:42:25.974 NotebookApp] Looking for jupyter_notebook_config in C:\Users\User\.jupyter
@hessammehr
hessammehr / log jupyter console + IJulia debug.txt
Created Aug 4, 2018
Comparison of output from jupyter console and jupyter notebook (IJulia master - debug + Julia 0.7rc2
View log jupyter console + IJulia debug.txt
[ Info: Recompiling stale cache file C:\Users\User\.julia\compiled\v0.7\IJulia\nfu7T.ji for IJulia [7073ff75-c697-5162-941a-fcdaad2a7d2a]
┌ Warning: __precompile__() is now the default
│ caller = top-level scope at none:0
└ @ Core none:0
┌ Warning: __precompile__() is now the default
│ caller = top-level scope at none:0
└ @ Core none:0
PROFILE = Dict{String,Any}("key"=>"cb9fd8c0-c339d5f3ef4a0e882c7380da","transport"=>"tcp","signature_scheme"=>"hmac-sha256","shell_port"=>59222,"hb_port"=>59226,"control_port"=>59225,"ip"=>"127.0.0.1","stdin_port"=>59224,"iopub_port"=>59223,"kernel_name"=>"julia-0.7")
20:21:26(): SENDING IPython Msg [ idents status ] {
parent_header = Dict("username"=>"jlkernel","session"=>"UUID(\"dd9690db-232f-454c-baf9-bfd29644aafd\")"),
@hessammehr
hessammehr / anagram.rs
Last active May 15, 2017
Anagram scoring in Rust
View anagram.rs
#[derive(Debug,Clone)]
struct Match {
c: u8, // character
pos: usize // position
}
fn score(matches: &[Match]) -> usize {
let l = matches.len();
let mut s = 1;
if l < 2 { return s }
@hessammehr
hessammehr / anagram.jl
Last active May 4, 2017
Anagram scoring in Julia
View anagram.jl
function anagram_score(str1, str2)
# score for a sequence: [1,2,3,4] => 1; [1,4,2,3] => 3
score(sec) = count(i->i!=1,sec[2:end]-sec[1:end-1]) + 1
function match_inner(str1,tokens,accu)
if str1 == ""
score(accu)
else
minimum(match_inner(str1[2:end],filter(t->t!=x,tokens),[accu;x[2]]) for x in filter(t -> (t[1] == str1[1]), tokens))
end
end
@hessammehr
hessammehr / actions.cljs
Created Dec 16, 2015
Cyclic dependency with quoted vars
View actions.cljs
(ns myapp.actions
:require [myapp.core :refer app-state])
(defn action1 []
(swap! app-state inc)
View gist:e603bf196138b496dfc3
(import '[edu.emory.mathcs.jtransforms.fft DoubleFFT_1D])
(defn fft [data] (let [a-data (into-array Double/TYPE data)
fftfun (DoubleFFT_1D. (count data))
dummy (.realForward fftfun a-data)] a-data))
;; Example: Constant signal
(fft (take 128 (repeat 1.0)))
;; [optional] view the result as vector
You can’t perform that action at this time.