Archive for the ‘Programming’ Category

Stickies.app Sync – Teaser II

without comments

Segundo teaser para o meu último projecto.

O trabalho tem avançado a um excelente ritmo, e só é pena estes fins de semana de 3 dias só sejam uma vez por ano (e às vezes nem isso). Tenho aprendido uma alarvidade de coisas novas, seja em Cocoa ou em Rails, e os momentos “eureka” são uns a seguir aos outros. Pequenos “eurekas” pessoais, mas “eurekas” mesmo assim…

O que foi feito então? A aplicação para Mac já tem 90% das funcionalidades que considero fulcrais: pega na base de dados do Stickies, faz a publicação para um URL, recebe a resposta em XML que depois de processada é utilizada para reconstruir a base de dados do Stickies. Já estou a executar o bloco de sincronização periodicamente e faço o relauch ao Stickies para o refrescar (não arranjei forma de o obrigar a actualizar-se). Devo ter memory leaks a dar com um pau que estes anos todos de PHP tornaram-me muito preguiçoso nos meus mallocs e frees. Queria integrar o Sparkle na versão inicial, dado que prevejo muitos updates durante as primeiras semanas.

Quanto ao serviço web, grande avanço este fim de semana. Estava a zero ontem de manhã e hoje tenho um site feito em Rails com grande parte da lógica feita. Melhor que ter o site feito, é que estou a perceber bem a mecânica do Rails. Melhor ainda, é que é um gozo enorme. Valeu a pena ter andado a ler Rails for PHP Programmers aos poucos nas últimas semanas.

Hoje não há tempo para mais, mas fica um screenshot do site a correr aqui no meu computador.

No próximo post espero já ter um link para download de um pequeno DMG e outro link para o pequeno site… Ainda não tem nome, mas estou também a tratar disso.

Acho que seria interessante um log do desenvolvimento das duas coisas, mas para já acho que vou manter este formato semanal. Quando tiver a versão inicial concluída faço um post com todos os detalhes que ninguém quer saber…

Vou dando notícias… :)

Written by Pedro Cardoso

December 9th, 2008 at 1:25 am

Posted in Apple,Programming

Tagged with , , , ,

VIM for PHP programmers

with 3 comments

Gosto do vim mas tenho pena de não saber usá-lo melhor. Safo-me, mas estou bastante longe de ser um utilizador avançado (olá Edson! :) ).

No entanto, encontrei no Scribd um guia que me vai fazer companhia no autocarro, assim que o passar a papel.

Written by Pedro Cardoso

April 15th, 2008 at 11:34 pm

Posted in Programming

Tagged with ,

Paypal publica lista com números de cartões de crédito…

with one comment

…mas só para testar formulários, que embora sejam números matematicamente válidos têm menos saldo que aqui o meu cartão depois de uma visita à Fnac.

Link

Written by Pedro Cardoso

April 8th, 2008 at 4:34 pm

Abort, retry, ignore?

with 3 comments

Não detestam quando estão a meio de um projecto e descobrem que já existe algo exactamente igual?

Porra! Sinto-me como se estivesse enfiado num laboratório a tentar inventar a pólvora e num momento de descanso vou à janela e vejo alguém a lançar foguetes.

(A)bort, (R)etry, (I)gnore?

Written by Pedro Cardoso

December 19th, 2007 at 10:37 pm

Posted in Programming,Rant

Sendmail

with one comment

Para fazer flush à queue de mails no OS X:

sudo /usr/sbin/sendmail -q -v

Estava aqui a fazer umas coisas em PHP e mail e os emails não saiam, ou saiam a conta gotas.

Written by Pedro Cardoso

December 4th, 2007 at 12:39 am

Posted in Programming

Impressões

without comments

Três coisas relacionadas com impressão, vagamente relacionadas:

- Segundo o post aqui do colega no Planeta, a Epson meteu em tribunal fabricantes de tinteiros compatíveis. Por acaso até tenho Epson (uma C62 com uns aninhos), e sempre usei tinteiros de marca branca. São baratos, funcionam, e não há chip para chatear. Que raio de coisas inventam. Afinal de contas, é tinta, não é Chanel nº5 . Nem se vê gasolina da BMW ou da Ferrari…
- Spam postal do Carrefour tinha um multifunções Lexmark (com leitor de cartões) por 25 euros. Não, obrigado. Lexmark nem para esquartejar para peças.
- Pessoal, estamos em 2007. Para imprimir conteúdo de páginas HTML também se pode usar CSS. Leiam como no sempre actual A List Apart. Apenas com CSS (e a função normal de imprimir do browser) desliga-se o que não interessa aparecer na versão impresa (menus, navegação), além de redimensionar containers, aplicar um tipo de letra melhor para o papel, “ligar” secções escondidas na versão normal do site. E se o browser for decente (ie: não-IE), até se fazem malabarismos como meter o URL de um link a seguir ao próprio link e coisas ainda mais catitas. Poupa-se o servidor, cliente e o utilizador que tem menos um popup para gerir.

