background preloader

CODE Project

Facebook Twitter

Basic Curves And Surfaces Modeler. Introduction This is a basic surface modeler made using MFC and OpenGL on VC6. The geometry interface and graphics interface are separated so that you can simply define your curve or surface without worrying about the display. The display is in a generalized form i.e. if you derive your own curve from CCurve and override the PointAtPara and NormalAt methods along with other mandatory methods, you can create an OpenGL curve as follows: Some where in your project file you create your own derived classes' headers and source files...

Some where in your CDocument code... #include "myCurve.h"void CMyProjDoc::OnCurve() { myCurve crv(...); CGLCurve* myglCurve = new CGLCurve(&crv) dContext->Display(myglCurve); delete myglCurve; } Now dContext is the display context object (CGLDisplayContext) that manages all the display functions, so this is created in the constructor of the document.

The display of all curves are managed by the CGLCurve class and that of surfaces are by the CGLSurface class. The demise of the low level Programmer. When I started programming many of the elements we take for granted now, did not exist. There was no DirectX and not many compatible libs were available for the free compilers of the day. So I had to write my own code for most basic programs, keyboard handlers, mouse handlers, video memory accessors, rasterizers, texture mappers, blitters… the programs I wrote then were 100% my own code and I had to be able to handle anything and everything. Personally I’ve always been interested in what was going on under the hood so this suited me just fine. I always dug into the details and I almost always end up programming as close to the bone ON the hardware (or OS) as I possibly can both to eek out as much performance as possible AND to satisfy my own hunger for knowledge.

Over the last decade I’ve been involved in the hiring process at many studios and in more recent years I’ve noticed a pattern. Knowledge of what is generally considered “low-level” programming is waning. Why Dynamic Programming Languages Are Slow. Elegant Coding: Eleven Equations True Computer Science Geeks Should (at Least Pretend to) Know. This idea is a complete rip off an article that appeared in Wired a little while ago and it got me thinking what would my list for Computer Science look like?

Plus I thought it might be a fun post and unlike the Wired list this one goes to eleven. So here they are in no particular order: Binomial Coefficient The Binomial Coefficient equation generates Pascal’s Triangle and gives you the coefficients for the Binomial Theorem these ideas are often attributed to Pascal but in fact they have been known in part for over a millennia. As I mentioned that this list is no particular order and I don’t wish to play favorites but if there is one equation here that you should really consider learning and committing to memory this is it.

Demorgan’s Laws Logical form: Set Form: Eigenvector and Eigenvalue Pumping Lemma for Regular Languages No Comp Sci list would be complete with at least one formula from either Formal Language Theory or Automata Theory. Information Entropy Bayes' Theorem Natural Join O(n) Calling Go from Python via JSON-RPC. Computing ThoughtsCalling Go from Python via JSON-RPCby Bruce EckelAugust 27, 2011 Summary Although it's often uncomfortable, I think the best approach to learning a new language or technology is just to grab your nose and jump feet-first into the hole in the ice.

I've been intrigued by the Go language since I first encountered it about 6 months ago. There are some great online lectures that you can find here. Go solves a number of problems that C++ and Java didn't. But one of the biggest issues solved by Go is parallel programming. My interest here is to make the case for hybrid programming. In my experience, all languages do some things well but have blind spots. Python, for example, is an incredibly powerful language for rapid development because of the simplicity and clarity of its syntax and the extensive reach of its libraries. One is building user interfaces. Both Python and Ruby support concurrency, which allows you to program as if you have multiple processing units available. We Got Hacked, Here's What We Found. Last week we discovered that the owner of SEOnix.org hacked in to our backend and threw himself a sweet SEO party. The only invitee was obviously his own website, but he still managed to have a good time all alone.

In the last 3 months he got a couple of nice gifts from us in the form of juicy links and an occasional canonical tag. But it wasn’t only us. He managed to do the same on other authorative sites as well. We’re leaving the names out to protect the innocent. In total he has injected several hundred posts, getting links from 25 domains, most of which it’s safe to assume weren’t earned like you or I would earn them.

