<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Programming on CyberSpy</title>
    <link>https://cyberspy.io/tags/programming/</link>
    <description>Recent content in Programming on CyberSpy</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Wed, 23 Jan 2019 22:11:25 -0500</lastBuildDate>
    <atom:link href="https://cyberspy.io/tags/programming/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Program the Esp32 with ESP-IDF on Mac OS X</title>
      <link>https://cyberspy.io/articles/esp32-on-osx/</link>
      <pubDate>Wed, 23 Jan 2019 22:11:25 -0500</pubDate>
      <guid>https://cyberspy.io/articles/esp32-on-osx/</guid>
      <description>&lt;h2 id=&#34;programming-the-esp32-on-your-mac&#34;&gt;Programming the ESP32 on your Mac!&lt;/h2&gt;&#xA;&lt;p&gt;Go out and buy yourself a cheap little &lt;a href=&#34;https://www.espressif.com/en&#34;&gt;ESP32 SoC&lt;/a&gt; and follow these basic instructions to setup your development environment on your Mac. If you want to do some advanced C-programming to control your ESP32, this is for you. If you&amp;rsquo;d rather use &lt;a href=&#34;https://www.arduino.cc&#34;&gt;Arduino&lt;/a&gt; and play with simple sketches then this is not for you &amp;ndash; google how to use Arduino and off you go!&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-you-will-need&#34;&gt;What you will need&lt;/h2&gt;&#xA;&lt;p&gt;So, of course you&amp;rsquo;ll need an ESP32 SoC development board. I recommend the &lt;a href=&#34;https://www.sparkfun.com/products/13907&#34;&gt;SparkFun Thing&lt;/a&gt;. Lots of other choices, but this blog post will address some of the specific configuration considerations that you&amp;rsquo;ll need to be aware of when you select this particular device.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Julia Intro</title>
      <link>https://cyberspy.io/articles/julia-intro/</link>
      <pubDate>Wed, 07 Nov 2018 15:11:45 -0500</pubDate>
      <guid>https://cyberspy.io/articles/julia-intro/</guid>
      <description>&lt;h1 id=&#34;juliaet-wherefore-art-thou&#34;&gt;Julia&lt;del&gt;et&lt;/del&gt;, Wherefore art thou?&lt;/h1&gt;&#xA;&lt;p&gt;As Yoda once said&amp;hellip;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt; YAPL - yet another programming language. Learn something new, you must.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h3 id=&#34;why-learn-julia&#34;&gt;Why Learn Julia?&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://julialang.org&#34;&gt;Julia&lt;/a&gt; was designed from the beginning for high performance. Julia programs compile to efficient native code for multiple platforms via &lt;a href=&#34;https://llvm.org&#34;&gt;LLVM&lt;/a&gt;. As such, it&amp;rsquo;s an interesting programming language to take a look at as it&amp;rsquo;s a serious contender for certain classes of programming problems; most notibly, scientific and data-centric analysis.&lt;/p&gt;</description>
    </item>
    <item>
      <title>OCaml OpenGL - Get into Gear!</title>
      <link>https://cyberspy.io/articles/ocamlopengl/</link>
      <pubDate>Tue, 13 Mar 2018 14:41:15 -0400</pubDate>
      <guid>https://cyberspy.io/articles/ocamlopengl/</guid>
      <description>&lt;h2 id=&#34;ocaml-and-opengl---getting-our-functional-programming-into-gear&#34;&gt;OCaml and OpenGL - Getting our Functional Programming into Gear!&lt;/h2&gt;&#xA;&lt;p&gt;In my blog post for this day, I thought I&amp;rsquo;d take a look at the OCaml OpenGL library, &lt;a href=&#34;https://opam.ocaml.org/packages/lablgl/lablgl.1.05/&#34;&gt;lablgl&lt;/a&gt;. If you&amp;rsquo;re not already familair with openGL, I strongly suggest that you take a look at one of the tutorials available online. One that I found to be very informative; although written in &lt;strong&gt;c++&lt;/strong&gt;, is &lt;a href=&#34;http://www.opengl-tutorial.org&#34;&gt;opengl-tutorial&lt;/a&gt;. Nonetheless, in this post, we&amp;rsquo;ll look at some simple, and not so simple examples written in OCaml. But before we can do that, we need to install the requisite &lt;strong&gt;opam&lt;/strong&gt; dependencies. To install &lt;code&gt;lablgl&lt;/code&gt;, simply:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Let&#39;s Get Funky with the Camel</title>
      <link>https://cyberspy.io/articles/ocaml-func/</link>
      <pubDate>Fri, 09 Feb 2018 16:17:20 -0500</pubDate>
      <guid>https://cyberspy.io/articles/ocaml-func/</guid>
      <description>&lt;h2 id=&#34;how-many-ways-can-we-get-funky&#34;&gt;How many ways can we get Fun(ky)&lt;/h2&gt;&#xA;&lt;p&gt;In any programming paradigm, it&amp;rsquo;s critical to understand how we write functions - be they traditional imperative , anonymous , recursive, or functional. In this post, I will break down the different types of functions that you can write in &lt;strong&gt;OCaml&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start by examining the imperative function. Here&amp;rsquo;s a simple function that prints out the phrase &lt;em&gt;Hello World!&lt;/em&gt; $n$ times, once on each line, and returns the value $n$ as its result.&lt;/p&gt;</description>
    </item>
    <item>
      <title>OCaml Hello World and more</title>
      <link>https://cyberspy.io/articles/ocaml-hw/</link>
      <pubDate>Tue, 06 Feb 2018 11:28:00 -0500</pubDate>
      <guid>https://cyberspy.io/articles/ocaml-hw/</guid>
      <description>&lt;h3 id=&#34;well-hello-there&#34;&gt;Well Hello There!&lt;/h3&gt;&#xA;&lt;p&gt;As tradition has it, every new programming language experience must begin with the basic &lt;em&gt;Hello World&lt;/em&gt;. Let&amp;rsquo;s walk the the basics of how to set up our development environment specifically for OCaml and demonstrate how to compile our basic program.&lt;/p&gt;&#xA;&lt;h3 id=&#34;warming-up-our-environment&#34;&gt;Warming up our Environment&lt;/h3&gt;&#xA;&lt;p&gt;Of course we could just use our vanilla editor to enter our OCaml programs, but a more efficient work environment leverages an extensible editor that is &lt;em&gt;aware&lt;/em&gt; of our programming language. Editors like &lt;a href=&#34;*&#34;&gt;sublime&lt;/a&gt;, &lt;a href=&#34;*&#34;&gt;Atom&lt;/a&gt;, and &lt;a href=&#34;*&#34;&gt;Visual Studio Code&lt;/a&gt; are some of the more popular selections. &lt;a href=&#34;*&#34;&gt;Vim&lt;/a&gt; and &lt;a href=&#34;*&#34;&gt;Emacs&lt;/a&gt; are also options, but the new tools tend to support vi/emacs style editing while offering more extensive and expansive features.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Recursion Revisited</title>
      <link>https://cyberspy.io/code/recursion/</link>
      <pubDate>Tue, 28 Nov 2017 15:23:02 -0500</pubDate>
      <guid>https://cyberspy.io/code/recursion/</guid>
      <description>&lt;h3 id=&#34;recursion-from-more-than-one-point-of-view&#34;&gt;Recursion, from more than one point-of-view.&lt;/h3&gt;&#xA;&lt;p&gt;A common programming idiom in computer science is solving a problem by self-reference, also known as recursion. In this post, we look at two different&#xA;implementations of the same problem.&lt;/p&gt;&#xA;&lt;h4 id=&#34;solve-a-recursive-problem-in-two-different-programming-language-paradigms&#34;&gt;Solve a recursive problem in two different programming language paradigms&lt;/h4&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s look at the solution to a simple problem, compute $f(x)=e^{x}$.&lt;/p&gt;&#xA;&lt;p&gt;We will illustrate two separate solutions - one in a procedural language (python), and the other in a functional language (elixir).&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start off with the functional language. Were does recursion come into play?&lt;/p&gt;&#xA;&lt;p&gt;We define the function $f(x)=e^x$ as the infinite sum,  $\text{ }f(x) = \sum_{n=0}^\infty{\frac{x^n}{n!}}$&lt;/p&gt;&#xA;&lt;p&gt;In our solution below, we define two separate recursive functions, &lt;code&gt;exp/2&lt;/code&gt; and &lt;code&gt;fac/1&lt;/code&gt;. What&amp;rsquo;s interesting to note here is how each of these functions has two separate definitions. This is an aspect of programming in elixir that elegantly uses pattern-matching to return different results depending upon the input. Our two functions nicely dovetail into the base-case and recursive case of a recursive algorithm.&lt;/p&gt;&#xA;&lt;p&gt;For example, looking at &lt;code&gt;exp/2&lt;/code&gt;, the first function definition returns 1 for any value of x (as indicated by the &lt;code&gt;_&lt;/code&gt; preceding the variable) and returns 1. This is the mathematical equivalent of $x^0=1\text{ for any }x$.&lt;/p&gt;&#xA;&lt;p&gt;The second definition of &lt;code&gt;exp/2&lt;/code&gt; is the recursive case. for any value of $n\gt0$. Moreover, we define &lt;code&gt;exp(x, n)&lt;/code&gt; as $\frac{e^x}{n!}$ + &lt;code&gt;exp(x, n-1)&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Similarly for the definition of &lt;code&gt;fac/1&lt;/code&gt; we see two definitions; one for $n=0$ and another for all values of $n\gt0$.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Visualizing the News: Grab your PILlow</title>
      <link>https://cyberspy.io/articles/2017-11-12t213223-0500--visualizing-the-news-grab-your-pillow/</link>
      <pubDate>Sun, 12 Nov 2017 21:32:23 -0500</pubDate>
      <guid>https://cyberspy.io/articles/2017-11-12t213223-0500--visualizing-the-news-grab-your-pillow/</guid>
      <description>&lt;h3 id=&#34;a-pictures-worth-a-gazillion-bits&#34;&gt;A Picture&amp;rsquo;s Worth a Gazillion Bits&lt;/h3&gt;&#xA;&lt;h2 id=&#34;newsapi&#34;&gt;newsapi&lt;/h2&gt;&#xA;&lt;p&gt;This weekend, I tripped over a neat news REST-ful api called &lt;a href=&#34;https://newsapi.org&#34;&gt;newsapi&lt;/a&gt;. Grab an API key and you&amp;rsquo;re off to the&#xA;races.&lt;/p&gt;&#xA;&lt;p&gt;There are tons of live headlines - &lt;strong&gt;News API can provide headlines from 70 worldwide sources.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;There are basically two api endpoints:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GET &lt;a href=&#34;https://newsapi.org/v1/articles&#34;&gt;https://newsapi.org/v1/articles&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;GET &lt;a href=&#34;https://newsapi.org/v1/sources&#34;&gt;https://newsapi.org/v1/sources&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Register for an &lt;a href=&#34;https://newsapi.org/register&#34;&gt;account&lt;/a&gt; and generate an api-key and let&amp;rsquo;s get started.&lt;/p&gt;&#xA;&lt;h2 id=&#34;accessing-the-api-with-python&#34;&gt;Accessing the API with Python&lt;/h2&gt;&#xA;&lt;p&gt;&lt;strong&gt;newsapi&lt;/strong&gt; can easily be accessed using a browser since the REST-ful method used is a &lt;strong&gt;GET&lt;/strong&gt; method. But, accessing the api&#xA;from the browser is limiting.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Making Heads or Tails out of Recursion and Combinatorial Math</title>
      <link>https://cyberspy.io/articles/2017-11-09t212705-0500--tail-recursion-and-combinatorial-math/</link>
      <pubDate>Thu, 09 Nov 2017 21:27:05 -0500</pubDate>
      <guid>https://cyberspy.io/articles/2017-11-09t212705-0500--tail-recursion-and-combinatorial-math/</guid>
      <description>&lt;h3 id=&#34;gnu--gnu&#34;&gt;GNU — &lt;a href=&#34;https://en.wikipedia.org/wiki/Recursive_acronym&#34;&gt;GNU&amp;rsquo;s Not Unix&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;I thought I&amp;rsquo;d take a look at two topics at once and make some fun by mashing them together. Today&amp;rsquo;s topic&#xA;is &lt;a href=&#34;https://en.wikipedia.org/wiki/Recursion&#34;&gt;&lt;strong&gt;recursion&lt;/strong&gt;&lt;/a&gt;. In computer science (and in math, although we call the equation a&#xA;&lt;a href=&#34;https://en.wikipedia.org/wiki/Recurrence_relation&#34;&gt;recurrence relation&lt;/a&gt;) recursion is an often misunderstood concept causing lots of&#xA;panic and anxiety. In reality - it&amp;rsquo;s pretty easy once you wrap you head around the idiom.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-recursion&#34;&gt;What is recursion?&lt;/h2&gt;&#xA;&lt;p&gt;When we define a function in such a way that it calls itself, we&amp;rsquo;ve defined a recusive function. The most basic example is the&#xA;&lt;a href=&#34;https://en.wikipedia.org/wiki/Factorial&#34;&gt;Factorial&lt;/a&gt; function, $f(n)=n!$. We define the function &lt;em&gt;recursively&lt;/em&gt; by defining it&#xA;in reference to itself. So, recursively, we define $f(n)$ as:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Getting Visual With It</title>
      <link>https://cyberspy.io/articles/2017-11-08t102620-0500--getting-visual-with-it/</link>
      <pubDate>Wed, 08 Nov 2017 10:26:20 -0500</pubDate>
      <guid>https://cyberspy.io/articles/2017-11-08t102620-0500--getting-visual-with-it/</guid>
      <description>&lt;h3 id=&#34;time-to-get-vizzy-with-it&#34;&gt;Time to Get Vizzy With It!&lt;/h3&gt;&#xA;&lt;p&gt;Like Will says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Gettin vizzy wit it&#xA;Na na na na na na na nana&#xA;Na na na na nana&#xA;Gettin vizzy wit it…&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;plot-thickens&#34;&gt;Plot thickens&lt;/h3&gt;&#xA;&lt;p&gt;Time to turn on the lights and see what our data objects look like when we turn them&#xA;into visualized plots. Sure, we can use the &lt;code&gt;print&lt;/code&gt; function to see the &lt;em&gt;numbers&lt;/em&gt; within&#xA;our &lt;strong&gt;numpy&lt;/strong&gt; objects. Better yet, let&amp;rsquo;s turn our objects into pretty graphical images. To do so, we turn to&#xA;the &lt;a href=&#34;http://matplotlib.org/contents.html&#34;&gt;&lt;code&gt;matplotlib&lt;/code&gt;&lt;/a&gt; library. An extensive library of plotting routines that easily allows us to render&#xA;image plots into many different formats (png, jpg, pdf, etc&amp;hellip;) - both onto the screen for quick visual inspection, or written&#xA;to a file for general use.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Do the Numpy</title>
      <link>https://cyberspy.io/articles/2017-11-07t153643-0500--do-the-numpy/</link>
      <pubDate>Tue, 07 Nov 2017 15:36:43 -0500</pubDate>
      <guid>https://cyberspy.io/articles/2017-11-07t153643-0500--do-the-numpy/</guid>
      <description>&lt;h3 id=&#34;do-the-numpy-dance-is-your-chance-to-do-the-nump&#34;&gt;Do the Numpy Dance, Is your Chance to do the Nump!&lt;/h3&gt;&#xA;&lt;p&gt;Sir Numpy says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The Numpy Dance is your chance to do the nump&#xA;Do the Numpy Nump, come on and do the Numpty Nump&#xA;Do the Numpy Nump, just watch me do the Numpty Nump&#xA;Do ya know what I&amp;rsquo;m doin&amp;rsquo;, doin&amp;rsquo; the Numpty Nump&#xA;Do the Numpy Nump, do the Numpty Nump&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h3 id=&#34;start-at-the-beginning-numpy&#34;&gt;Start at the beginning: &lt;a href=&#34;http://www.numpy.org&#34;&gt;&lt;em&gt;&lt;code&gt;NumPy&lt;/code&gt;&lt;/em&gt;&lt;/a&gt;&lt;/h3&gt;&#xA;&lt;p&gt;The first library that we will investigate is &lt;code&gt;numpy&lt;/code&gt;. Simply put, &lt;code&gt;numpy&lt;/code&gt; allows us to represent&#xA;mathematical objects like arrays and matricies of different datatypes and performs operations on those objects thereby&#xA;easing the burden of writing the tedious code within your applications to do the mundane representations and operations.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Basic Math Concepts made Complicated Quickly</title>
      <link>https://cyberspy.io/articles/2017-10-15t171012-0400--basic-math-concepts-made-complicated/</link>
      <pubDate>Sun, 15 Oct 2017 17:10:12 -0400</pubDate>
      <guid>https://cyberspy.io/articles/2017-10-15t171012-0400--basic-math-concepts-made-complicated/</guid>
      <description>&lt;h1 id=&#34;fibonacci---whats-in-a-name&#34;&gt;Fibonacci - What&amp;rsquo;s in a Name&amp;hellip;&lt;/h1&gt;&#xA;&lt;h3 id=&#34;the-man-the-myth&#34;&gt;The man, the myth&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Fibonacci&#34;&gt;Leonardo Fibonacci&lt;/a&gt; was a mathematician who&#xA;lived in the middle ages and was held in high esteem for his prowess as a talented&#xA;mathematician. Best known for his &lt;a href=&#34;https://en.wikipedia.org/wiki/Fibonacci_number&#34;&gt;Fibonacci Sequence&lt;/a&gt; which&#xA;seemingly is simple to define, yet it&amp;rsquo;s limit point (of the ratio of the last two elements of the sequence)&#xA;(also known as the Greek letter Phi). The mysticism around the Golden ratio abounds due to its correlation with many&#xA;natural element - both living things as well as dynamic processes.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