Written by Pedro Cardoso

June 15th, 2007 at 10:32 pm

Posted in CSS,Programming

load “”

without comments

10 PRINT "Muitos parabéns, speccy, e muito obrigado."

20 GOTO 10

run

Written by Pedro Cardoso

April 23rd, 2007 at 6:46 pm

Posted in Programming

Javascript/CSS Image Reflection

without comments

reflex demoHere is a new CSS/Javascript hack of mine: transparent image reflection, like it can be seen on the image on the left.
Been toying with this for the last few days and after some testing here it is. It’s slow, not fully tested, and probably not good enough to be used, but this can be something to improve and build on.

The idea itself is not original, as it can be seen in lots of places, from websites to software, but this implementation is as far as I know unique, in the sense it does not require browser support for the Canvas tag, like this implementation.

It’s working with Safari, IE and Firefox. IE and Firefox support animated gifs as background, so if the source image is a animated GIF so is the reflection.

Here it is, play with it, check the source and let me know if you liked! :)

Written by Pedro Cardoso

April 24th, 2006 at 11:07 pm

input type=search – Extreme overhauling

without comments

If you’re using Apple’s Safari browser, you may have noticed the following input element, similar to a text box.

Safari Input Search

This element was introduced with Tiger (Mac OS X 10.4) integrated with Dashboard and Safari RSS, but it soon started to appear in some other sites. At it’s heart, this is just a special kind of INPUT element, of type “search”, that Safari renders as a Cocoa search field. Other browsers that don’t know what it is (ie, everyone else) default to a normal textbox, with no ill effects, apart from failing validation.

There are several new attributes for this element, documented here, but in short:

  • placeholder: the text to be shown in light gray when the box is empty
  • autosave: the identifier for auto saving entered values
  • results: the number of auto saved searches

What if there was a way to have this kind of element rendering in the other browsers like it does in Safari?

Well, I hacked away and now there is. I’ve been wanting to wait a little more and clean up the code but release early and release often, right? :)
Just include the code at the end of this post in your HTML, and that’s all, your search input elements will become like this in other browsers.

Input Search Test

Under the hood

At startup, all the INPUT elements of type search are parsed and this happens:

  • The element we are messing with is hidden, and a new container SPAN is created containing (in this order) the search image, a new textbox and the clear button. These elements are styled to look like a single element. In Mozilla, the corners are rounded using the -moz-corner-radius CSS rule.
  • The onBlur/onFocus events are defined so we can automatically clear and set the textbox’s default message (using the attribute placeholder)
  • Similar monkey business is done to the onChange so we can show/hide the clear button when appropriate.

Notes: This behaviour can be easily modified to apply this hack to elements with a certain className, instead of applying to elements of input type=search. When in the presence of Safari, replace the text with a search input. This way the (X)HTML could remain standards-compliant.

This code is yours to do as you please, just leave a comment if you like it… :)

    Todo
  • Re-use the text element instead of creating a new one and hiding the old one.
  • Paste-aware
  • Implement auto saving (using client-side cookies?)
  • Improve the positioning of the images

The files are here. You need the HTML along with the image files.

Written by Pedro Cardoso

March 26th, 2006 at 6:38 pm

Posted in Programming,Projects

Small things

without comments

Pretty PHP code instantly

Have some ugly PHP code you need to beautify? Install the PEAR php_beautifier package and with Mac OS X’s pbcopy/pbpaste commands you’re ready to go.

Copy the source you’re dealing with to the clipboard, and on the command line do this:


$ pbpaste | php_beautifier | pbcopy

Tada! Paste it back into the editor and it’s certainly a lot prettier.

While you’re at the command line, do a man pbcopy for more information about this amazing utility on OSX.

And now, something different. Reading Russell Beattie‘s feed today and came across box.net, a online storage thingy. Seemed cool, complete with some public features so you can share files with others (or other share files with you), and as such I’ll provide you with a link, complete with my email address on it so you can refer me on it. :)

Written by Pedro Cardoso

March 15th, 2006 at 12:37 am

Posted in Apple,Programming