RSSAmplifier

Blog

Moxley Stratton

moxleystratton.comRSS feed ↗17 posts

Latest posts

When To Use Elixir’s String.to_atom/1

TL;DR: Use String.to_atom/1 at compile time only. In the Erlang VM, atoms are not garbage-collected. Because of that, unchecked creation of atoms can lead to memory leaks at best, and a crashed VM at worse. This has been widely discussed on the internet. Both String.to_atom/1 and the :"string" expression generate arbitrary atoms from strings. Using these two techniques for converting a string to…

Visualizing Neuron Weights During Training

I have a deep interest in knowing exactly how a neural network works. Not only do I want to know the theory, I want to know– in practice– what’s happening to the neuron’s weights as the network is being trained. With TensorFlow, it took a lot of work and investigation to finally get to a point where I had something that visualized weights being trained. It seemed that…

TensorFlow on MacOS

I was very excited to start running TensorFlow Python programs on my Mac. I installed it using PIP, using the instructions provided by TensorFlow.org . On running my first TensorFlow program, the first thing it output was: 2018-11-25 19:13:07.524017: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1…

Atom Editor Setup for Elixir

When working with Elixir, I want the following support from my editor: Elixir syntax highlighting Compiler errors and warnings displayed while I’m editing Elixir code Automatic Elixir code formatting Automatic Dialyzer checking and reporting when I save an Elixir code file These are the following plugins that provide those features: language-elixir ide-elixir atom-elixir-formatter…

Elixir Abstract Syntax

As developers know, program source code is represented as lines of text. The Abstract Syntax Tree (AST) is the representation of the source code as a hierarchical data graph, specifically a tree structure. With an AST, much of the difficult work parsing the original source code has been performed, and the syntax can be introspected programatically. Similar to an AST, the Abstract Semantic Graph…

Install Redis on macOS with Homebrew

Install brew update brew install redis Upgrade If Redis is already installed, you might want to upgrade: brew upgrade redis Verify Check to see if Redis is already running: redis-cli If it’s already running, you can probably stop here. Launch on System Boot Check to see if it is already set up to launch on boot: ls -l ~/Library/LaunchAgents | grep -i redis Make it launch on boot: ln -sfv…

Install Elixir on macOS Using ASDF

Install asdf git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.3.0 echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile . ~/.bash_profile Install Erlang and Elixir Plugins asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git Uninstall…

Low-Level ActiveRecord

With many Rails projects, there is occasionally a need to bypass the normal ActiveRecord API, and get closer to the low-level SQL API. Here are a few useful methods that bypass the confines of everyday ActiveRecord. #find_by_sql users = User.find_by_sql("SELECT * FROM users WHERE id = 1") This returns model instances for the given SQL string. #find_by_sql also accepts parametrized values, like…

Finding the source for a given Rails web page

These tips may help those of you who are relatively new to Rails, or maybe even if you’re not. Common tips and tricks Look at the URL path (e.g. /users/100685/edit ). Can the action and main view file be determined from CRUD/REST conventions? /:model/edit -> edit.html.slim /:model/1234 -> show.html.slim /:model/new -> new.html.slim /:model -> index.html.slim Look up the path in routes.rb, or…

Considering a switch to the Atom Text Editor?

You’ve probably heard of Atom, Github’s new text editor . Read these checklists to help you decide whether it’s an editor worth switching to. General Pros Open Source High-quality extension and enhancement infrastructure View is programmable using good old HTML DOM and CSS Well-known API model (NodeJS) Built-in Github integration Built-in, light Git integration Realtime Markdown…

Simple Cellular Automata

I released a very simple cellular automata explorer. Try it out here . See the Github page for more information.

Ten Secret Key Bindings from OS X

Did you know that when using these applications: Any application on OS X, except Vim and MS products Bash, or any console program with Readline support These key bindings are available: Control-A - Move to beginning of line Control-E - Move to end of line Control-F - Move forward one column Control-B - Move backward one column Control-N - Move to next line Control-P - Move to previous line…

Injection

Within the world of application development, there is a conspiracy. $sql = "SELECT * FROM users WHERE username='" . $username . "'"; What’s wrong with this code? The problem is that $username needs to be escaped before it can be put into the SQL statement. If $username contains single quotes, the SQL statement will do something you did not intend. If you already know this, stick around,…

Clojure Tutorial for the Non-Lisp Programmer

I intend to keep this tutorial as accurate and up-to-date as possible. If you have any suggestions for changes, please leave a comment at the bottom of this page. Clojure is a functional lisp dialect that uses the Java Virtual Runtime as its platform. The language home page is at http://clojure.org/ . Table of Contents A Quick Comparison Installing Clojure Atoms Vectors Lists Maps and Sets…

Ruby: Escape, Unescape, Encode, Decode, HTML, XML, URI, URL

This example shows you how to escape and un-escape a value to be included in a URI and within HTML. require 'cgi' # Escape data for URL query parameters name = "ruby?" value = "yes" url = "http://example.com/?" + CGI.escape(name) + '=' + CGI.escape(value) + "&var=T" # url: http://example.com/?ruby%3F=yes&var=T # Escape data for HTML url = "http://example.com/?ruby%3F=yes&var=T" html = %(<a…

Bookmarklet Compiler

What are bookmarklets? They&rsquo;re small Javascripts, saved as browser bookmarks, that perform useful functions. Here&rsquo;s my favorite bookmarklet site . It includes the bookmarklet that helped me develop my first Ajax applications: Javascript Shell . How do you make a bookmarklet? Write the javascript that you want to be the bookmarklet. Escape all the special URL characters, like space,…

Search articles

Search for something: