Category Archives: Uncategorized

Rendering kaomoji in Arch Linux

tl;dr: install ttf-indic-otf plus a good CJK font and hope for the best. (╯°益°)╯彡┻━┻

Recently I was reading a Wanikani forum post and noticed Chrome couldn’t render its title properly.

kaomoji-not-working

Well, Wanikani is a site about japanese, so the usual suspect is a missing glyph in some japanese font. I thought about it for a second and remembered about kaomoji (顔文字), “face-character”, japanese emoticons; this should be one of them because of the parenthesis. So I needed some set of fonts to display those and I couldn’t find anything useful on Google.

My initial reaction was that I lacked some Chinese or Korean glyph, so I started installing several CJK (Chinese-Japanese-Korean) fonts and reopening Chrome. Not much progress. I eventually installed FreeFont, a font supposed to contain a good amount of unicode characters. Guess what?

kaomoji-2016-06-27

A bit of success, but the characters inside the parenthesis still weren’t rendered at all. I spent an hour trying various combinations of fonts as listed in the ArchWiki until I gave up on Linux and decided to see the title on my iPhone. Of course the thing rendered correctly there.

I googled that character (ಠ) and discovered about the Kannada alphabet used in India, and more generally that kaomoji uses alphabets that I didn’t even know existed. Of course, fixing it is quite simple: just install indic fonts. The result:

kaomoji-working

Specifically, for future reference, I installed these packages:

I updated the ArchWiki fonts article with a section about kaomoji, this is it.

I also reviewed the selection on kaomoji.ru/en to look for more rendering problems. I didn’t find an obviously wrong instance, but it is hard to be sure. Hope I never have problems with this thing again. ┬─┬ノ( º _ ºノ)

When to ignore air resistance

This paper talks about how most introductory physics textbooks are awful and provide unrealistic approximations, with no comments on their applicability.

The observant student knows—from exploring the world—that golf drives rise quickly and almost straight and drop parabolically only near the end. This student learns that the world described by her physics textbook is not the real world and that careful observation is irrelevant to physics.

Contrast the experience of the curious student with that of a student who parrots equations and regurgitates textbook paragraphs. This student is untroubled by the golf problem or its variants listed in Table I because he knows the easily memorized “fact” that all trajectories are parabolae. […]

If you ever took a physics class, I’m quite sure you recognize that teaching style. The following figure shows the trajectory of a golf ball considering air resistance, in case you’re interested:

Playing Rising Lands in a modern computer

UPDATE: According to the comments of HellRazor, it is possible to play Rising Lands successfully with DOSbox. I added a new section explaining the method.

After reading the StarCraft II novels Heaven’s Devils and Flashpoint, I got back to playing StarCraft 2. I’m an awful player, but remembering the original StarCraft (and its expansion set, Brood War) made me think about games that impressed me when I was young. One of them was Rising Lands, a RTS set in a post-apocalyptic future in which Earth was devastated by a meteor collision and most technological knowledge was lost. (yes, cheesy, but trust me on this — it is good)

Continue reading

The most socially useful communication technology

Text is the most socially useful communication technology. It works well in 1:1, 1:N, and M:N modes. It can be indexed and searched efficiently, even by hand. It can be translated. It can be produced and consumed at variable speeds. It is asynchronous. It can be compared, diffed, clustered, corrected, summarized and filtered algorithmically. It permits multiparty editing. It permits branching conversations, lurking, annotation, quoting, reviewing, summarizing, structured responses, exegesis, even fan fic.

I read the post “Always bet on text” today and, I must say, it is a beautiful way to look at the process of communicating by writing. :)

Completeness and incomputability

It is notable that completeness and incomputability are complementary properties: It is easy to prove that any complete prediction method must be incomputable. Moreover, any computable prediction method cannot be complete — there will always be a large space of regularities for which the predictions are catastrophically poor.

— Ray Solomonoff, “Algorithmic Probability — Its Discovery — Its Properties and Application to Strong AI”

This quote is a paragraph from the book Randomness Through Computation, an amazing work I was reading this morning.

The idea that any computable prediction method can’t be complete is profound for those of us that work with machine learning; it implies we always have to deal with trade-offs. Explicitly considering this makes for a better thought process when designing applications.

