Front Page Posts
Beginner's JavaScript Tutorial, Part 2 - Math, Functions, and Variables
Posted by Blake on 11 Vigeo 12:5
Getting Set UpCreate a new folder somewhere. Create a file called index.html and a file called code.js.
Put the following code in index.html:
In your code.js file, add the following solitary line of code:
Open index.html in a browser.
If you are using Internet Explorer, then a little yellow popu...
Beginner's JavaScript Tutorial, Part 1 - Intro
Posted by Blake on 11 Vigeo 12:4
Welcome to the horrible world of JavaScript. The rumors. They are true.
But with a solid understanding and a healthy level of cross-browser testing, the pain is manageable and only fatal in 20% of cases.
PrerequisitesI assume you have a SOLID understanding of HTML. That means more than "<b> is fo...
Modifying a WAVE File using Python
Posted by Blake on 11 Vigeo 12:3
You may find the Python snippet at the end of this post useful for simple sound editing and effects. It contains a few helper functions and a class called Sound. This allows you to open, modify, and save WAVE files.
The Sound class has a field called "samples". This is a list containing 1 or 2 lis...
How to determine where a line intersects a plane
Posted by Blake on 11 Vigeo 12:1
Suppose you have a line defined by two 3-dimensional points and a plane defined by three 3-dimensional points. How do you tell where the line intersects the plane?
Step 1: Convert the plane into an equationThe equation of a plane is of the form Ax + By + Cz = D.
To get the coefficients A, B, C, sim...
Coding Interview 12: Get the Previous Character in a Stream
Posted by Blake on 11 Vigeo 11:5
Suppose you have an array of bytes. Implement a stream with the following methods:
However, there is a catch. These characters can be 16 bit. The way to tell if a character is 16 bit is if the first byte of a pair of bytes has a 1 as the first bit.
Do not allocate more memory than necessary.
Do...
How to convert a UI Control in WPF/Silverlight/WinForms into a Bitmap
Posted by Blake on 11 Vigeo 11:5
Sometimes you just need to convert a FrameworkElement/Control into a bitmap even though the control doesn't necessarily exist in the UI Tree. Usually people find themselves in this situation because the 2D Graphics Drawing library for WPF/Silverlight is completely non-existent and you just need a ch...
How to Parse Mathematical Expressions
Posted by Blake on 11 Vigeo 11:4
The following code snippet is a parser of simple mathematical expressions. It recognizes the four basic mathematical operations and parentheses. You can also pass in a variable table as a dictionary of strings to numbers. "pi" and "e" are also recognized.
The parser is more or less a stream with a...
10,000 Digits of Legendre's constant
Posted by OmnipotentEntity on 11 Vigeo 11:3
1.00000 00000 00000 00000 00000 00000 00000 00000 00000 00000
00000 00000 00000 00000 00000 00000 00000 00000 00000 00000
00000 00000 00000 00000 00000 00000 00000 00000 00000 00000
00000 00000 00000 00000 00000 00000 00000 00000 00000 00000
00000 00000 00000 00000 00000 00000 00000 00000 00000...
How to Programmatically Draw a Polygon
Posted by Blake on 11 Vigeo 11:1
For some reason you find yourself needing to draw a polygon on a pixel surface given a set of points. Or perhaps even multiple sets of points to draw a compound polygon with gaps in it.
Assume the grid is pixels. Sure, it's a pretty small polygon that will end up grainy when we're done. But smal...
Coding Interview 11: Where is the Restroom?
Posted by Blake on 11 Vigeo 11:0
Given a list of restroom locations (some struct with an x and y coordinte) return the closest restroom to a given point.
Part 1: Find the closest restroom to a point
Simple enough. Loop through the list of coordinates and use the distance formula. Keep track of the lowest distance you find and the...
