Use Bitbucket to store all your projects. It is a Version Control System and it provides you crucial backup for your code.
Here is how I use it
Always write clean code, indent properly. This improves readability and makes it easier to find bugs.
ZeroBrane Studio now has an option to automatically fix indentation of your code
Edit -> Source -> Correct Indentation.
Another language that I like very much Go has a special tool
go fmt, it reformats entire code, making it a single standard for everybody.
When all developers use the same code style, it's much easier to read others' code.
There will be a similar feature in ZeroBrane Studio in the future.
Single quote for strings is better because you don't have to hold shift to type it.
local str = "not healthy" local str = 'healthy'
Holding shift and typing double quotes is inconvinient for your hands, they get tired faster. Keep your hands relaxed while coding.
for loop is faster than
pairs(), however it rarely makes a difference.
You can't write to
system.ResourceDirectory on a device, but you can in the Simulator.
This is useful if for example you are making a level editor inside the game, using the Simulator you can edit and save levels inside your project directory.
There is one limitation,
system.pathForFile('newfile.txt', system.ResourceDirectory) won't work for files that don't exist. If you need to create new files inside
system.ResourceDirectory, you have to construct correct path with a file that exists for sure, such as
Here is a small snippet that will create
local path = system.pathForFile('main.lua', system.ResourceDirectory) -- Remove main.lua from the string path = path:sub(0, -9) -- Add newfile.txt instead path = path .. 'newfile.txt' -- Open new file for writing local file = io.open(path, 'w+') if file then file:write('File Content') io.close(file) end
There is a website called Habrahabr, where posts have a preview version and a full version. Preview is made from the full version by cutting the text before special habracut tag
So I miss such feature in Ghost and decided to implement it on my own.
<!--preview--> to define where preview ends in my post.
When there is something more to read, three dots in the center appear.
ghost/core/server/helpers/index.js file. Scroll down until you see
coreHelpers.content function. We need an extra
if statement to cover our case.