Inércia Sensorial


Dia de chuva em Águas de Lindóia

Filed under: Geral — inerte @ 11:33


Uma pena! Eu queria ter aproveitado mais o final de semana em Águas de Lindóia. Mas ano que vem tem outro aniversário de casamento!


Fotografar ou filmar o terminal

Filed under: Geral — inerte @ 21:06

Hoje no terminal da Lapa um aviso sonoro informou que não se pode fotografar ou filmar o terminal. Alguém sabe o porquê?


Vendedores ambulantes no trem de São Paulo

Filed under: Geral — inerte @ 11:58

Semana passada eu comecei a pegar diariamente o trem aqui em São Paulo. Da estação Ceasa até a Vila Olímpia, e no final do dia voltando por esse caminho. Às sextas-feiras, e ocasionalmente se perder a minha carona, o caminho é um pouco diferente. Pego o ônibus até a estação da Lapa, baldeio na Presidente Altino, e desço na Vila Olímpia mesmo.

Estranhamente durante esses dez dias eu vi poucos vendedores ambulantes, mas não tinha percebido até ontem. Um vendedor entrou no vagão, anunciando seu amendoim (R$ 0,50), e eu, sem fome ou caridade, o ignorei. Entretanto notei que na abertura das portas, ele manteve o corpo dentro e apenas pescoçou para visualizar rapidamente nos dois lados da estação, e correu até o vagão de trás.

Ali percebi que o vendedor procurou por algum segurança na plataforma, e aí caiu a ficha como não tinha visto, durante essas duas semanas, outra pessoa vendendo algo, e devem ser coibidos ativamente.


Plugin do Eclipse para editar scripts bash

Filed under: Programação — Tags: , — inerte @ 13:47

Meu projeto atual tem arquivos .php, .pm e .sh no mesmo diretório. Aos poucos fui achando os plugins para o Eclipse, e às vezes até múltiplos para a mesma linguagem de programação. E para bash, eu achei o ShellEd. Por enquanto está muito bom. Mesmo o projeto tendo sido criado para PHP, os arquivos .sh estão sendo abertos pelo ShellEd.


O infocídio de Mark Pilgrim

Filed under: Geral — inerte @ 11:16

Meu ídolo e profílico autor de sites/livros, como diveintopython[3].org e, Mark Pilgrim, aparentemente cometeu infocídio ontem. Todas as suas páginas estão retornando o cabeçalho http 410 Gone (The requested resource / is no longer available on this server and there is no forwarding address. Please remove all references to this resource), e ele também removeu as contas no Twitter e Google+. Na vida real ele está muito bem, o que me deixa muito feliz.

Mark Pilgrim


Twittando do meu novo

Filed under: 32 Dentes — Tags: — inerte @ 07:48

Mr. Gaigalas em meta-tweet achou uma pérola: tem até punchline.


Clojure script to parse IIS logs from a directory and show slowest pages

Filed under: Clojure — Tags: , — inerte @ 15:56

Just having some fun today. The code runs actually pretty fast: It reads over 1.5 million lines from 1.1GB of logs and sorts them by time-taken in 5 seconds. I bet there’s room for improvement but it was enough for my needs.

(ns iis_log
  (:require clojure.string clojure.test))
