Posts

Showing posts from March 18, 2012

your regex brain

Image

Emacs Grep Command and Unix Shell Quote Escape Pain

calling emacs's grep command have always been painful. i want grep with this regex height="[0-9]+">.When calling emacs's grep command, i tried: grep -ie -nH 'height\=\"[0\-9]\+\">' *html and many variations with the backslash in different places, double backslash, single/double quotes. No go.also, never really figured out the differences or semantics of single/double quote of unix shell.this is char escaping fucked up to umpteenth level!sure, one day, i could sit down and really figure it out (AND TRY TO REMEMBER IT (as am sure i've done this before)), then, sit down and figure out how emacs pass string to shell, but usually after 5 min of failures with trial & error, i switch to a short perl/python/elisp script that gets my job done.btw, in {Perl, Python, PHP}, it's all relative simple. In elisp, it's more complex, and more cumbersome. I think elisp regex char escape situation is still easier to understand than unix shell, but po…

Twitter Conversation Spam Farm

Image
Current twitter spam technique: find conversations and spam the shit out of it.twitter coversation spam ipaddep 2012-03-24Right now, they are spamming at a rate at least 20 spam per 30 seconds. (estimate based on twitter's search and auto-refresh)A Egregious Case of Twitter SpamMachine Generated Spamcomp.lang.lisp is 95% SpamWhere Do Spammers Came From? (A Xah Story of Human Animals)Spy vs Spy: Tech Geekers vs SpammersWorld Multiconference on Systemics, Cybernetics and Informatics???

Who's a Professional Programer?

got a stupid comment at How To Send HTML Mail With PHPQuote of the entire comment:my error:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/a9904100/public_html/register.php on line 89line 89? My code is only 31 lines.what possible programer idiot posts comment like this? I know! Majority of professional programers are like that. Professional programer means anyone who makes a living by coding. Unfortunately, to the tech geekers we see slaving in {emacs, perl, python, lisp, …} newsgroups and {hackernews, reddit/prog, slashdot, …} forums, they don't know this fact, and they sing their songs in their batcave about what emacs/software/language/interface should be. When you turn the mirror around, you can see that they, are just idiots of a different color.

Emacs: New HTML5 Tag Set for Yasnippet

Image
Here's yasnippet bundle for complete set html5 tags, and html5 tags only. (➲ HTML5 Tags) I've been using them for a year now. Download at Source code.google.com.For svn users, you can do: svn checkout http://ergoemacs.googlecode.com/svn/trunk/packages/yasnippet-0.6.1c/snippets/text-mode/html-mode (thanks to John Kitchin)If you enjoyed my work, a donation is much appreciated. Question: Google Code supports {svn, mercury} too. I'd be interested to know what's the syntax to download a subdir. Thanks.

List of HTML Self-Closing Tags

Perm URL with updates: http://xahlee.org/js/html5_non-closing_tag.html, 2012-03-23This page is a list of HTML elements that does not have a closing tag. They are sometimes called {self-closing, empty, void, singleton} tag. Here's a complete list for HTML5: <area /> <base /> <br /> <col /> <command /> <embed /> <hr /> <img /> <input /> <keygen /> <link /> <meta /> <param /> <source /> <track /> <wbr /> The space before the slash is optional.Is the Ending Slash Optional?HTML5: the slash is optional.HTML4: the slash is technically invalid. However, it's accepted by W3C's HTML validator.XHTML: The slash is REQUIRED.I'd recommend to always add the slash. Because, it provides a visual clue of non-closing tags. It's also technically superior, because if you write scripts to check your HTML, you don't need a lookup table to check which tags doesn't need to be clos…

Working with HTML/CSS Colors in Emacs

Perm URL with updates: http://xahlee.org/emacs/emacs_CSS_colors.htmlAm quite annoyed that the colors shown by list-colors-display is not compatible with CSS colors. In emacs, you can call list-colors-display. It'll display X11 color names with its hex values, with the text colored. Very convenient if you work with HTML/CSS. However, the color names is not compatible with the 16 basic CSS colors.For example, in CSS, there's a color named “silver” with hex value #c0c0c0. But in emacs, there's no such name nor such value. Here's a list of CSS colors.Basic CSS ColorsCSS NameCSS ValueWhite■#FFFFFFSilver ◇■#C0C0C0 ◇Gray ◇■#808080 ◇Black■#000000Red■#FF0000Maroon ◆■#800000 ◇Yellow ◇■#FFFF00Olive ◇■#808000 ◇Lime ◇■#00FF00 ◆Green ◆■#008000 ◇Aqua ◇■#00FFFF ◆Teal ◇■#008080 ◇Blue■#0000FFNavy■#000080Fuchsia ◇■#FF00FF ◆Purple ◆■#800080 ◇ Those with a “◇” means it's NOT in emacs's list-colors-display. Those with “◆” means it's got different value in emacs. (GNU Emacs 24.0.…

Computer Keyboard: Function Keys as Rubber Buttons

Image
you know how some keyboard have button-style function keys? Look at this pic:Imagine typing on this keyboard. Here's another one: Worst example of function keys. ① Continuous row, no group-gap. ② hard-to-press cheap buttons. Kinesis keyboard function keys. img srcMoral: don't buy keyboard that has the {F1, …, F12} keys in non-standard shape or form. The worst offender here is the Kinesis Contoured Keyboard. Computer Keyboard: What Are F1 … F12 Keys Used For? Increase Productivity Using Function KeysKeyboard Shortcut Design: Dedicated keys, Special Buttons, Extra KeysPC Keyboard Modifier Keys (A Short Survey)Keyboard Evolution: Zoom Button, Dedicated Keys

Emacs Keys Summery: M-x, C-x, C-c

emacs keys are often confusing to beginners. Here's a summery.【Alt+x】 is to call a command by name.【Ctrl+‹letter›】 is for frequently used editing commands. e.g. cursor movement, Paste C-y, mark C-SPC, Cancel C-g, Search C-s, ….【Alt+‹letter›】 is for somewhat less frequently used operations, often complement to Ctrl. e.g. move by words {M-f, M-b}, Copy M-w, comment-dwimM-;, ….【Ctrl+x …】 is for commands that are useful globally. e.g. diredC-x d, “switch-buffer” C-x b, string-rectangleC-x r t, bookmark-bmenu-listC-x r l, …. 【Ctrl+c …】 is for major-mode specific commands. e.g. in org-mode, C-c . inserts date.【Ctrl+h …】 is for help. e.g. describe-functionC-h f, apropos-commandC-h a, infoC-h i.【Ctrl+Alt+…】 is for lisp coding related commands. e.g. backward-sexp<C-M-left>.Note 【Alt+x】 is technically 【Meta+x】, ususually written as “M-x”. “Meta” is a physical key on lisp machine keyboards. If you are on a text terminal, and no Meta remapping has been setup, you can type 【Meta+x】 by …

The White Savior Industrial Complex

Recently, i've been thinking of a name for a phenomenon. I just found the proper term.The White Savior Industrial Complex2012-03-21 By Teju Cole. @ Source www.theatlantic.comFrom Sachs to Kristof to Invisible Children to TED, the fastest growth industry in the US is the White Savior Industrial Complex.The white savior supports brutal policies in the morning, founds charities in the afternoon, and receives awards in the evening.The banality of evil transmutes into the banality of sentimentality. The world is nothing but a problem to be solved by enthusiasm.This world exists simply to satisfy the needs--including, importantly, the sentimental needs--of white people and Oprah.The White Savior Industrial Complex is not about justice. It is about having a big emotional experience that validates privilege.Feverish worry over that awful African warlord. But close to 1.5 million Iraqis died from an American war of choice. Worry about that.I deeply respect American sentimentality, the way …

What is Closure?!?

Screen Density and Web Design Problems

Perm URL with updates: http://xahlee.org/js/web_design_screen_density.html, 2012-03-20Screen density is getting higher and higher. In the 1990s, CRT monitors from Apple Computers Inc is standardized at 72 ppi (pixels per inch), which became a de facto standard for desktop publishing (Apple started this field). But since ~2000, LCD replaced CRT, then came laptops, and now smart phones and tablets are more popular than desktop PCs. The iPad 3 has a density of 264 PPI. (See: iPad, iPhone, Kindle, Xoom: Pixel Dimension, Resolution, Density.)This creates a problem for web designs. In html and CSS, there are 3 types of units for length:Physical: cm centimeter, mm millimeter, in (inch), pt (point = 1/72 inch), pc (pica = 12/72 inch)Pixel: px.Relative: % percent, ex (letter x of the font used of current element), em (current font height)Physical unit is entirely useless. The problem with physical length such as centimeter is that usually the browser doesn't know the density of you…

Fuck Python. Hello Ruby

Background: coding perl in a day job 1998 to 2002. Learned python in ~2004. Hated perl for its unix drivel and Larry Wall snake oiling shit. (See: Larry Wall and Cults.) I thought python is antidote to perl's ways. It turns out, python is a cult of a different kind. But worse, it is actively anti functional programing. So, if your coding habit is FP, it's a pain in the ass in python. In fact, worse than Perl. Also, python doc is actually WORSE than perl in practice, despite that perl's is intentionally littered with drivels and obfuscations.Been smelling ruby since the ~2008 Ruby On Rails shit. Heard great things about it from people i trust. But resisted learning it, because i don't plan to spend another few years to learn something that is really the same as perl and python. Plus, ruby didn't support unicode.but now, since i love langs so much, i don't see reason not to. Latest Ruby support Unicode well now. Never learned much of Python anyway, other than wri…

Unicode Characters for Centimeter

Discovered special Unicode chars for Centimeter = cm = cm² = cm³Note: cm is used a lot in Taiwan, but not in USA. In USA, if metric length is used at all, it's more common to see millimeter (mm).Is cm used in other Asian countries? (China, Hong Kong, Japan, South Asia, India, …) Also, what about Europe? cm or mm?Sample Unicode Characters

2 Articles on the Problems of EmacsWiki

Die EmacsWiki, Die!2012-03-20 By Bozhidar Batsov. @ Source batsov.com [Bozhidar Batsov wrote “emacs prelude”, a set of emacs packages for emacs beginners]Problems of EmacswikiNote: Emacswiki was great, it served its time, helped people tremendously, but now it might be good time to change, since lots has changed in past 7 years since it started.If you feel the same, please send a kind notice to Alex. He might be convinced now. Also, Alex was kind enough to license the whole thing as open source. He has mentioned that he doesn't mind if people mirror or start another wiki. So, if you are ambitious, you can start a fresh one.

Xah Emacs Tutorial News: Some Article Updates, and Thank You

Emacs Lisp: Writing a Custom HTML Link FunctionEmacs Lisp: Writing a Date Time String Parsing FunctionIn past months, Jon Snader (jcs) (irreal.org) has gone thru my elisp tutorial and corrected many errors and given me feedback. I really like to say a big thank you to Jon here. Thank you Jon.Also, i have now and then received donations from people, with encouraging words. Recently got one from a professor from a well-known university. I really like to thank you guys. Some of you sent donation but i know that some are buried in my email that i have not replied. I just want to say here Thank You, whoever may be reading this. I will continue working on the emacs tutorial and ErgoEmacs as usual. Many elisp topics, such as emacs's font system, buffer/frame system, display system, i yet have to explore and write about. Thank you all for the support. And thank you for reading.

A Tale of Hackery: Keyboards with Numberic Keypad Sawed Off

Image
Perm URL with updates: http://xahlee.org/kbd/keyboard_with_numpad_cutoff.htmlMany programers find the numeric keypad annoying, because it forces the mouse to be placed far to the right, making the right arm traveling a big distance whenever switching between keyboard and mouse.A friend was asking about keyboard without the number pad. After text messaging on Facebook to and pro in a day showing links to some such keyboard, then, next thing i knew, he saw'd off his keyboard!Here's the pics:Thanks to David Rogoff for the pics and this tale of hackery.but folks, DON'T DO THIS to Your Keyboard! A perfect Gaming Keyboard is now ruined. How do you feel if your keyboard wants to saw off your arm?The number pad is actually quite useful if you are a programer.They provide 17 extra function keys. (See: Increase Productivity Using Function KeysWhy Dedicated keys are better than key combo) I use it heavily, especially in emacs. (for example, to open my bookmarks, i press 7 on nump…

Tip for Parallel Programing: Always Use Map When Possible

always use “map” whenever possible. Use loops (e.g. “for”, “while”, “do”) only if absolutely necessary (i.e. when you actually need to work on the items one by one in order.)See: Guy Steele on Parallel Programing: Get rid of cons!

Keyboards Without Number Pads

Image
Perm URL with updates: http://xahlee.org/kbd/keyboard_no_numpad.htmlSome collection of keyboard without numeric keypad. The list is ordered roughly starting with the best ones.Filco Majestouch-2, TenkeylessLinear Key Action“Filco Ninja Majestouch-2 Tenkeyless NKR Linear Action”, Model: “FKBN87ML/EFB2”. amazonNotice, the key labels are printed in front of the keys. Nice touch! This way, the key labels won't wear away (and they don't have to use other more expensive tech for key labeling such as laser-etching.) This “linear action” means the keys are suitable for gaming. That is, no “click”, so you can press fire button rapidly. They use Cherry MX Black mechanical key switches. (See: Guide to Computer Keyboard Key Switch Mechanisms.)This keyboard also features true N-key rollover. (meaning, you can press many keys simultaneously and it'll work correctly.) (See: Keyboard Ghosting & N-key Rollover: How Many Keys Your Keyboard Can Take?)The company Filco is known among keyboard…

Google Plus Page Account: How to View a Post in Your Personal Account

if you are running g+ pages, often you see a interesting post and you want to comment/share, but you want to do that with your personal account, not your page account. How to do that?Copy the URL, e.g. https://plus.google.com/b/113859563190964307534/113666291948192249820/posts/dLAu3fiKbKv remove the first sequence of digits, to get https://plus.google.com/b/113666291948192249820/posts/dLAu3fiKbKv Paste in a new tab. That's it.