terça-feira, 27 de agosto de 2013

[QuickTip] SublimeText Build System for Love2D

For those using Love2D as game engine and SublimeText2 as IDE this *.sublime-build can come handy if you want to rapidly generate *.love file for testing. (using command+B in mac for instance)

{ "cmd": ["zip -9 -r --exclude=.love game.love .; ls"], "selector": "source.lua.love", "shell": true }

This will generate a game.love inside your current folder excluding the .love files itself, also will show on SublimeText shell the output of the command.

By the way, if you want to run .love in the sequence just use the following

{ "cmd": ["zip -9 -r --exclude=.love game.love .; ls; /Applications/love.app/Contents/MacOS/love game.love"], "selector": "source.lua.love", "shell": true }
CMD receives a string used in terminal so using: /pathToLoveExecutable name.love; Will call the love executable as you would do in Terminal. 

And that should do the trick ;)

terça-feira, 16 de julho de 2013

Signing your TAG with Git - MacOSX

Recently I was asked to start versioning our master with tags and while doing some research about it I found a relevant blog post from Mike Gerwitz Git Horror Story about signing git commits.

I won't get inside the subject but I think signing at least your tags is a good initial step towards security.

In this guide you will:
- Install GPG (Gnu Privacy Guard)
- Create a signed key
- Create a signed tag
- Push tag to git server

You should already have git installed, of course.

So let's get started.

Installing MacGPG


You should follow MacGPG instructions at MacGPG at Sourceforge

Or if you like tools that solves your problems hidding the neat part use GPG Tools, altough I personally didn't test it.

Creating a signed key

Before we can really use tag command we must create a key, in a similar way that we do when using ssh private keys for GitHub.

In a terminal use:
gpg --gen-key
The terminal should ask you to select your key type like this:
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
The default selection is prefered in this case, unless you REALLY KNOWS why you would want to choose other options.

Next he asks you to choose a size:
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
I guess 2048 is good enough for me, pick a size you need.

Now it will asks for an expire date, even if you have really strong reasons for not setting an expire date THINK AGAIN.
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n daysw = key expires in n weeksm = key expires in n monthsy = key expires in n years Key is valid for? (0)
On this step you need to use your REAL information: name, email and passphrase. A comment can be inserted also, but isn't required (I recommend using it to differ this key amongst other keys).

You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de="">

Type O when you have finished and the terminal will prompt for a passphrase
And you're done for this step, let's create some tags.

Type O when you have finished and the terminal will prompt for a passphrase

And you're done for this step, let's create some tags.

Creating Tags with Git

I won't go in deep details about git tags, so if you want to read some about the subject first this is the right place: Git Basics Tagging

First you should get your key identifier, run the following command

gpg --list-secret-keys
This should print anything similar to:
sec 2048R/8EE30EAB 2013-07-16 [expires: 2015-07-16] uid Name (Comment) <youremail@email.com=""> ssb 2048R/hexvalueB 2013-07-16
Copy the 8EE30EAB from sec (yours probably is different)

Go to your repository folder on terminal and config git to use this key (remove the --global param to apply only for current repository)

git config --global user.signingkey 8EE30EAB
Finally create the tag
git tag -s v1.5 -m 'my signed 1.5 tag'
Show it with
git show v1.5
Push it with
git push origin v1.5
If you have more than one tag you can use
git push origin --tags
And that's it. If you have any problems leave it on comments I'll be glad to help if I can.

sexta-feira, 15 de fevereiro de 2013

[iOS] Using UIRefreshControl

In iOS 6 Apple presented us the UIRefreshControl to use with "Pull to Refresh" actions. This control is really easy to use and can be currently used with UITableView, UIScrollView and UICollectionView.

On your -(void)viewDidLoad method or the place where your controller will load for the first time, create and add the refresh control as a subview of the views mentioned above.





The next step is to create the refreshView method, just add it anywhere on your view controller.




That is it, nice and smooth.


quinta-feira, 10 de janeiro de 2013

[Rails] Feedzirra and custom fields

When we read RSS on any programming language normally only the default fields are necessary, but sometimes a comment page link, a subtitle or other important info is stored into custom fields.

I was working with Rails and Feedzirra when this problem appeared to me and with the example+solution below I hope other people don't have to struggle much on this.



For a common rss you would use


And now the magic line to register article:subtitle...


So the final code should be



You can even map to field to same single resulting field, when you have two different sources with different subtitle fields for instance.



That solves the issue