Xah Programing Blog Archive 2013-02
Ruby's predefined global variables is not documented, but Ruby 2.0, which came out few days ago, fixed that. Ruby: List of Predefined Global Variables
updated with photos. HP-28S Advanced Scientific Calculator
linux package managers galore
discovered a linux phenomenon.
y'know, linux has package managers, ➢ for example: apt-get, yum, pacman.
now, that's heaven. Search, install, done. No compilation and potentially hours reading README INSTALL fsck and gcc make version compatibilities. Universal, systematic.
you realize, when you get slightly deeper into Python, Ruby, etc, they don't recommend using the system's package manager. They recommend compiling yourself, or, use their own system.
Why? because the system ones are often outdated by a year or so. And when you get deep in dev, you need to manage several different setups, lib versions. So, Python has pyPM, york, and others, Perl has whachamafsck and others, ruby has rvm and others. (and ruby rvm is shell script muck on drugs)
you see, from my recent experience, it's not just one simple one per lang. It's several competing ones. You have to research and wikipedia and stackoverflow and feel the pain then settle which to use.
it's rather complex. Not trivial. ➢ for example: Ruby: What's RVM, Gem, Rake, Bundler, RDoc, ri, irb?
as another example, let's say emacs. Now, that's where i can claim knowing a thing or two. When you
apt-cache search emacs, you see tens of stuff flying by, many of them elisp packages (➢ for example: major modes). emacs modes from apt-get? LOL. Get outta here! You wanna use the one from emacs 24 instead, call “list-packages”, and use MELPA repository.
〔➤see A Guide on Emacs 24 Package System〕
AND, no, there's not just one emacs packages system, there are competing ones, even competing repositories. So, if you didn't spend years wallowing in emacs community, you wouldn't know.
how i learned to stop worrying and love the bomb…
Ducky keyboard and KeyBoardCheer keyboard!
discovered that the Ducky keyboard from Taiwan makes real quality keyboards. Check out their website.
I don't think you can easily buy it in USA though. But you might be able to buy from the company's site via shipping. (KBC is also quality.)
variable naming style: pot_hole_casing
in your code, do you prefer camelCase or under_score?
then, Christian Herenz alerted me, that this paper calls it “pot_hole_casing”. LOL!
〔Best Practices for Scientific Computing By D A Aruliah, …. @ http://arxiv.org/abs/1210.0530v1〕
thinking about it, that term makes much more sense than under_score. You see, camelCase is named visually. So, “pot_hole_casing” is a nice complement. Without visual clue, the phrase “camel case” can still convey, but “underscore” wouldn't, but “pot_hole_casing” would. Thus, it's a superior term.
small Python list tip. negative stepper starts from right
when the stepper is negative, it starts from right. ➢ for example:
list[::-1] reverses the list. (when the first index is empty, it default to 0, and when second index is empty, it defaults to the index of last item.)
# -*- coding: utf-8 -*- # Python 3 print(["a", "b", "c"][::-1]) # ['c', 'b', 'a']
thx to https://twitter.com/Ryuutei
should be fun. This problem started in elisp for me few years ago. Over the years, tried several elisp approaches… but overall i was stung twice. Few weeks ago, found a bug in my code. Rewrote it with a new algorithm thinking it's much better, but bang, another bug. That is, incorrect behavior.
Now i think i have a good solution, but still has certain limitations. So, am posting this as a fun coding problem, pulling on the talent pool.
am posting this as a general programing problem, not specific to emacs lisp. I do have a elisp solution, but can be easily translated to any other lang.
Programing Language Design: Why Lisp Macro Sucks (YMMV very much!)
I don't think this is suitable for programers, but a fun funky keyboard, with mechanical keys (Cherry MX Black).
drew the layout diagram of Happy Hacking Keyboard in SVG. The Unhappy State of the Happy Hacking Keyboard
the new lang julia is quite interesting. A order faster than most other langs. So so many langs, which you gonna choose? Proliferation of Computing Languages
found a better way to make mouse wheel accelerate in Firefox. Updated: Firefox: Set Mouse Wheel Scroll Speed
update. added a 3 video reviews. Logitech M570 Wireless Trackball
trackballs are especially nice when you turn on auto-raise. That is, you hover pointer to a window and it automatically comes to the front. You can turn this on in Microsoft Windows or Linux (but not Mac).
auto-raise is nice because it saves you lots of clicking. Once you get used to it, it's so smooth, no clicks or keystrokes.
trackball makes this even better, because when you have auto-raise on, you don't want to move the pointer unnecessarily. Trackball by nature doesn't move pointer, while with mouse, one tends to move it about.
in Ubuntu Unity, they started to have a fancy feature called “auto-click”. That is, whenever the pointer rests on a spot, it automatically do a click. So, with this, you don't even need to click on tabs, or boxes, anymore. I tried it for 5 minutes, but haven't decided i want it, because it's too easy to unintentionally click on something. You have to always find a inactive spot to rest your mouse. (does anyone know how to turn this on in xfce?)
started to read a blog titled 《Write Yourself a Haskell... in Lisp》.
wow, that's interesting. The net really got advanced geeks. I myself have written a Perl package that emulated Mathematica functions ten years ago, but it was not something to write home about, because it doesn't do parsing. It just implement some functions of Mathematica in Perl, all Perl syntax. 〔➤see Perl Module: Tree::Matica (Mathematica Tree Functions in Perl)〕
then, the second paragraph, it says:
«We're not going to bother with parsing: our input programs will be S-expressions.»
if you don't do parsing, you are skipping the hard part. And the title 《Write Yourself a Haskell... in Lisp》 becomes deceptive, or, marketing.
wrote this. validate my website Google Analytics code. 〔https://github.com/xahlee/xahscripts/blob/master/validate_website/check_google_analytics.py3〕 Too bad that github doesn't recognize the “.py3” suffix. It makes things a lot easier.
geeks and repetitive tasks
new. Python 3: Operators
for some reason, Unicode in Mac are in color. Updated with screenshots. Unicode: Food, Drink 🍕 🍌 🍰 🍺
pedobear is coming to town ᶘ ᵒᴥᵒᶅ Unicode Smilies (◔ ◡ ◔)
hot from the press. Learn Python 3 in one hour. Python 3 Basics
updated. aspell sucks: Dismal Vocabulary Size
How to auto sync X11 primary selection and its clipboard?
answer added at Linux: Commands Related to GUI Apps
Is it true that keyboards before PC have Control key right besides the A key?
What's the linux command line to put things in trash?
You can do
new page, with Microsoft mouse. Ergonomic / Vertical Mouse
note, jwz uses the Evoluent VerticalMouse. See Celebrity Programers with Repetitive Strain Injury
python3: respect of style??
2to3 converted my use of lambda to list incomprehension.
- return len(filter(lambda x: x == os.sep, os.path.abspath(d))) + return len([x for x in os.path.abspath(d) if x == os.sep])
hey, is there no respect to my style?
git force pull.
git fetch --all # get latest from remote but without merging into local git reset --hard origin/master # rid of all local state
looks like Andrew Auernheimer (aka weev) is going to jail.
He's a grey hat hacker. You can read about him at Wikipedia here Weev
he published a essay on Tech Crunch here: 〔iPad Hack Statement Of Responsibility By Andrew Auernheimer. @ http://techcrunch.com/2013/01/21/ipad-hack-statement-of-responsibility/〕
new found. Fantastic. Linux: Best Image Viewer for Random Slideshow
i wanted to know the general mechanism in Linux to associate file extension with executable (for when user clicks a icon in GUI), and i wanted to know how to do this asso by command line.
it seems there's no standard way. Here's 2 best links from helps i got.
Arch Linux documentation consistently came up the best when i had some Linux questions. I started to read about Arch Linux a bit. I like their philosophy. I think it'll be my next Linux to try.
while Ubuntu community is like …
redraw the parser diagram in Inkscape. ♥ Inkscape.
Set git to Always Color
git diff a file in staging area vs a previous commit.
git diff --color --cached a6efe85 xahlee_info/comp/blog.html
don't forget the 「--color」 part.
to make git always color in diff, do:
git config --global color.ui true
vi tip: find out what a key do
To find out what a key or key-combo does, type
:help then press the key, then Enter ↵.
this would be similar to emacs's
describe-key. 〔➤see Tips on Long Term Emacs Productivity〕
the blog i wrote few days ago about TCP/IP is now on its own page. quick random jot-downs, on TCP/IP, on Tech Writing
meanwhile, i discovered a much better book. 〔《Sams Teach Yourself TCP/IP in 24 Hours (5th Edition)》 amazon〕
the 〔《TCP/IP Illustrated, Volume 1》, 2nd edition (2011). amazon〕 is classic, but stinks of academic verbosity, hard to undersand, and the latest edition isn't well written. The Sams book is much more practical.
updated. Python: Unicode Tutorial 🐍
Is my Linux kernel 32 bits or 64 bits?
getconf -a | grep LONG_BIT
linux: xfce: show hidden files by Ctrl+h
in Linux, if you are using xfce, then the folder viewer (aka file manager) is Thunar. It doesn't have a option in preference to show hidden files (those starting with a dot). But you can show by 【Ctrl+h】
On its own page. Why Python's Lambda is Broken and Can't be Fixed
new. A much better top. Linux: Monitor Processes, “htop” Tutorial
Updated. Best Trackballs 2016