Wednesday, August 28, 2013

AWS for Node.js

Started using this really cool node package that lets you use any AWS services like SimpleDB from right inside Node.js.

How to escape a space in Angular

I asked this question on stackoverflow.com, because I was having issues getting dot syntax to work with Angular and mongoose. Turns out you can't have a space in there, and have to drop the dot in favor of square braces and quotation marks. Ugh, I hate ["double enclosure"] requirements... dumb!

At first I thought I might have to use $interpolate or $sanitize Angular services along with express's app.set but I was wrong. Angular is still very mysterious to me, Express only slightly less so. Time! sigh

Mongoose Schema Definitions

Here is how to define a schema in Mongoose. And how to make connections. Here is where to login to mongolab.com which is where my DBs are. This was something I was working on as part of the swrp.net and sith'ari sites that I haven't touched in a couple weeks due to hammering on my patent application :/

Async was needed for Connect-mongo

You have to have async installed for socket-io to work with connect-mongo evidently. I kept running into a bug that led me to this ("Error: Cannot find module 'async'"). For some reason I'd thought it was already in node by default :/

PlayStation Mobile Developer

I registered as a PSM developer during the free trial, woot ;D Here's the SDK docs and dev portal.

Scripting with Mono

Here is a good site talking about how to script with Mono.

Scripting with Mono

Here is a good site talking about how to script with Mono.

Surfaces

I particularly like this wikipedia article that discusses surfaces.

Friday, August 23, 2013

State Machines

Getting really interested in state machines lately.

Trying to find a good tool that can take standardized state machine markup as input and generate a good visual representation.

Antares Universe VIZIO, a development visualization tool for Unity 3D, seems to be a cool plug-in for visualizing state machine stuff, as shown in this YouTube video.

State Machines

Getting really interested in state machines lately.

Trying to find a good tool that can take standardized state machine markup as input and generate a good visual representation.

Antares Universe VIZIO, a development visualization tool for Unity 3D, seems to be a cool plug-in for visualizing state machine stuff, as shown in this YouTube video.

Tuesday, August 20, 2013

YIELD!

Lcfvs pointed me in the direction of yld, a very cool-looking Node.js package. No wonder, it's his own creation. Here's what he says about it:

Contrary to promises, where developers add functions and disorganize their code, yld allows you to execute instructions linearly.

Each yield pauses the process and allows to retrieve a response from another function ... this is comparable to promise.then().

This programming method avoids to pass the variables from scope to scope, to handle the response.

If you have already tried to use JavaScript asynchonously, you have certainly thought about some answers to these issues.

Sounds good to me!

Akka looks cool

I don't know much about Akka but it sure looks cool. Requires Scala though. And this guy says Node.js with Express is way faster. Hmm.

YIELD!

Lcfvs pointed me in the direction of yld, a very cool-looking Node.js package. No wonder, it's his own creation. Here's what he says about it:

Contrary to promises, where developers add functions and disorganize their code, yld allows you to execute instructions linearly.

Each yield pauses the process and allows to retrieve a response from another function ... this is comparable to promise.then().

This programming method avoids to pass the variables from scope to scope, to handle the response.

If you have already tried to use JavaScript asynchonously, you have certainly thought about some answers to these issues.

Sounds good to me!

Monday, August 19, 2013

More on Software Patents

Today I wrote a comment on an ipWatchdog article where I said:

