Lua Semicolon Conventions

Semi-colons in Lua are generally only required when writing multiple statements on a line. So for example: local a,b=1,2; print(a+b) Alternatively written as: local a,b=1,2 print(a+b) Off the top of my head, I can’t remember any other time in Lua where I had to use a semi-colon. Edit: looking in the lua 5.2 reference I … Read more

Ruby: Boolean attribute naming convention and use

Edit: three-years later; the times, they are a-changin’… Julik’s answer is the simplest and best way to tackle the problem these days: class Foo attr_accessor :dead alias_method :dead?, :dead # will pick up the reader method end My answer to the original question follows, for posterity… The short version: You can’t use a question mark … Read more

How can I build/concatenate strings in JavaScript?

With ES6, you can use Template strings: var username=”craig”; console.log(`hello ${username}`); ES5 and below: use the + operator var username=”craig”; var joined = ‘hello ‘ + username; String’s concat(..) var username=”craig”; var joined = ‘hello ‘.concat(username); Alternatively, use Array methods: join(..): var username=”craig”; var joined = [‘hello’, username].join(‘ ‘); Or even fancier, reduce(..) combined with … Read more

__str__ versus __unicode__

__str__() is the old method — it returns bytes. __unicode__() is the new, preferred method — it returns characters. The names are a bit confusing, but in 2.x we’re stuck with them for compatibility reasons. Generally, you should put all your string formatting in __unicode__(), and create a stub __str__() method: def __str__(self): return unicode(self).encode(‘utf-8’) … Read more

Do people use the Hungarian Naming Conventions in the real world? [closed]

Considering that most people that use Hungarian Notation is following the misunderstood version of it, I’d say it’s pretty pointless. If you want to use the original definition of it, it might make more sense, but other than that it is mostly syntactic sugar. If you read the Wikipedia article on the subject, you’ll find … Read more

An Ideal Folder Structure for .NET MVC [closed]

I have found it simplifies deployment to have the website project contain only content (no compiled code). Something like: Web.Site project Content Images Css Scripts Views web.config And move all compiled code into another project: Web project Controllers Filters Models … Then, you can treat everything within the Web.Site project as needing to be deployed, … Read more