(def #^{:doc "Where the log files reside."} logs-directory "D:/userdata/jnetto/Desktop/zina_inside/W3SVC93479707")
(def #^{:doc "How many lines to show from logs."} top-to-show 25)
;; IIS log lines starting with # are comments
(defn is-not-comment?
  [^String s]
  (not= (.substring s 0 1) "#"))
(defn remove-comments
  (filter is-not-comment? file-contents))
;; Values on logs are separated by a space. Therefore, "-" is shown as a value when there is nothing there, instead of a space,
;; which would mess up the separator.
(defn nil-if-hyphen
  (if (not= s "-") s))
(defstruct token :uri :time-taken :username)
(defn relevant-line-info
  "Returns a map with the path + querystring, time-taken and username from a log line."
  (let [line-tokens (clojure.string/split line #" ")
        cs-uri-stem (nth line-tokens 6)
        cs-uri-query (nth line-tokens 7)
        cs-username (nth line-tokens 9)]
    (struct-map token :uri (str cs-uri-stem (nil-if-hyphen cs-uri-query))
                      :time-taken (read-string (nth line-tokens 20))
                      :username (nil-if-hyphen cs-username))))
(def accesses (ref []))
(doseq [child (.listFiles ( logs-directory))]
  (println "Processing" child) ;; Just for debugging purposes, to show something is happening
  (let [file-contents ( child)
        file-without-comments (remove-comments file-contents)
        tokens (map relevant-line-info file-without-comments)]
    (dosync (alter accesses concat (take top-to-show tokens))))) ;; We 'take 'top-to-show here as an optimization. If we will print
                                                                 ;; only top-to-show, why take more from each file?
;; Until here it's actually pretty fast. 'sort-by and 'reverse are actually the slowest parts of this script.
(doseq [line (take top-to-show (reverse (sort-by :time-taken @accesses)))] 
  (println line))


Pong in Clojure

Filed under: Clojure — Tags: — inerte @ 20:14

Me and Cesar Canassa decided to create a game. I suggested a roguelike, which we will build eventually, but as both newbies in game development, we are going to start small.

With Pong.

In the last couple months I have been teaching myself some Clojure, and said to Canassa I would like to try writing Pong using it. Now here’s where his personality shines: He had never written a single line of Clojure, but said “sure!”. Later on, while researching about functional programming, he mentioned how he had read in several places how one of the few areas of development where this paradigm is not recommended is… game development.

Ooops. Too late.

Beers in hands on a Saturday night, we promised to get something running. The plan didn’t go well. Our lack of Java and Clojure knowledge, and our lack of intelligence after ten beers got in the way. We managed to open a black window and draw white lines on it, but at the same time there was a sense of struggling, a fight against the language and its libraries. We were driving the car down the hill again and again.

Somehow on Sunday, Canassa created a repository on Bitbucket for Clojure Pong, and the first changesets started to roll in.

Today we finished the game. We thought about adding sound to the ball collision on racquets and walls but the game already does much more than training and learning code should do.

We are looking for criticism, specially on idiomatic Clojure. We tried to replace the usual maintaining of a “global” state in variables that is possible in other languages and paradigms, with a “game” map that flies around functions. It is a simple approach, but probably contains a lot of unnecessary overhead. Not in terms of performance, but in terms of function responsibility.

For example, the racquet collision function takes the whole game as parameter. Feels like cheating: Instead of using variables sprinkled to determine what is happening, the values are keys of “game”. It feels like we are still using state, but it is concentrated on a map structure.

But it works, and it is also probably more fun than training and learning code should be. There is a pause screen, the ball rolls slightly angled on game start and scoring, and a FPS counter.

We are going to use some of these stuff on our next project. Breakout is coming, and I will post again when we have some news.


Crowd review a resume

Filed under: Geral — inerte @ 12:00

Another one of my ideas which I won’t implement. Ever had doubts if a candidate CV/resume is a good fit for the job? Pay US$ 19.90, upload the CV to a website, and let 10 people say yes/no. I bet recruiters would love this tool.

Let me expand a little bit:

Recruiting a person with a completely different skill set than yours is hard, right? Imagine the troubles a owner of a soon-to-open delicatessen store feels when hiring a baker. Or a recruiter trying to avoid an embarrassment when forwarding a CV she’s not so sure about.

Well, why not let people who are already professionals in a field tell you if the candidate has a good curriculum vitae? Post a job description, upload/paste CVs, and receive good feedback on it.

What’s in it for the professionals? Money. One dollar per rating, maybe more if the professional has a proven track of good rating on the website. More if you tweak the paid amount and the website revenue cut. At US$ 19.90, that’s good for 10 one dollar ratings, or 5 two dollars ratings (with 10 left for the website).

Quis custodiet ipsos custodes? Apply metamoderation, and recommendation, for example CV uploaders can invite known professionals to join the website. Don’t let invited professionals rate CVs sent by people close to whoever brought them to the website. Gently remind CV uploaders to come back to the website and say if the received ratings were good.

Let professionals suggest questions to ask the candidate. Rate/metamoderate questions.

Let professionals comment on the CVs. For example: “According to the job description, I recommend the candidate knows SOX.”

Hiring is so hard I bet the 20 bucks price could be increased, for example it starts at US$ 20, but recruiters could ask for an specific professional for her opinion, whom would set her price per rate. Or +US$ for expedite ratings (in 2/6/12/24 hours). Maybe that’s too complicated for pricing, though.

If you ever build this website, let me know 🙂


memcached monitoring and statistics

Filed under: Perils of Software Development — Tags: — inerte @ 15:54

I wanted to know, overtime, how many cache hits and misses my instance was getting. Searched a lot and finally found this perl script:

Usage is very simple. Save the file, give it execution permissions, then just run:

./ –commands –cumulative

Here’s an output example: output example

Seems like I’m doing fine, caching the right parts! Hit over 80% and only half of my allocated memcached memory being used… (that’s because I had recently restarted it, so usually it keeps filled).

« Newer PostsOlder Posts »

Powered by WordPress