So What Happened? This person managed to get in via one of our editors’ logins and put links to his own site in 124 posts. Content scraping is nothing new, and it happens to us all the time. Here’s a good example – when searching on one of the URLs from TNW you see his post is at the number 1 position not ours. Get Greedy, Get Caught. Collective Intelligence: Ants colony solving TSP. According to Wikipedia: "Collective intelligence is a shared or group intelligence that emerges from the collaboration and competition of many individuals and appears in consensus decision making in bacteria, animals, humans and computer networks".

This article describes how to make ants find the solution for the TSP problem. Implemented in Python. Get the source from GitHub. The algorithms based on collective intelligence have some "interesting" properties: decentralizationparallelismflexibility, adaptability"robustness" (failures)auto-organization These algorithms are inspired by the nature. The swallows settle on wires before they are taking of for the next destination. There exist several applications of collective intelligence in engineering and optimization. Travelling Salesman Problem Travelling Salesman Problem is a classical problem in the field of graph theory. Ant colony algorithm for TSP Ant colony algorithm was introduced in year 1997 by Italian researcher Marco Dorigo. HTML5 Game of Multi Life. Download source - 2.53 KB Introduction This article describes an HTML5 version of Conway's game of life using the new Canvas element. I have actually previously done an article describing a WPF/XBAP version of Life which can be seen here.

My intention was not to display a singular lack of imagination but rather contrast the two different coding styles. The take home message I have is that for small applications, HTML5/JavaScript is probably twice as easy to code up and has the advantage of being truly multi-platform. Performance on the top five browsers I tried was also excellent. Background Please refer to my previous WPF article for more details or just Google "Conways game of life" but in essense, Life, models simple automota that live on a grid and live or die according to simple rules based on the number of neighbours they have.

Using the Code The code consists of just one file and the file size is just 8KB! The LifeTorus class implements my model and it was relatively easy to write. Why I prefer Scheme to Haskell. Before you sharpen you keyboards and spit acid at me as punishment for the title, let me point out that I haven't written this post to bash Haskell (no pun intended), in fact I love it. Haskell introduced me to algebraic data types, domain specific languages, pattern matching, and many other programming constructs that feel like lost limbs in other languages, but Haskell willfully resists any attempt I make to write useful code with it. Scheme lacks almost all of Haskell's innovations in favour of a minimalistic flexibility, but it mixes a practicality with the functional beauty that makes it Haskell for human beings.

Last weekend I began writing a prototype for a data mining application. I started in Haskell; it is fast, elegant, and once you've used the Parsec module it is tough to imagine writing a parser without it. My first step was to extract data from a straightforward XML file. Yes, literally hundreds of them.

I'm not saying Scheme is better than Haskell. Posted on 9 April 2012. Adding Background Music to Android App. Download source - 4.38 MB Introduction A large chunk of Android's application development consists of Game development. Background Music is an integral part of a Game app. This article explains how to add music to any Android App using Media Player provided by Android SDK Library. Familiarity with Android activity and services is assumed here.

Background MediaPlayer class controls the playback of audio/video files and streams.Its Life Cycle is implemented in the form of State Machine Diagram.The official Android development page gives a nice explanation of its Life Cycle. Use a Service with MediaPlayer In order for media to be played in the background of your app location when the user is interacting with it— you must start a Service from your application's main activity and the service shall contain all the methods related to playback. Using the Code Below is the code for a basic service implementing the media player.The code is written in JAVA by using Android SDK on Eclipse IDE. History. WPF Game of Life. Introduction This article describes an XBAP (XAML Browser Application) implementation of Conway's Game of Life. This is my first article and in fact my first serious project in WPF. The reason I've done it is more as a learning exercise to see what WPF is capable of (a lot!)

And what the limitations of XBAPs were. As well as exploring XBAPs, this application also allowed to me to learn about writing FrameworkElement derived classes. Background There are many web sites that deal with Conway's Game of Life - perhaps the best introduction to the topic is the Wikipedia article, Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. Any live cell with fewer than two live neighbours dies, as if caused by under-population. The game starts with the user setting which cells are alive, then the game advances one generation at a time. Using the Code Points of Interest. Want apps? here is the list of best apps on market - Samsung Galaxy S Forums : Galaxy S2 S II Forum. BASIC Computer Games: Page from BASIC Computer Games.

