One time, I was looking at a graph, and the thought occurred to me, "this graph shows where the two sides of this equation are exactly equal, but what if a graph showed also where they were almost the same?", so I wrote a little graphing web app: https://truthygraph.github.io/.
I decided to try my hand at musical composition. This is my first piece. I call it "We Spin Together".
Recently, I was curious if I could generate a digital radio signal from scratch just using math, and use that signal to control this radio-controlled outlet that I have.
This is a binary signal coded with On-off keying (also known as Amplitude-shift keying).
I'm taking the long pulses to mean "1" and the short pulses to mean "0", so this signal is transmitting the digital code, "0110100010000000".
I've recently been getting into Software-defined Radio (SDR), mostly using a HackRF - a radio tranceiver capable of operating from 1MHz to 6GHz (which is a huge range).
You can capture radio signals with Software-defined Radios (SDR), such as the HackRF. Gnu Radio is the main software I use for receiving and transmitting radio signals, but I've found Audacity, a program meant primarily for editing sound files, to be a great program for viewing and editing radio signals.
This got GNU Radio and GNU Radio Companion installed, but then I needed to install the Osmocom Gnu Radio Blocks so that Gnu Radio could communicate with the HackRF.
I wrote the controller software in Python (with ZeroMQ, Flask, Rpi.GPIO, and jQuery Mobile): https://github.com/calebmadrigal/rpi-home-automation.
DNS Tunneling can be useful for getting out of a very restrictive corporate firewall (since almost nobody blocks DNS).
DNS Tunneling works by encoding IP protocol inside of DNS packets. Iodine is a cross-platform implementation of DNS Tunneling. This mini-guide will walk through the process of setting up a DNS Tunnel with Iodine.
Just another painting. I did this one earlier this year.
I recently decided to brush up on my algorithms and data structures by writing them in Python. Though these are not optimized, they could be helpful for reference. Here is the Github repo: https://github.com/calebmadrigal/algorithms-in-python.
Recursion is awesome, but has the downside of growing the stack, which can limit its usefulness. Some languages like Scheme, however, have Tail-call optimization, which lets programmers write Tail-recursive functions that don't grow the call stack. Python does not have Tail-call optimization (TCO), but with asyncio, we can have something like Tail-call optimization. Basically, this method uses the asyncio event loop like a trampoline function.
# keep the stack from growing.
I've been playing with d3 recently, and it awesome! I'm especially amazed by the ease of animating transitions with it.
I took this photo of a beautiful "vanilla sky" outside of our home in Milwaukee, WI. It served as my model for the painting (along with other memories of looking at sunsets from beneath the spruce tree).
I recently finished reading Phantastes by George MacDonald for the 2nd time. The first time I read it, I really liked it. This second time, it became one of my all-time favorites. I've never experience any other work of art which feels so much like being in a dream.
This was my first time painting since I was a kid doing watercolors in school. Definitely plan to try it again!
In the process of trying to explain to a friend how sessions work, I decided to write a barebones example to demonstrate how to do sessions in Node.js with Express.js.
// Consider all URLs under /public/ as static files, and return them raw.
Too much detail in art is profanity - a vulgar attempt to sum up that which is beyond finite expression.
When to use an SSH Tunnel?
You want to get to a website that a corporate network is blocking.
You want to encrypt the network traffic for a non-encrypted protocol.
An SSH Tunnel is where you tell your local SSH Client to forward your local computer's traffic to a specified SSH Server (over the encrypted SSH protocol). The SSH Server will then act as a proxy for all requests you make on your local computer.
The best art is more like a laser beam than a flood light - it doesn't hit everyone, but those it hits, it burns.
I recently was car shopping, and I had the question about gas mileage: "How much does, say, the difference between 25 mpg and 30 mpg cost?"
To find how much different fuel efficiencies cost in terms of dollars per year.
I want to estimate this value for the next 10 or so years.
I'm estimating the average price per gallon of gas (over the next 10 years) to be $4.50. It is around $3.60 now, I adjusted for inflation, and counter-adjusted for the time-value of money.
I'm estimating that we will drive about 14,000 miles per year (based on the last 3 years).
Over the last several years, I've been writing down words (or sets of words) which I consider to be particularly beautiful.
Inspiration: I've found that taking in good art makes me want to write.
Note: This isn't so much a poem as a truth put into a rhythmic format. It's a bit too "teachy" to be real poetry, in my opinion. Real poetry should not try to teach directly, but rather, should convey feelings (which may indirectly teach something).
Analogies are to functions as facts are to variables - facts are data which the mind can reference, but analogies change the way the mind works.
Whenever possible, I try to explain things with analogies.
Inspiration: I was in a gray mood today, and when I looked outside and saw the gray skies, I thought, “the weather matches my mood… or does my mood match the weather?” I didn’t feel like staying in this gray mood.
In the waves as they roll.
Inspiration: Music is universal. We enjoy it; we cannot help ourselves. And we want to join with it.
Keep away from the bay!
That is near the seaside.
From the deep ocean skies.
Inspiration: Sometimes, when I need to get work done, I have to stay away from things which will get me into an artistic, or I'll be swept up in it for hours.
He raises arms, and the battle fights.
Removing from the throne my logical side.
Deep oceans are within his gaze.
But only in beauty does he invest.
Careless and wild - this side of mine.
"Behold! the sails are filled with wind!
Onward towards the moon again!"
Inspiration: What it feels like when my right-brain takes control. Often, starry nights and moonlight provoke me.
And to in love, embrace.
Inspiration: Riding on a bus, looking at the beautiful sky, and thinking about meeting God.
And there’s a spiritual side.
Inspiration: Looking at the sunrise in Chicago over the lake, after a night casually dressed and deep in conversation.
Inspiration: An explanation of why living from my heart is so important to me.
No defenses built up, layers over time.
Experiencing fully the beautiful present.
Inspiration: Rafe (my son) - when I look at his eyes, it looks like he is just driniking everything in.
In the last week or so (starting Monday, March 3, 2014) I've been in a very poetic mood. It has been so interesting - it was light a light switch flipping on. I haven't been sitting down and trying to write poetry, they've just been coming to me. Often, as soon as one ends, another begins. It has been so pleasurable. I hope people enjoy them, but even if they don't, it has been so worth it to me!
I've recently tried both Heroku and Node.js for the first time. Both are very simple, and work very nicely together. This is a quick guide to deploying a Node.js app to Heroku. To make it simple, I'll walk through deploying a Node.js sample project I created. It is a very simple message board.
Simple example to show how to draw lines with Matplotlib (in IPython Notebook).
# an x-list and a y-list.
Define a rectangle which encloses the part of the curve for which we want to find area.
Randomly generate points within that region.
I didn't want my blog data stored in a database; I vastly prefer it being stored in version-controlled Markdown format.
I wanted to write blog posts in Markdown (which is possible in Wordpress, but Wordpress isn't designed to use Markdown).
I also get to use vim to write my blog posts now, which is much nicer than the Wordpress editor.
This is a guide to set up IPython Notebook on a Server - specifically, on a DigitalOcean VPS. This will allow you to access your iPython Notebooks from anywhere.
I've been doing a good bit of graphing in IPython Notebook recently, and I often wanted to make the graphs larger. I also often wanted to label the graph axes. So I wrote this simple function and have been using it a lot.
This is an example from the book which I've made some modifications to.
IPython Notebook / Matplotlib / Pylab / Numpy is great for graphing (among other things). Below is a simple demo of how to graph with it.
I'm mostly a Mac user and I also really like Linux (especially Ubuntu), but I hate Windows. However, I'm occasionally required to use Windows at work, so I've found a way to make using Windows more enjoyable: to use Ubuntu (installed on VirtualBox inside of Windows) instead of Windows for everything except for the few tasks which require Windows.
I've continued on my (hopefully) short-term fascination with music+math (it's fun, but really bad for productivity). So I found this great library for generating music in Python called Pyknon. And it can be installed using pip: pip install pyknon.
I wrote a little python script just to help me understand some concepts in music theory like intervals and chords. It is meant to be read top to bottom (which is why I intersperse functions and variables throughout). It is NOT written in good modular form (in general, I don't recommend writing python like this). This code can also be used as an intro to the pyknon library.
On the VIM note, here is a link to my current vim config (.vimrc file and .vim directory) on github: Vim config.
I have found the secret to not getting road rage: audiobooks. Try it. Right now, I'm listening to Dune by Frank Herbert.
I have started my journey into the world of OpenCV using Python on my Mac. These are my first steps with it.
I realized that I utilize the [NSArray head] and [NSArray tail] functions in various code snippets, but haven.t shared the actual code for that category. So here is my NSArray+FPcode.
GNU Octave - An open-source MATLAB clone.
R - An open source clone of a statistical computing environment called S.
Julia - A language for doing statistical analysis. The goals are to compete with Matlab and R.
This seems like a nice, concise book on probability and statistics for Python programmers: Think Stats.
Premature generalization is the new premature optimization.
And it, too, is evil.
""" Takes a set of data points in the form: [(1,1), (2,2), ...] and outputs (slope, y0). """
Today, I had this XML document which I was wanting to make viewable in a browser. My plan was to run the XML document through an XSLT engine to transform it into an HTML document (which could then be opened in a browser).
Instead, I found that I could just embed the XSLT directly in the XML document. Then, when this file is opened in a browser, the XSLT executes and spits out HTML, which is then rendered into the browser window. This is great because I now have the original XML file (which we wanted to keep further analysis purposes) which can also be rendered nicely in a browser.
I've been taking the Udacity CS373 (Robotic Car) class, and this week the topic was Particle filters. Particle filters are basically a localization algorithm that accounts for error in measurements and sensors.
Anyway, part of the Particle Filter algorithm requires the generation of a new set of these things called "particles" based on the particles' weights. So to accomplish this task, the Resample Wheel algorithm was presented in class. It is a particularly elegant method of generating a new set of particles by randomly drawing from an old set of particles (with replacement). The particle weight determines the likelihood of it being picked.
Since I've been getting into functional programming more recently, the fact that Python doesn't do tail-call optimization has been bothering me. So I did a bit of searching, and found this gem: Tail Call Optimization Decorator.
First, I wanted to create a subdomain which would host my django stuff. In order to do this, I created a subdomain using the cPanel (the item is called "Subdomains"). This created the directory and a basic .htaccess file (along with a few error pages).
So now, I can do this!
This also assumes that an image called "invalidFieldCircle.png" is in your project's "Resources" directory, which should be located just below the main project directory (you may have to create it).
Type inference allows you to have static typing but not all the verbosity of most other statically-typed languages.
mvn clean install -U "-Docns.web.dynamic.content.version=2.6.0"