References

  1. Ray Solomonoff — Wikipedia.
  2. Solomonoff’s Lightsaber — Wikipedia, LessWrong

A PNG showing differently in Firefox and Chrome

I was chatting with some friends on IM when someone posted an URL to a Psyduck image. In it said “Now open this in Firefox” when opened in Google Chrome or Safari and “Now open this in IE (or Chrome/Safari)” when opened in Firefox.

Psyduck

What.

At first, I though it would be a simple use of pattern matching against HTTP’s User-Agent on the server to send two different PNG files depending on the browser. However, both files had the same size and I couldn’t reproduce it with curl. Worse: I downloaded the file and the same behavior was present, so it should be something with the image itself.

I never really studied or read about binary file formats before, so I googled a bit and installed the chunkypng gem. After playing a bit with its documentation, I could see which blocks it had.

Can you see the acTL block? It isn’t in the PNG specification. Why is it there? After some more searching, it was clear that this block is only available in APNG files, an extension to PNG enabling animated images similar to GIF.

The first byte @content of the acTL block is the number of frames (only 1) and the second one is how many times to loop the APNG
(source). From the spec, there’s always a “default image” (described by the IDAT blocks, exactly like a normal PNG file), thus this extra frame should be the second Psyduck image.

To confirm this hypothesis, I installed pngcrush with Homebrew and removed the acTL block:

I ended up with an image that will look the same independent of the host browser:

Altered Psyduck

Search a bit more lead me to the cause of the discrepancy: only Firefox and Opera have support for APNG files! From this post in Google’s Products forum and this ticket in Chromium’s issue tracker, WebKit/Chrome doesn’t support the format and probably won’t for some time. Also, from the spec:

APNG is backwards-compatible with PNG; any PNG decoder should be able to ignore the APNG-specific chunks and display a single image.

Take all that and the mystery is solved: when that image is opened in Firefox (or Opera), it’s treated as an APNG and the second frame is shown. In Chrome/Safari (WebKit), the extra blocks are ignored and the default image is shown.

That was fun.

References

  1. PNG specification
  2. APNG specification

MATLAB in OS X Mountain Lion

I needed to write an optimization function for college and came across this problem today: if you use OS X Mountain Lion (I think the problem also happens in Lion and < 10.6), your MATLAB should stop working correctly after a Java update that occurred in June. Well, Java.

The problem lies with a bug packed in the Java Security Update released by Apple. For some reason, the corresponding fix isn’t automatically downloaded by the App Store, so we must do it manually1. This bug interferes with MATLAB’s graphical user interface, making it unusable.

It’s pretty easy: go to support.apple.com/kb/DL1572 and download the update. Then, just install and open MATLAB.

Another “solution” is to run MATLAB without its GUI by using:

Where $MATLAB is the installation directory, for example in /Applications/MATLAB_R2009b.app/.

Moral: don’t leave some computer-based homework for the last day when it depends on Java.

  1. http://www.mathworks.com/matlabcentral/answers/79489#answer_89629

On the verge of procrastination

Procrastination is… jumping from an idea to another.
Johnny Kelly

I’m currently procrastinating. And it hurts, much more than it should.

This post is the result of my shallow research on the topic of procrastination mixed with the desire to avoid doing something else (like writing my dissertation).

Counterproductive, needless and delaying tasks

This triad of adjectives is the constant companion of college students. You try to focus, but an invincible foe keeps pushing you against a wall. Nothing works. You realize you should’ve studied more for that test, and to all the other ones you had since your freshman year.

Inside this whirlpool, you begin to wonder why you were allowed to continue. And then you get anxious because the job market is fucked up and no one is there to help you besides yourself. Competition against your peers. Mostly unfinished tasks multiply. And you miss your first deadline, then you have to talk to a bad mooded professor without a drop of consideration.

Finally, you begin to do something entirely different. Facebook, Twitter, Tumblr — those islands of pure ego — or anything else, really, in order to avoid what you ought to do. At this stage you’re writing lists, large lists, gigantic lists, and then you realize none of them is going to get completed. Ever. And panic strikes.

You feel weak. Now you’ve graduated, and no better situation awaits. Your naïve notion of perfectionism attained nothing but frustration and sleepless nights.