Writing a Multiplayer Game (in WPF) Introduction This article will explain some concepts of game development and how to apply and adapt them for multiplayer development. Background When I started to program, I used AMOS BASIC. It was oriented for games and it was the reason I liked programming. Some Principles Even if it is possible to do event-oriented games, that's not usual. Well, that works very well for single-player games but multiplayer games have a lot of other problems.

To solve the slow connection problem, there are some techniques. I decided for another approach. On slow connections, if you press to move forward, it can take some time to show you what happened and, if you stop moving forward, the character will still move forward on the server until it receives such a state change. The Technology XNA has the Update/Draw principle, but it is local. To make communication fast, I decided that I should only send the changed values from the server to the client and from the client to the server.

The Update x++; What Else? How processor, assembler, and programming languages work (for dummies) Introduction You might be wondering about how your computer works: what happens when you write a program and then compile it? What is assembler and what is the basic principle of programming in it? This tutorial should clarify this for you, it’s not indented to teach you assembly programming itself, but rather give you the needed basics to understand what’s actually going on under the hood. It also deliberately simplifies some things, so you’re not overwhelmed by additional information. However, I assume that you have some knowledge in high level programming (C/C++, Visual Basic, Python, Pascal, Java, and tons more…). Also I hope that the more skilled guys will forgive me for simplifying a lot of things here, my intention was to make the explanation clear and simple for someone who doesn't have a clue about this topic.

Note: I will be very grateful for any feedback on this. How does the processor (CPU) work? What are instructions and how are they used? Small example Complexity of programs ). Realtime Webcam Sudoku Solver. Introduction This application might not have any practical value, but it is great from a learning perspective. I wanted to learn about computer vision.

Computer vision is one of the most exciting areas of modern computing. It is also a difficult area. What is simple and obvious for the human brain is very difficult for a computer. Many things are still impossible with the current level of IT progress. This application is implemented using low level C++ because I wanted to learn how things work under the hood. The webcam acquires one image at a time (a frame). The numbers below the image are delays in milliseconds measured on my 2.8GHz PC with the webcam set to 640x480 pixels. How conversion to black and white works Thresholding Every computer vision application starts with the conversion from color (or grayscale) to monochrome image. The simplest method to convert color to monochrome is “global thresholding”. For a good conversion to monochrome, we will use adaptive thresholding.

Theory. Why Study Functional Programming? ...or, "why make programming even harder? " Learning functional programming is an opportunity to discover a new way to represent programs, to approach problems, and to think about languages. While programming with a functional language is still fundamentally similar to programming with any other type of language (examples of others being imperative or logic), it represents programs and algorithms through distinct forms of abstraction and gives you a new toolset with which to solve programming problems.

Additionally, many of the techniques of functional programming are beginning to permeate new mainstream languages, so taking the time now to develop a thorough understanding of them is an investment which will pay great dividends. For more information, it is best to search the internet for pages arguing why it is worth your time to learn specific functional languages.

Many such pages are linked below in the relevant sections. Scheme: well articulated Lisp Scheme vs. Linus Torvalds: The King of Geeks (And Dad of 3) | Wired Enterprise. The license plate on Linus Torvalds’ Mercedes SLK convertible says it all. The frame running around the outside of the plate reads “Mr. Linux. King of Geeks.” But the plate itself says “Dad of 3.” If you meet Linus Torvalds, he comes off as a mild-mannered, down-to-earth Finnish-American. He lives with his wife Tove, three kids, a cat, a dog, a snake, a goldfish, a bunny and a pet rat in a comfortable 6,000 square foot home just north of Portland’s tony Lake Oswego neighborhood. The house is yellow — his favorite color — and so’s the Mercedes. But he’s not really like any of his neighbors. He leads a double-life. Linus Torvalds has reached middle age, and so has Linux. Linux began life as an underdog project.

Throughout the ’90s and on into the next decade, the fight was fierce on both fronts, but now, so many of the battles are won. More than 8,000 developers have contributed to the Linux kernel in the past seven years, according to the Linux Foundation. And Linus became a dad. Advanced programming languages. Abakus -- The simple KDE calculator. The Most Complex Program of All Time « Making the Complex Simple. Google to announce "new programming language for structured web programming" Lisp Hackers: Marijn Haverbeke. _why's Estate - The Little Coder's Predicament.