Ever wonder how the square-root button on your calculator works? Nope, it's not the Underpants Gnomes. In this screencast we will demonstrate Newton's method of making a series of guesses, each one getting us closer to our answer. we're gonna need an average function which will take x and y, add them together and divide that by 2. now our newton function will take a guess in addition to our number that we want the square root of. It will divide our number by the guess and average that with the previous guess. Let's try it on 81. Start with an initial guess of 1.0. We get 41.0. So we run it with that. And again, and again, until we start to converge on the answer. As we see, the square root of 81 is 9. So now we can write a function to do that all for us. We'll get the absolute value of a number, by taking its negation and seeing which one's bigger. To check the answer, we square it, or multiply it by itself. We can now write our square root function. It...
Posts
Sleepless in Seattle (literally!)
- Get link
- X
- Other Apps
What is that movie even about, anyway? Not sure if I really care, but the title pretty much describes my experience here so far. Seems like Seattle doesn't want to let me sleep. That's a commodity that's currently too rich for my blood. My first night was spent just sitting. Right on the sidewalk. About as uneventful as you can get. I relaxed as much as possible but couldn't let myself doze off because I was on the job - guarding my mobile office from those grabby types. This time, I'm here on business and only have exactly what I need - no more, no less (though I certainly wish it were less). In the morning, I realized that I had just enough change for a cup of coffee, but accidentally walked into this weird special Starbucks "Reserve" store. They handed me a menu. What? I ordered a large... I mean, Venti, and it was nearly five bucks! Normally I would have bought it and felt extremely stupid. But since I was unable to do so, it was not only sup...
MilkyTracker: The quest for the perfect music software
- Get link
- X
- Other Apps
The last album I made was in 2013 on a MacBook using Logic Pro and Massive, a setup that cost a couple thousand dollars. Since I no longer have that machine and the software was proprietary, I no longer have access to all of that work. This has sparked a great interest in searching for a replacement digital audio suite, one that would provide a comparable workflow but also offer longevity, the ability to archive my work in a format that can be shared across platforms and improved upon. An artist should demand nothing less! What if a painter had to stop working on everything because they didn't want to use canvas from a certain company, and then none of their brushes or paints would work? That's what is actually happening in today's creative landscape, but with software. Whatever program I use must, above all else, use a standard file format for music encoding, which is usually MIDI but there are others. That way none of my work is dependent on any specific piece of ...
Part 2: Software Development Tools
- Get link
- X
- Other Apps
sudo apt-get install python3-pip sudo apt-get install python-pip sudo pip install --upgrade youtube_dl sudo apt-get install dosbox sudo apt-get install oracle-java8-jdk sudo apt-get install gnome-disk-utility sudo apt-get install leafpad sudo apt-get install libreoffice Emacs - do whole video on this. Leiningen - save lein script to /bin/lein, then: sudo chmod a+x /bin/lein lein sudo apt install emacs24 git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d .spacemacs config: (setq-default dotspacemacs-configuration-layers '((clojure :variables clojure-enable-fancify-symbols t))) vim/fireplace (do whole video on this): sudo apt-get install vim git clone https://github.com/ctford/vim-fireplace-easy.git .vim ln -s ~/.vim/vimrc.vim ~/.vimrc vim -c "helptags ~/.vim/bundle/vim-fireplace/doc" -c "q"
Retro-Gaming and Software Development Platform: A Step-by-Step Guide
- Get link
- X
- Other Apps
Get retropie-4.3-rpi2_rpi3.img from https://retropie.org.uk/download/ Flash it to your sdcard, boot and press F4 to exit to shell. Install graphical desktop: sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install xserver-xorg sudo apt-get install xinit sudo apt-get install raspberrypi-ui-mods sudo apt-get install -y rpi-chromium-mods sudo apt-get install -y python-sense-emu sudo apt-get install -y python-sense-emu-doc sudo apt-get install -y realvnc-vnc-viewer sudo apt-get install lxde Your best friend: sudo raspi-config There you can do all kinds of stuff, I recommend changing your password and enabling ssh in the interface options. Set your appropriate locale (mine is en_US.UTF-8), keyboard layout - English (US, alternative international), and wifi country. Use the spacebar to select/deselect. Type startx to load lxde.
Programming: The New Rock 'N' Roll
- Get link
- X
- Other Apps
In this post we will set up a super efficient programming environment - on a $10 computer, in just a few short lines of code! Step 1 - Install tmux , a terminal multiplexer. This will allow us to work in as many simultaneous terminal windows as we need to, just as if we are in a graphical desktop but all from a single text console: sudo apt install tmux Begin a session with the "tmux" command. Open a new window with Ctrl-b c and switch between them with Ctrl-b n. Step 2 - Install leiningen , vim and fireplace (formerly called "foreplay"). They work together with the Clojure programming language, which uses an extremely concise syntax to generate highly optimized Java and Javascript code: sudo apt install vim git clone https://github.com/ctford/vim-fireplace-easy.git .vim ln -s ~/.vim/vimrc.vim ~/.vimrc vim -c "helptags ~/.vim/bundle/vim-fireplace/doc" -c "q" (Paste the contents of this file into /bin/lein) sudo ...
Pardon My Parsing...
- Get link
- X
- Other Apps
Advent of Code 2016 problems Since they all involve parsing some kind of input data, this will be a job for ... Instaparse ! With it we can use a context-free grammar to generate a tree-like structure from our data. For example, here an input string for the day 4 problem. Each room is represented as a key, id and checksum: aaaaa-bbb-z-y-x-123[abxyz] The key is made of one or more strings of letters separated with hyphens. The id is a string of numbers, and the checksum is a string of letters in brackets. This is how we represent that in EBNF notation... In Clojure!: (def room-parser (insta/parser "room = key id checksum key = (word <separator>)+ <separator> = '-' word = #'[a-zA-Z]+' checksum = <'['> word <']'> id = #'[0-9]+'")) Now we pass the input to our shiny-new parser: (room-parser "aaaaa-bbb-z-y-x-123[abxyz]") And we get our magical tree! Ooowee! => [:...
Programming Beginners Guide
- Get link
- X
- Other Apps
This guide only assumes that you can use a computer. All we're gonna need are 3 things: 1. Web browser - to find and read documentation, 2. Text editor - for writing your source code, 3. Terminal - for entering commands. Depending on your operating system you may need to install Java. You can verify you have it by opening your terminal and typing: java -version The only other thing we need to install is Leiningen , which will take care of everything else. Follow the instructions over there. Download and run the installer and test it out by typing the magic words: lein repl This is where it all happens! Test it out by trying a simple calculation: (+ 1 1) If you've gotten this far, welcome to the future! The power to shape it is yours. In the next post, we'll learn about basic commands.
Theory of Computation - Finite State Automata
- Get link
- X
- Other Apps
An honest effort in tackling the fundamentals of program design must include an understanding of the basics of computation best embodied by automata theory , and our chosen software ecosystem fortunately makes available to us a rich set of visualization tools to assist us in learning these abstract concepts. We will begin this investigation by utilizing a great library called automat , built specifically for this task, which will allow us to use AT&T's Graph-Visualization software to turn simple expressions into images to represent models of algorithms. The simplest automaton is a chain of valid inputs, like [1 2 3]. We punch that into automat, and it spits out a nice pretty diagram for us: > ( view [ 1 2 3 ]) And then we can combine them: > ( view ( a/or [ 1 2 3 ] [ 1 3 ])) This represents the union of the two automata, and returns an automaton which will either accept [1 2 3] or [ 1 3] . Game designer Mark Engelberg , creator of i...
Yes, I said instaparse. How to actually use it.
- Get link
- X
- Other Apps
Create a project and add instaparse to your dependencies: [instaparse "1.4.8"] and at the top of your file: (ns example.core (:require [instaparse.core :as insta])) Now we will take the previous example, the problem from day 4 . It gives us a series of keys like this: aaaaa-bbb-z-y-x-123[abxyz] a-b-c-d-e-f-g-h-987[abcde] not-a-real-room-404[oarel] totally-real-room-200[decoy] Which keys are the real rooms? Each key is made up of an encrypted name (lowercase letters separated by dashes) followed by a dash, a sector ID, and a checksum in square brackets. It is valid if the checksum is the five most common letters in the encrypted name, in order, with ties broken by alphabetization. aaaaa-bbb-z-y-x-123[abxyz] is a real room because the most common letters are a (5), b (3), and then a tie between x , y , and z , which are listed alphabetically. a-b-c-d-e-f-g-h-987[abcde] is a real room because although the let...
Meta-Problem #1: Parse the Input Data
- Get link
- X
- Other Apps
One thing every one of these coding problems has in common is you are given some kind of input data in the form of some string of characters. Parsing is defining a grammar that describes that string of characters so it can be interpreted as data that you can poke around and ask questions about. Mark Engelberg's Clojure library, instaparse , will serve all our parsing needs... but that's not all... it also promises to make it FUN! It enables us to describe our data structure's production rules using context-free grammar notation . For example: S = AB* AB = A B A = 'a'+ B = 'b'+" This looks for alternating runs of 'a' followed by runs of 'b'. So for example "aaaaabbaaabbb" satisfies this grammar. On the other hand, "aaabbbbaa" does not (because the grammar specifies that each run of 'a' must be followed by a run of 'b'). So if we feed it the input "aaaaabbbaaaabb" We will get...
My Interview for Apple
- Get link
- X
- Other Apps
As I am preparing my solutions and tests for the Advent of Code problems to get into Apple, I realize that if I could explain a little bit of how in the world I got into the position of even having a chance to work at such an important company, it can potentially reveal a whole lot about the current state of web technology. I've only been doing this stuff for a couple of years but have managed to make some critical observations and decisions that have given me a major advantage. I want to explain how you could do this too, even more easily than I have. Learning to make abstractions begins with math, but more relevant to the issue here is the way programming is taught, particularly the differences in the rate of adaptation to the technological trends by the tech industry and the computer science education curriculum. A recent example of this is MIT switching from Lisp, a theoretical language invented for AI in 1958, to Python, a modern dynamic scripting language. I love Python an...