To say software does not alter the physical machine is wrong. Software is stored as a specific orientation of magnetic particles on a disc, or a specific orientation of physical electrons stored within a memory matrix (RAM, SSD). Software sends specific computing instructions to a processor in the form of precise physical patterns of electrons. Just in the same way, the distributor in a car sends electrons to spark plugs in a specific sequence enabling the engine to run, and most cars now use a computer to control much of this. Further any machine is nothing more than information temporarily conveyed in the arrangement of protons, neutron, and electrons within the spatial matrix of the "reality" of the universe, which is arguably itself a giant quantum computer that we ourselves are merely software running on (see MIT theorist Seth Lloyd's paper, "Universe as quantum computer"). The fact that genes are patentable belies the validity of arguments against software patents since gene sequences are merely biological software! And biology is merely software running on the universe itself.

Re Bilski was denied because they tried to tack "on a computer" to their ideas just to make it patentable. Citing a "data source" does not require a computer: an autistic guy who memorized the phone book is a data source, too. Software that relies on specific things about computers like network protocols, markup languages, complex data structures that are clearly defined by the patent, etc. are things that remain patentable. Saying "a piece of software that accomplishes goal X" is not patentable without thoroughly explaining how that goal is accomplished by the software.

Friday, August 16, 2013

How to use SimpleDB with Node.JS

in the main app:

//aws config

AWS.config.loadFromPath('credentials.json');

AWS.config.update({region: 'us-east-1', apiVersion: '2009-04-15'});

exports.AWS = AWS;

in the views/partials/partial1.jade:

p IC Name: {{character.Attributes["IC Name"]}}

in public/js/controllers.js:

socket.on('send:character', function (data) {

$scope.character = data.character;

in routes/socket.js:

var AWS = require('aws-sdk');

var sendChar = function(socket) {

console.log("send character");

var sdb = new AWS.SimpleDB();

var params = {

'DomainName': 'Avatars',

'ItemName': 'Avatar Name'

};

sdb.getAttributes(params,function(err, data){

if(err) {

console.log('error in send:character: ',err);

return error;

}

charData = {'Attributes':{}};

data.Attributes.forEach(function(value,index){

charData.Attributes[value.Name]=value.Value;

});

console.log('char data returned: ',charData);

socket.emit('send:character', {

character: charData

});

});

}

module.exports = function (socket) {

...

sendChar(socket);

...

};

Wednesday, August 14, 2013

Starting a new Node.js Socket.io Jade Angular Express Site on OpenShift :D

So to start a new site I went to btford's angular-socket-io-seed and downloaded the zip. He seems to have changed his package management over to bower, and alternative to npm, though there seems to be disagreement on stackoverflow as to which is better. Whatever. Here is the definitive article on package management that addresses nom, bower, et al. The whole idea is to get the Amazon AWS SDK node package working with it.

I made a new node site on OpenShift, pulled the repo, then deleted everything and copied the angular-socket-io-seed. Then I globally installed bower, and locally installed socket-io and express in my new app. I renamed app.js to server.js to satisfy OpenShift's launcher. Also had to npm install Jade.

Next I had to change in server.js:

self.ipaddress = process.env.OPENSHIFT_NODEJS_IP;

self.port = process.env.OPENSHIFT_NODEJS_PORT || 8080;

This ends up looking like this:

app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 8080);

app.set('address', process.env.OPENSHIFT_NODEJS_IP);

Added app.get('address'), to server.listen.

That worked, except the time isn't showing up. Well it's on a severe delay.

So I nav'd to /public in my project and did:

bower install angular-socket-io

This is to update that since it was 0.0.2 in the project but current is 0.2.0, and I think it was having to download a dependency causing the delay. Nope, the delay was due to the fact rhcloud does not support websockets on the default port! Therefore it falls back on XHR polling just like Heroku does, at least by default. But as of December 2012 they had a preview with websockets working. You have to use port 8000 for http or port 8443 for https for it to work evidently.

So therefore... what I had to do is in my client app.js I had to add this:

config(function ($routeProvider, $locationProvider,

//this as per the angular-socket-io documentation to get it to connect to the port 8000:

socketProvider) {

var mySocket = io.connect('http://myURL:8000');

socketProvider.ioSocket(mySocket);

Because otherwise it will still default to the regular port and go back to nasty XHR polling.

I thought of using a proxy module for node but this worked so hey. It goes to show you. There's usually a non-obvious built-in solution to obvious problems.

ZOMG I had to bower install angular-cookies ... for some reason it's not already there... WTF!?

Then I had to drag the angular-cookies files into the angular main folder... they couldn't be in the separate folders that it makes for your ass. WTF WTF. It was because I wasn't loading scripts in order in my index.jade file.

Now I keep getting the error:

/Users/qwerqwer/Documents/Dev/node projects/sithari/routes/socket.js:45

thisApp.thisStore.get(sid, function(err, gotsession) {

^

TypeError: Cannot call method 'get' of undefined

Why the heck is it undefined?

Because I needed to npm install Async.

Monday, August 5, 2013

Software Patents: Good Idea?

I read this article on WSJ.com and posted this comment:

Mr. Love's arguments are illogical.

First of all, he tries to assert that small companies don't file patents, only big companies like Apple and Google; then he says that these big companies spent $15 billion in 2011 to buy their patents *from other companies!* To me that sounds like a great reason to file a patent, if you're a small company: so that later on, you can sell it for lots of cash to someone like Apple or Google.

Mr. Love mentions that most software start-ups don't file patents, but he does not provide any supporting evidence as to why, nor does he state how much less likely they are to file these patents than start-ups in other industries. Leonid Kravets reported on TechCrunch.com that 29.5% of general software start-ups file patents, while 38% of network hosting software start-ups do -- compared to 52% of general hardware start-ups and 65.2% of semi-conductor hardware start-ups ("Do Patents Really Matter To Startups? New Data Reveals Shifting Habits", June 21, 2012). He also showed that start-ups who do file patents are increasingly more likely to file additional patents. However only 15.9% of web start-ups file a patent in the first four years.

It seems pretty obvious that the type of software being developed is the key factor in determining whether or not a start-up will file a patent. These days, many software start-ups rely heavily on open-source software; their company may not even be selling the software itself, just the service of supporting that software or providing particular content via that software. This is particularly true for web companies who are more service-oriented and content-oriented and do not sell software; or for game companies who license gaming engines from other companies and are not innovating new methods of how a video game is made, but rather, are simply providing a new "flavor" of an existing type of game, relying on copyright to protect their game's unique aspects (3D models, music, textures, level design, etc.).

Mr. Love did not interview any start-ups or conduct a survey of start-ups to find out why they are not filing patents. He implies that even if these companies have something patentable, they simply don't think it's worth patenting anyway. However he provides no examples of companies who decided against patenting a patent-worthy software innovation, simply because they thought it wouldn't do them any good. I am certain they would be difficult to find.

If you are a software start-up who has actually developed a completely original piece of software that does something no software has really done before, in a unique way that is truly worthy of being patented, then why should your right and ability to patent that idea you worked so hard to create be taken away from you, just because some jerks decided that because it's written in code as opposed to made out of metal, therefore patents should not apply? Or just because some litigious companies abuse the system (something that should have a separate cure besides just getting rid of software patents)?

Also what is the problem with Apple and Google paying their attorneys a lot? Mr. Love also does not provide any information on what other major tech companies spend on their attorneys, such as General Electric. I highly doubt Apple spends more on attorneys than GE! Also the attorneys that Apple and Google are paying are largely US citizens who put that money back into the economy. Even with this, attorneys still have a hard time finding work in the US due to the fact that our government does not enforce the constitutional right to a fair trial in this country except in criminal proceedings. If you are a small business and get hit with a bogus tax assessment, it will cost more for an attorney to defend yourself against the vampire state than it will to simply pay the tax assessment, due to the fact that you are not afforded a court-appointed attorney.

I also think:

If there is a reason a software patent might not be a good idea, I would say it is the fact that by filing the patent, you must publish your entire idea, which makes it an easy matter for a programmer in China or wherever to copy your idea long before you have the opportunity to file a patent outside the US. And unlike hardware that must be physically imported, and therefore the importation of it can be blocked, software being sold from a website hosted outside the US would be very hard indeed to take action against, even if your patent is approved. All they have to do is change their website's name.

I also wrote:

Sean, imagine you're an inventer. You work a day job 44 hours per week. In your "spare time" you stay up late and slave away on an invention. It's something that's never before been made, which will enhance the lives of the people who use it. You personally recognized the need for the invention, designed it, tested it, made it, built it, wrote documentation and diagrams for it, and now you want to sell it. Now someone is telling you: your invention does not consist of physical items therefore I can copy it exactly and sell it and you have NO RECOURSE. Your patent application gets denied because there are no physical items involved in this thing, it is something that only exists inside a computer environment, or inside of virtual reality, or on a website, etc. How would that make you feel? I would say you had wasted your time inventing something that wasn't a physical object, and that you just got SCREWED.Look: if I invent something that is made out of metal and parts, all I am doing these days is simply designing it in a 3D CAD program and then sending all my digital plans to some company in China (or wherever) who basically just "prints out" the design. How is the printing out of that digital design any different than the display of a digital design on a computer monitor, in which the digital design is converted into a *physical* array of photons that hit your eyes, just like the 3D printer makes a digital design into a *physical* array of atoms that hit your hands? I think the fallacy here is that there is a difference between hardware and software. Yes, some inventions must take a certain form in order to function properly -- RAM must be a certain arrangement of molecules in reality, while a computer game must be a certain arrangement of electrons in RAM, etc. But it is fallacious to say that everything does not exist, at some level, in physical reality. Vlatko Vedral argues coherently in "Decoding Reality" that physical reality itself is essentially a quantum computer, which means that everything is software at a certain level. The problem is patent trolls, and you people want to solve this problem via draconian methods. The real solution would be to revise patent law to better define what aspects of software are patentable, and what aspects are not; and to establish a set of legal criteria for what a patent troll is, then make it a crime to be one.

Sunday, August 4, 2013

Thursday, August 1, 2013

Got Authorization Working Better

This was useful to get socket.io auth working better:

http://udgwebdev.com/nodejs-express-socketio-e-sessions/

https://github.com/senchalabs/connect/issues/588

Passport looks cool but I don't have it in use yet: http://passportjs.org/guide/

Had to install nom install cookie to do cookie.parse to un-semicolon-list the cookies for proper un-signing.

How to fire an embedded document in another document in MongoDB / Mongoose.js

Here's what I had to do:

socket.on('get:planet', function (data, callback) {

//console.log('get planet heard');

planetModel

                .find({_id:data.planetId})

                .populate('consortium')

                .exec(function (err, results) {

callback();

socket.emit('send:planet', {

planet:results[0]

});

});

});

Populate pulls the goods from another record and plops it in there.

But now my problem is how to use Angular select ngOptions to deal with this in a form?