What should you do?

Some researchers1 suggest that counterproductive, needless and delaying tasks are the necessary and sufficient conditions to categorize some comportament as procrastination. I disagree. Sometimes, it’s necessary to “procrastinate” (by doing these tasks) in order to create interesting things. So, when is it bad?

Misery

A common attribute among procrastinators is perfectionism.

Generally, one is taken as a perfectionist if s/he “tries to do everything right”. A more descriptive set of variables3 include: high standards, orderliness and discrepancy between her/his achievements and standards. The last item is mostly responsible for the problems attributed to perfectionism.

In fact, people who rate high on our discrepancy scale also rate high on scales measuring depression, shame, anxiety, and other negative psychological states.

Robert B. Slaney3

So the troubling situation is if you want to achieve more but can’t actually do it. Then you begin to realize that if you do nothing until the last minute, you won’t be blamed for not having skills, but for being lazy. And you begin thinking this is alright. “I feel more productive doing it the night before, overloaded with coffee”. As far as coping mechanisms goes, this is bullshit.

Can someone escape from this spiral after entering it? Or s/he is condemned to a life of self-hatred, unsatisfied in every waking hour? That’s… a good question. The answer might be in identifying what kind of “mindset” typically generates procrastination.

Losing yourself in doubts

With important and potentially negative outcomes linked to procrastination, why would a student choose to procrastinate?

Jeannetta G. Williams et al2

I and most of the procrastinators I know of are students, so restricting this discussion to this group isn’t so bad an assumption. (as a matter of fact, we’re pretty good at it).

There are two opposite mindsets2, each very (negative or positively) correlated with procrastination tendency. The first, called mastery-oriented, is defined by a strong desire of learning for its own sake, unconcerned with grades. The second, performance-oriented, is marked by studying to “win”, as the name implies. The latter is obviously much more afraid of failing than the former.

This situation is unsustainable. Getting anxious over the fact — an immutable one, considering a student — that you won’t understand or be good at something is painful.

Another problematic factor is the “big push effect” before a deadline: if you have a semester to do it, why the heck did you wait until the last week?! Coffee, awful nights and a constant fear of not being able to finish, all this due to some afternoons and nights on the Internet, doing nothing.

