2010-03-28
Programming Fonts
I've been on the search for a good programming font recently. Can't really find one I like, but I'm picky, so this is to be expected. Along the way I've noticed the ridiculous amount of people who code in... proportional fonts. This kinda blows my mind. I've messed around with this as a joke before in notepad or what have you, but serious coding in a proportional font is so silly. Proportional fonts are terrible at making similar looking characters look different enough. For example, take this piece of C code: b = 42l; It is critical here that lowercase L looks entirely different than the number 1, else the meaning of this line is completely different. I've come to realize I need a sufficiently wide font. Some coding fonts are basically straight up and down. This is really tough on my eyes. I've also noticed that I desire a good distance between lines. Too many fonts don't account for this and thus each line is stacked straight on top of the one below it. This gives me a headache. Sometimes I like anti-aliasing, sometimes I don't. It really just depends on the font. Sometimes it ends up looking way too blurry, which is obnoxious. Then again, sometimes pixel fonts look way too pixely. I really like a lot of pixel fonts, especially profont, but I find myself wanting larger sizes than they offer. Perhaps I'll spend some time making a large-ish sized pixel font that fits my needs. I need a fun way to kill some time because Lost Odyssey is being really boring at the moment.
Labels:
antialiasing,
blur,
c,
code,
coding,
font,
fonts,
pixel,
pixel font,
pixel fonts,
proportional,
proportional font,
proportional fonts,
typography
2009-12-05
Haskell: Left to Right, Top to Bottom
Look at the following Haskell code:
Simply add this code:
With this, we can rewrite the nested function calls before in a much more Ruby like manner, with a pipeline:
EDIT:
After using this further I realized that you would also want an additional operator: (-->). This operator would compose functions backwards, since (==>) applies functions backwards. This is needed for map simplifications like
-- Too many parens
a = sum (take 100 (cycle [1 .. 10]))
-- Avarice
b = sum $ take 100 $ cycle [1 .. 10]
-- Points free
c = (sum . take 100 . cycle) [1 .. 10]
c' = (sum .
take 100 .
cycle) [1 .. 10]
They all read right to left, except c' which reads bottom to top. As an English speaker, this is the opposite of what I want in my code. Ruby, for one, fixes this problem. Consider the following snippets:
# The Ruby Way
(1 .. 10).cycle.take(100).inject(&:+)
-- Haskell
foldl1 (+) (take 100 (cycle [1..10]))
-- or
sum (take 100 (cycle [1..10]))
Notice how in Ruby you simply read left to right, whereas in Haskell you find the innermost part of the expression and then read towards the left. Solving this problem in Haskell was actually a lot easier than I expected because of Haskell's freedom to define your own binary operators.Simply add this code:
x ==> f = f x
or(==>) = flip ($)
depending on which one floats your boat more.With this, we can rewrite the nested function calls before in a much more Ruby like manner, with a pipeline:
[1 .. 10] ==> cycle ==> take 100 ==> sum
This generalizes to multi-line expressions nicely too:
sayB = "Brian"
==> map (:[])
==> reverse
==> map (++ "\n")
==> tail
==> head
==> putStr
You read that entire piece of code left to right, top to bottom, as you would expect.EDIT:
After using this further I realized that you would also want an additional operator: (-->). This operator would compose functions backwards, since (==>) applies functions backwards. This is needed for map simplifications like
[1 .. 10] ==> map (1/) ==> map negate
-- ...becoming...
[1 .. 10] ==> map ((1/) --> negate)
2009-11-28
BlazBlue
I just got back from a good evening of BlazBlueing with my friend. Game is so awesome. I can't wait for BlazBlue: Continuum Shift. Hakumen + Bang for life.
Labels:
360,
arcade stick,
Bang,
Bang Shishigami,
BlazBlue,
Haku-Men,
Hakumen,
Tager
2009-11-22
Ever wanted those toolbox windows in GIMP to skip your taskbar? This is the relevant section in
openbox/rc.xml. <application name="gimp" class="Gimp" role="gimp-toolbox">
<skip_taskbar>yes</skip_taskbar>
<skip_pager>yes</skip_pager>
</application>
<application name="gimp" class="Gimp" role="gimp-dock">
<skip_taskbar>yes</skip_taskbar>
<skip_pager>yes</skip_pager>
</application>
Labels:
GIMP,
Linux,
openbox,
window manager
2009-11-08
Java Bitshifting Wtfery
In Ruby the following two expressions are equivalent:
However, in Java, the first one evaluates to zero. This was a very odd bug in a particular program I was writing.
It just seems to me that shifting right by a negative value should by equivalent to shifting left by its absolute value, but strangely Java thinks that should not be the case. It may be worth noting that in Python, shifting by a negative amount results in an exception being thrown.
and evaluate to eight.1 >> -31 << 3
However, in Java, the first one evaluates to zero. This was a very odd bug in a particular program I was writing.
It just seems to me that shifting right by a negative value should by equivalent to shifting left by its absolute value, but strangely Java thinks that should not be the case. It may be worth noting that in Python, shifting by a negative amount results in an exception being thrown.
Labels:
bit munging,
bit shifting,
bit twiddling,
bitshifting,
bug,
java,
python,
ruby
2009-11-04
Programming Language Naming Conventions
Ever wanted a reason not to use C-style identifiers? You know, strlen, strncpy, and the like?
Well consider a predicate function that determines whether something is hit or not.
Here are the identifiers in various naming conventions.
Ruby:
Lower case with underscores:
Camel:
Microsoft style:
C style:
Notice the problem with the last one... such a problem exists for the predicate function asking whether something "is in," though it's much less vulgar (obviously, this is
Well consider a predicate function that determines whether something is hit or not.
Here are the identifiers in various naming conventions.
Ruby:
is_hit?Lower case with underscores:
is_hitCamel:
isHitMicrosoft style:
IsHitC style:
ishitNotice the problem with the last one... such a problem exists for the predicate function asking whether something "is in," though it's much less vulgar (obviously, this is
isin in C style).
2009-06-12
Partitioning NTFS Made Easy
Today I was trying to install Linux on my friend's computer. GParted sometimes really sucks at resizing NTFS. It failed three times here. After digging through the internet for a while I came across
diskmgmt.msc. All you need to do is press Win+R then type diskmgmt.msc and press Enter, or choose Run from the start menu, type diskmgmt.msc, and press Enter. This program seems to flawlessly resize NTFS (while the OS is booted, amazingly). Now I am about to partition the rest of the drive. Hooray.
Labels:
gparted,
install,
Linux,
ntfs,
ntfsresize,
partition,
partition magic,
resize,
shrink
Subscribe to:
Posts (Atom)