JavaScript Cheat Sheet

Clear an array array.length = 0 linq.js example Enumerable    .from(some_array)    .where(i => i.prop == test_value)    .select(i => {"a":i.a_val, "b":i.b_val})    .distinct(s => s["a"])    .toArray(); jQuery create new element, attach an event, and add it to the list of elements of a parent element jQuery("<span id='test'>Some text</span>")    .on("click", function() { alert( … Continue reading JavaScript Cheat Sheet

Tutorial: Making NEURON + SaveState.restore() + CVODE work

Here is a working example of running a NEURON simulation of a cell to steady state, saving that state, restoring it in a new simulation, and using the method to stimulate the cell with an arbitrary waveform. All this while using the variable integration method CVODE. First, build the cell, and run it to … Continue reading Tutorial: Making NEURON + SaveState.restore() + CVODE work

FFMPEG Cheat Sheet

  Create animated GIF (with nice colors) from a sequence of images named "img (0...N).jpg". Use "%0Nd.jpg" for 0-padded numbered files. set pattern="%04d.jp2" ffmpeg -i %pattern% -vf palettegen palette.png ffmpeg -i %pattern% -i palette.png -lavfi "fps=15, paletteuse" out.gif

NEURON Cheat Sheet

Compile all .mod files in directory nrnivmodl #NRN IV MOD L Use variable step integration h.cvode_active(1) # or 0 for fixed, note the _ h.cvode.atol(0.01) # for tolerance 0.001 is default Run sim till a specific time h.continuerun(tstop) Record value e.g. memb pot vVector = h.Vector() vVector.record(section(0.5)._ref_v) #Use h._ref_t for time #Then, after vVector.to_pyton() … Continue reading NEURON Cheat Sheet

Ruby Cheat Sheet

Upper/lower case version of a string "test".downcase "test".upcase Check if a string contains another string my_string.include? "target" Replace in string stringVar.gsub("replacewhat","withthis") # add ! to replace in-place Length of array arrVar.length Try/Catch exception handling begin error_code_here() rescue handle_error() end Ternary/conditional operator: result = condition ? if_true : if_false