On the other hand, doing things for their intrinsic value is so much better that there’s a whole area of research devoted to it — the so-called [Optimal Experience or simply Flow](http://en.wikipedia.org/wiki/Flow_(psychology).

Conclusion

My first impulse to write this article appeared right after I finished “What are BLAS and LAPACK“. Considering that I still have to write lots of things for my senior dissertation, I was procrastinating by writing about procrastination. Wonderful.

I don’t have much to say before turning this into an autobiographic “I was a much worse procrastinator, now I’m just an average one!” or a self-help post. However, I’ve learned a good deal about the subject and it might be useful in some parts of my work. I hope you learned something as well.

During my research, one of the best resources I found was the video below. While not scientific, its rhythm, images and words are stunning.

Procrastination from Johnny Kelly on Vimeo.

It’s unsettlingly precise.

References

  1. Schraw, Gregory; Wadkins, Theresa; Olafson, Lori. Doing the things we do: A grounded theory of academic procrastination. Journal of Educational Psychology, Vol 99(1). link.
  2. Jeannetta G. Williams et al. Start Today or the Very Last Day? The Relationships Among Self-Compassion, Motivation, and Procrastination. American Journal of Psychological Research, Volume 4, Number 1. October 20, 2008. link
  3. McGarvey, Jason. The Almost Perfect Definition. Seen on 08/24/2013. link.

: http://vimeo.com/9553205

Starting my final project

When I entered the Polytechnic School in Brazil, back in 2009, I didn’t have a good idea of what an “engineer” was. I just wanted to learn more things and somehow work with mathematics, my favourite subject in high school.

After 3 years and a half studying there and almost a year here in the US, lots of things have changed. I chose control engineering as my major, I learned how to program and was exposed to (sometimes tortured by) various other subjects.

I will have two more semesters before graduation when I come back to Brazil, but only if my final project is done by July/14. So I should start it now if I don’t want to wait for December/14 to finish college.

Continue reading

Dealing with pet projects

Too many pet projects. Too many scraps of paper with “to do” written over them. A damn problem that affects almost every programmer I know.

I know it sounds lame, but I decided to be more productive during 2013. Some problems I realized I have, after meditating about the subject:

  • A desire to start implementing new ideas, but rarely leaving them at a “good enough” state (“it does everything I need it to do”).
  • The objectives, problems and ideas for each project tend to get dispersed among pieces of paper, notes on my cellphone/laptop and ideas in my head (that are usually forgotten).
  • A lack of a clear “path” to achieve the proposed objective.
  • The scope of each project tend to get out of control or too ambitious.
  • I hardly ever throw away an idea, except when I find a better one.

Continue reading

Chegando na ERAU

Tentarei contar como foram minhas experiências na Embry-Riddle Aeronautical University (ERAU), desde a hora que saí do Brasil até agora.

New York

Viajei de São Paulo para New York no dia 12/08. Foi uma viagem demorada, cansativa e estressante. Depois de uma madrugada absurdamente estressante graças à problemas com minha passagem, tive o desprazer de uma viagem de 10 horas entre o aeroporto de Guarulhos e o JFK Airport. E mais algumas horas entre pegar uma shuttle com um motorista muito mal-educado e chegar ao hotel.

Eu e minha mãe fizemos check-in e saí para comprar algo no McDonald’s. O primeiro choque: como diabos pedir “só o lanche” em inglês? Depois de apanhar um pouco e passar por turista burro, voltei com os lanches para o hotel e conseguimos dormir.

Pokémon Center

A semana que passei em NY foi bem tranquila, tendo visitado o Central Park e um monte de lojas, inclusive a Nintendo World Store (que é linda ;_;). Comprei bastante coisa, como um iPad na Apple Store da 5th Avenue e alguns jogos.

Plushies do Pokémon Center

Plushies do Pokémon Center

Um momento bastante memorável foi quando perguntei o preço do passeio pelo Central Park em uma espécie de carruagem movida a bicicleta (“pedicab”) e o rapaz falou “Parlez-vous français?” (Você fala francês?).

Viagem para o Arizona

No domingo, 19/08, vim para a ERAU. Mais uma viagem estressante. Quando fui comprar a passagem na American Airlines (que é uma companhia, no mínimo, ruim), minha bagagem estava acima do peso máximo. Depois de ficar uns bons 15 minutos atrasando a fila desesperado, pensando em como diabos ia comprar outra mala no aeroporto sem me atrasar horrores para chegar no Arizona, o funcionário olhou meu passaporte e viu que eu sou brasileiro – e me deixou passar.

Cheguei no Sky Harbor, o aeroporto de Phoenix. Comprei uma passagem da ShuttleU para a ERAU e esperei no lado de fora, onde pude entender uma frase que ouvi algumas vezes por aqui: “Quando o sol está cansado, ele descansa em Phoenix”. Esta cidade parece um forno. Mas a shuttle chegou rapidamente, ao menos.

Chegando na ERAU

Já no campus, fiz o check-in no meu dormitório com a ajuda dos brasileiros que estavam por aqui. Estava uma bagunça: pratos de comida sujos na pia do banheiro, tralha por todo canto, muito lixo no carpete, tudo. Consegui tomar banho e ajeitar o lugar, ao menos.

No resto da semana vieram outros brasileiros para cá e tivemos a chance de conhecer melhor o campus, assistir algumas palestras (chatas) e abrir conta no banco. Abaixo, algumas fotos que julguei interessantes. São as vistas, respectivamente, do meu quarto e da biblioteca do campus.

Vista do meu quarto

Vista da biblioteca

Agora

Minhas aulas começaram nesta semana. Faço as seguintes matérias:

  • Real-time Systems
  • Microprocessor Systems
  • Microprocessor Systems Lab
  • Programming in Ada
  • Digital Photography

Acabei largando a matéria que tinham me inscrito inicialmente, Intro to Discrete Structures, pois é equivalente a uma matéria que fiz na Poli. Exatamente igual, ao menos em conteúdo. Peguei essa matéria sobre fotografia no lugar – veremos se foi uma boa ideia.

Pretendo escrever mais sobre as experiências aqui, se se mostrarem interessantes. Até breve. :)