Jekyll2019-10-17T21:17:00+00:00http://www.neuralcoder.science/feed.xmlNeural CoderA website about things.Marvin Thielkpython3 virtual env aliases2019-10-15T00:00:00+00:002019-10-15T00:00:00+00:00http://www.neuralcoder.science/Venvs<p>So I recently transitioned from using conda environments to python virtual environments. They’re pretty similar but I’ve written a couple scripts to make things easier for myself.</p>
<h3 id="installation-stepsnotes">Installation steps/notes:</h3>
<ol>
<li>If you’re on a mac you have to install python 3 because they still come with <a href="https://pythonclock.org/">python 2</a> for some reason…
<ul>
<li>No included package manager? Install <a href="https://brew.sh">homebrew</a></li>
<li><code class="highlighter-rouge">brew install python3</code></li>
</ul>
</li>
<li>I prefer to keep all my venvs in one location <code class="highlighter-rouge">~/envs/</code>
<ul>
<li><code class="highlighter-rouge">mkdir envs</code></li>
<li><code class="highlighter-rouge">cd envs</code></li>
<li><code class="highlighter-rouge">python3 -m venv whatever_venv_name_you_want</code></li>
</ul>
</li>
<li>Add a script to <code class="highlighter-rouge">.bashrc</code> or <code class="highlighter-rouge">.bash_profile</code> to make activation aliases
<ul>
<li>This script makes activate-name_of_venv an alias that points to the correct bash command for all envs in <code class="highlighter-rouge">~/envs/</code>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>for D in ~/envs/*/
do
D="${D%"${D##*[!/]}"}"
N="${D##*/}"
alias activate-$N="source $D/bin/activate"
done
</code></pre></div> </div>
</li>
<li><code class="highlighter-rouge">source .bashrc</code> or restart your terminal</li>
</ul>
</li>
<li>Install ipykernel for jupyter hub or notebooks
<ul>
<li><code class="highlighter-rouge">activate-name_of_venv</code></li>
<li><code class="highlighter-rouge">pip install ipykernel</code></li>
<li><code class="highlighter-rouge">python -m ipykernel install --user --name name_of_venv --display-name "name_of_venv"</code></li>
</ul>
</li>
</ol>Marvin ThielkSo I recently transitioned from using conda environments to python virtual environments. They’re pretty similar but I’ve written a couple scripts to make things easier for myself.Re-enable network discovery on Windows 102019-08-04T00:00:00+00:002019-08-04T00:00:00+00:00http://www.neuralcoder.science/Network-Windows-10<p>So it turns out windows 10 has deprecated HomeGroups in update 1803 to to encourage paying them to put your data on their computers…</p>
<h3 id="to-re-enable-it">To re-enable it:</h3>
<ol>
<li>Open the Windows Services Management Console (services.msc).</li>
<li>In the list of services, look for the Function Discovery Resource Publication service. It must be disabled.</li>
<li>Change the service startup type from Manual to Automatic (Delayed Start).</li>
<li>restart or right click on the service and start it</li>
</ol>
<p>I found the instructions from <a href="http://woshub.com/network-computers-not-showing-windows-10/">here</a>.</p>Marvin ThielkSo it turns out windows 10 has deprecated HomeGroups in update 1803 to to encourage paying them to put your data on their computers…Black Jupyter Notebook2019-03-25T00:00:00+00:002019-03-25T00:00:00+00:00http://www.neuralcoder.science/Black-Jupyter<p>I was looking to auto format my notebooks with <a href="https://github.com/ambv/black">Black</a></p>
<p>I found a couple such as</p>
<ul>
<li>https://github.com/drillan/jupyter-black</li>
<li>https://github.com/dnanhkhoa/nb_black</li>
<li>https://github.com/csurfer/blackcellmagic</li>
<li>https://github.com/tobinjones/jupyterlab_formatblack</li>
<li>https://github.com/betatim/joli</li>
</ul>
<p>However, they were all missing features, were out of date, and had issues.</p>
<p>Writing my own version would have been 2 short files, however, I found that <a href="https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/code_prettify/README_code_prettify.html">code_prettify</a> is so extensible that you can easily configure it to use Black using the nbextensions configurable parameters.</p>
<h3 id="features-and-issues-solved">Features (and issues solved)</h3>
<ul>
<li>skip jupyter magic lines
<ul>
<li>https://github.com/csurfer/blackcellmagic/issues/5</li>
<li>https://github.com/drillan/jupyter-black/issues/5</li>
</ul>
</li>
<li>configurable shortcuts</li>
<li>adds a toolbar button</li>
<li>runs for all selected cells
<ul>
<li>https://github.com/drillan/jupyter-black/issues/2</li>
</ul>
</li>
<li>can format whole notebook</li>
<li>don’t have to run the cells</li>
<li>don’t have to load ext each notebook</li>
<li>don’t have to add notebook magics to each cell</li>
<li>allowing for the cells to be edited while running</li>
<li>deal with Black’s changing API and works with the most recent Black version, as well as previous ones
<ul>
<li>https://github.com/csurfer/blackcellmagic/issues/9</li>
<li>https://github.com/drillan/jupyter-black/issues/4</li>
<li>https://github.com/dnanhkhoa/nb_black/issues/2</li>
</ul>
</li>
<li>works with the most recent jupyter version
<ul>
<li>https://github.com/drillan/jupyter-black/issues/6</li>
</ul>
</li>
</ul>
<p>The python code I’ve written to do the black formatting is:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">black_reformat</span><span class="p">(</span><span class="n">cell_text</span><span class="p">):</span>
<span class="kn">import</span> <span class="nn">black</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="n">cell_text</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">"^</span><span class="si">%</span><span class="s">"</span><span class="p">,</span> <span class="s">"#</span><span class="si">%#</span><span class="s">"</span><span class="p">,</span> <span class="n">cell_text</span><span class="p">,</span> <span class="n">flags</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">M</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">reformated_text</span> <span class="o">=</span> <span class="n">black</span><span class="o">.</span><span class="n">format_str</span><span class="p">(</span><span class="n">cell_text</span><span class="p">,</span> <span class="mi">88</span><span class="p">)</span>
<span class="k">except</span> <span class="nb">TypeError</span><span class="p">:</span>
<span class="n">reformated_text</span> <span class="o">=</span> <span class="n">black</span><span class="o">.</span><span class="n">format_str</span><span class="p">(</span>
<span class="n">cell_text</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="n">black</span><span class="o">.</span><span class="n">FileMode</span><span class="p">(</span><span class="n">line_length</span><span class="o">=</span><span class="mi">88</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">"^#</span><span class="si">%#</span><span class="s">"</span><span class="p">,</span> <span class="s">"</span><span class="si">%</span><span class="s">"</span><span class="p">,</span> <span class="n">reformated_text</span><span class="p">,</span> <span class="n">flags</span><span class="o">=</span><span class="n">re</span><span class="o">.</span><span class="n">M</span><span class="p">)</span>
</code></pre></div></div>
<p>but code_prettify takes a json configuration file that runs javascript so here’s the json you need to paste into the configuration window:
<script src="https://gist.github.com/MarvinT/a072aa992e977496974aaf492287b08c.js"></script></p>
<h3 id="to-install">To install</h3>
<ol>
<li>go to your Nbextensions in your jupyter notebook
<ul>
<li>to install nbextensions see https://github.com/ipython-contrib/jupyter_contrib_nbextensions#1-install-the-python-package</li>
</ul>
</li>
<li>enable Code prettify</li>
<li>paste above json into text box labeled <code class="highlighter-rouge">json defining library calls required to load the kernel-specific prettifying modules, and the prefix & postfix for the json-format string required to make the prettifying call.</code></li>
</ol>
<p>This also requires black to be installed in the running kernel and it therefore goes without saying this only works in py>=3.6</p>Marvin ThielkI was looking to auto format my notebooks with BlackFirst attempt at new year resolutions2018-01-29T00:00:00+00:002018-01-29T00:00:00+00:00http://www.neuralcoder.science/New-Years-Resolutions<p>Hey everyone, welcome to my site which will serve to document my goals, projects, thoughts and whatever else might happen to need to get documented.</p>
<p>I’ve never really done new years resolutions before and decided on a whim (after watching some cool Youtube video about how people automate their daily routines) that I should start making some changes… by which I mean track what I do and figure out my stats (and eventually set goals for myself).</p>
<p>This first post is to document what I plan to work on and what the goals for 2018Q1 are.</p>
<p>I’ll be cleaning this up (in the <a href="https://github.com/MarvinT/MarvinT.github.io">code</a> as I learn Jekyll, markdown, liquid, yaml, HTML, and whatever else) and updating this page as I make progress.</p>
<table>
<thead>
<th>Goal</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td><a href="#get-healthy">Get Healthy</a></td>
<td> Diet, sleep hygiene, supplements, nootropics, doctor visits </td>
</tr>
<tr>
<td><a href="#get-scheduled">Get Scheduled</a></td>
<td> Strict scheduling of time, regular sleep and work hours </td>
</tr>
<tr>
<td><a href="#get-rich">Get Rich</a></td>
<td> Machine learning augmented crypto, track expenses, stock market triggers </td>
</tr>
<tr>
<td><a href="#get-fit">Get Fit</a></td>
<td> Strength, BMI, Endurance </td>
</tr>
<tr>
<td><a href="#get-focused">Get Focused</a></td>
<td> Improve focus by meditation </td>
</tr>
<tr>
<td><a href="#get-deeper">Get Deeper</a></td>
<td> Practice more deep/machine learning </td>
</tr>
<tr>
<td><a href="#get-organized">Get Organized</a></td>
<td> Goals, planning, realistic constraints, completion, time management </td>
</tr>
<tr>
<td><a href="#get-handsome">Get Handsome</a></td>
<td> Hair, Hygiene, Style </td>
</tr>
<tr>
<td><a href="#get-responsive">Get Responsive</a></td>
<td> How quickly I respond to phone calls, texts, and PMs </td>
</tr>
<tr>
<td><a href="#get-internet-famous">Get Internet Famous</a></td>
<td> Get internet clout via twitter and blogging </td>
</tr>
<tr>
<td><a href="#get-creative">Get Creative</a></td>
<td> Perform classical artistic creation </td>
</tr>
<tr>
<td><a href="#get-politically-active">Get Politically Active</a></td>
<td> Create tools or analysis to aid in activism I’m interested in </td>
</tr>
</tbody>
</table>
<h2 id="get-healthy">Get Healthy</h2>
<p>Description: Diet, sleep hygiene, supplements, nootropics, doctor visits</p>
<p>Trackable metrics: TBD</p>
<p>Approaches: Diet, Nootropics</p>
<p>Q1 explicit goals: Research metrics and methods. Have at least one metric, one manipulation, an estimate of the time course of effect. Determine 2018 goals.</p>
<p>2018 goals: TBD</p>
<p>
</p>
<h2 id="get-scheduled">Get Scheduled</h2>
<p>Description: Strict scheduling of time, regular sleep and work hours</p>
<p>Trackable metrics: total unscheduled time for last day, week, month, time allocation to each calendar for last day week month</p>
<p>Approaches: Schedule all time on google calendar.</p>
<p>Q1 explicit goals: reach 0 untracked minutes for a month</p>
<p>2018 goals: reach 0 untracked minutes for 6 months</p>
<p>
</p>
<h3 id="how-my-time-gets-spent">How my time gets spent!</h3>
<figure class="">
<img src="https://www.dropbox.com/s/zkqnoll9lee6vga/time_distribution.png?raw=1" alt="How my time gets spent!" />
<figcaption>
Distributions of 24 hour rolling average of how I spent my time. Each column is time spent in a different Google calendar. The distribution is plotted as a letter value (LV) plot, which is a non-parametric estimate of the distribution of a the data, similar to a boxplot. The dot is the time use in the last 24 hours. The X is the immediate preceding 24 hours.
</figcaption></figure>
<p>
</p>
<h2 id="get-rich">Get Rich</h2>
<p>Description: Machine learning augmented crypto, track expenses, stock market triggers</p>
<p>Trackable metrics: Net worth, expenses</p>
<p>Approaches: gather features, data, build model, predict future price and certainty variance of crypto</p>
<p>Q1 explicit goals: Identify features, and start gathering data, track metrics</p>
<p>2018 goals: increase net worth by some explicit amount</p>
<p>
</p>
<h2 id="get-fit">Get Fit</h2>
<p>Description: Strength, BMI, Endurance</p>
<p>Trackable metrics: Body Composition, HRV, machine resistances</p>
<p>Approaches: regular gym time, bike to work, more BJJ, go to gym</p>
<p>Q1 explicit goals: Get bike fixed. Track metrics. Determine 2018 goals</p>
<p>2018 goals: TBD</p>
<p>
</p>
<h2 id="get-focused">Get Focused</h2>
<p>Description: Improve focus by meditation</p>
<p>Trackable metrics: Total time meditated in past day, week, month. Meditation streak.</p>
<p>Approaches: Meditate every day before bed</p>
<p>Q1 explicit goals: meditate on 75 days</p>
<p>2018 goals: meditate on 340 days</p>
<p>
</p>
<h3 id="mindfulness-meditation-log">Mindfulness Meditation Log</h3>
<figure class="">
<img src="https://www.dropbox.com/s/l6mi74tk8p9rfkj/meditation_log.png?raw=1" alt="Mindfulness Meditation Log" />
<figcaption>
Representation of my meditation. Each square represents a day. Saturation is how much time I meditated on that day.
</figcaption></figure>
<p>
</p>
<h2 id="get-deeper">Get Deeper</h2>
<p>Description: Practice more deep/machine learning</p>
<p>Trackable metrics: Hours spent programming deep learning.</p>
<p>Approaches: Do more deep learning</p>
<p>Q1 explicit goals: Learn Deeply for 50 hours</p>
<p>2018 goals: Learn Deeply for (TBD) 200 hours</p>
<p>
</p>
<h2 id="get-organized">Get Organized</h2>
<p>Description: Goals, planning, realistic constraints, completion, time management</p>
<p>Trackable metrics: Time spent organizing, inbox zero</p>
<p>Approaches: Spend time getting organized</p>
<p>Q1 explicit goals: reach inbox zero (important messages)</p>
<p>2018 goals: TBD</p>
<p>
</p>
<h2 id="get-handsome">Get Handsome</h2>
<p>Description: Hair, Hygiene, Style</p>
<p>Trackable metrics: /r/malefashionadvice wayw ratings?, Alex rating?</p>
<p>Approaches: More regular haircuts, more regular shaving, research and improve fashion/wardrobe</p>
<p>Q1 explicit goals: Shave once a week, spend 4 hours researching /r/malefashionadvice</p>
<p>2018 goals: TBD</p>
<p>
</p>
<h2 id="get-responsive">Get Responsive</h2>
<p>Description: How quickly I respond to phone calls, texts, and PMs</p>
<p>Trackable metrics: Mean response time, mean log response time</p>
<p>Approaches: Respond more quickly</p>
<p>Q1 explicit goals: statistically significant reduction in mean log response time over TBD window</p>
<p>2018 goals: continuous reduction in mean log response time over TBD window</p>
<p>
</p>
<h2 id="get-internet-famous">Get Internet Famous</h2>
<p>Description: Get internet clout via twitter and blogging</p>
<p>Trackable metrics: Twitter Followers, number of tweets, website views</p>
<p>Approaches: get website (this website), acquire twitter handle (hey Twitter, are you reading this), start engaging</p>
<p>Q1 explicit goals: get website, acquire twitter handle</p>
<p>2018 goals: Reach Brad’s following?</p>
<p>
</p>
<h2 id="get-creative">Get Creative</h2>
<p>Description: Perform classical artistic creation</p>
<p>Trackable metrics: hours spent arting</p>
<p>Approaches: art more</p>
<p>Q1 explicit goals: 8 hours arting</p>
<p>2018 goals: 40 hours arting</p>
<p>
</p>
<h2 id="get-politically-active">Get Politically Active</h2>
<p>Description: Create tools or analysis to aid in activism I’m interested in</p>
<p>Trackable metrics: Tool uses</p>
<p>Approaches: Identify area for analysis, do analysis, make it available</p>
<p>Q1 explicit goals: Identify project</p>
<p>2018 goals: have project available</p>
<p>
</p>Marvin ThielkHey everyone, welcome to my site which will serve to document my goals, projects, thoughts and whatever else might happen to need to get documented.