Posts

Showing posts from October 24, 2010

Using Javascript to Insert Javascript Based Widget

Perm url with updates: http://xahlee.org/js/js_insert_js_code.htmlAsynchronous Javascript; Using Javascript to Insert JavascriptXah Lee, 2010-10-30This page shows you how to use javascript (js) to insert a html that contains js code and have that js code run. If you don't know how to insert a element using js, see: Adding HTML Content with Javascript. The ProblemThere are lots js based widgets today. For example, web share widget, Google search widget, Comment widget, twitter, facebook, amazon ads... etc. They let you easily add functionality to your site.If your webpage is static html, or generated by php or content manager software, you can directly include these widgets at the right place at the server side. However, sometimes it is convenient to use a js to insert them. Because, you may want the location of the widget to be different for different pages. Or, only centain pages you want to include the widget, but you don't know which until the page is generated.So, the sol…

Do you want a emacs cookbook?

Recently, a new lisp book came out: LAND OF LISP (Book and Comics).My emacs tutorial and elisp tutorial is sizable for a book. There's no emacs cookbook or elisp cookbook on the market. To turn it into a book, it probably will take half a year at least to add content, convert html to a format suitable for print, as well as a lot work to improve quality. If i write a emacs book, are you likely to buy it?Yes, if it's good.No, am not likely to spend money on emacs/elisp book.(Vote on the side.)

emacs javascript template

Does anyone know a emacs template for javascript?In particular, am looking for template for either YASnippet or AutoComplete.one minute google or emacswiki search didn't find anything.(am already using both js2-mode and js-mode (espresso mode), they don't appear to have name completion or template builtin.

TRON Light Cycle Optimal Stradgy

Image
Perm url with updates: http://xahlee.org/math/tron_light_cycle.htmlTRON Light Cycle Optimal StradgyXah Recommends:

Amazon Kindle. Read books under the sun. Review Xah Lee, 2010-10-29Has anyone done research about the opitmal strategy for the TRON's light cycle?Tron lightcycles We assume it as a perfect-info mathematical game, on a n×n square grid. (think of the board in Go (game).) Suppose the cycles are red and blue. Red moves first. Each turn, the player moves one square edge. The first player that doesn't have legal move loses. Also, we suppose it's a board game, and both players knows the other's position exactly at all times. We also for now assume that the starting position is at the opposite corners of the board.2×2. Second player win.3×3. First player win.4×4. Second player win.5×5. First player win.The pattern seems clear. On Odd boards (where there's a center spot), first player win. On even boards, second player win.Now, if we assume that the starting pos…

Javascript Encode URL, Escape String

Image
Perm url with updates: http://xahlee.org/js/js_encode_url.htmlJavascript Encode URL, Escape StringXah Recommends:

Amazon Kindle. Read books under the sun. Review Xah Lee, 2010-10-29This pages shows you how to use javascript to do percent encoding for URI.There are these js functions to do encoding and decoding.encodeURI, decodeURIencodeURIComponent, decodeURIComponentescape, unescapeencodeURI and encodeURIComponentencodeURI and encodeURIComponent are used for encode a URI. The difference is that encodeURIComponent will also encode the “http://” part. Here's a sample uri: http://en.wikipedia.org/wiki/Sylvester–Gallai_theorem The dash above is a en-dash, unicode 8211 (U+2013).Result: encodeURI: http://en.wikipedia.org/wiki/Sylvester%E2%80%93Gallai_theorem encodeURIComponent: http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FSylvester%E2%80%93Gallai_theorem The “%E2%80%93” are hexadecimals E2 80 93, and is the byte sequence of the en dash char by utf-8 encoding.For detail, see: Percent-encodin…

Autism Spectrum Quotient

So, i found this Autism Spectrum Quotient from Facebook.(before talking about that, here's a side story: motherfuck scumbag facebook. So, i saw this Autism Spectrum Quotient test from friend's comment. Click, and as usuall, it asks to accessing fucking info. Why the fuck is that necessary? Copy the phrase “Autism Spectrum Quotient test”, google, bang, arrive at http://www.wired.com/wired/archive/9.12/aqtest.html right there first result. No fucking require my age, sex, sexual preference fuck. (See: Facebook's Ethics.))Ok, back. Now, the test is available here: http://www.wired.com/wired/archive/9.12/aqtest.html. Here's a quote about the test:Psychologist Simon Baron-Cohen and his colleagues at Cambridge's Autism Research Centre have created the Autism-Spectrum Quotient, or AQ, as a measure of the extent of autistic traits in adults. In the first major trial using the test, the average score in the control group was 16.4. Eighty percent of those diagnosed with autis…

land of lisp

Image
Perm url with updates: http://xahlee.org/comp/land_of_lisp.htmlLAND OF LISPXah Lee, 2010-10-27Conrad Barski's book 《The Land Of Lisp》 is out! LandOfLisp.com. The site features a music video, and a comics strip. Very well done!Bug War, from landoflisp.com. Land of Lisp- The Music Video! 《Land of Lisp: Learn to Program in Lisp, One Game at a Time!》By Conrad Barski M.D. amazonSpread the news, team lisp!Conrad Barski's “alien technology” lisp web-badge Source. Xah's Emacs Lisp TutorialA Lambda Logo TourLISP LogoLisp Needs A LogoLisp Macros and Practical Common Lisp (rant)

Google is evil; Apple is a monopoly; and Microsoft is the underdog

Recently this tweet has been going around:Welcome to 2010: Java is a restricted platform; Google is evil; Apple is a monopoly; and Microsoft is the underdog.who first said it?

3 Twitter Facts You'll Never Forget

Image
Perm url with updates: http://xahlee.org/js/twitter_make_money_fast.html3 Twitter Facts You'll Never ForgetXah Recommends:

Amazon Kindle. Read books under the sun. Review Xah Lee, 2010-10-26New twitter realizations.Mutual FollowingThose with huge but about equal number following/followers, means they just do mutual follow. Actual readership is probably near 0. Most these are i think are “seo” shit. They get 10k followers to brag on their website.There are 100M twitter accounts. Suppose 1% of twitter population are these mutual followers. Then, we have 1M accounts who all having about 1M followers. (M = mega = million) That's why we see so much sites bragging huge twitter followers.Anyone who follows more than 100 probably isn't reading any of it. Suppose someone follows 100 accounts. Suppose each of these has 1 tweet with link per day. That's 100 links. I think it's safe to say that 90% of those who follows more than 100 twitter accounts only click on 1% of the links…

Why Do I Not Support the “Human Right” Concept?

Image
Perm url with updates: http://xahlee.org/Periodic_dosage_dir/human_rights.htmlWhy Do I Not Support the “Human Right” Concept?Xah Lee, 2010-10-11Criticisms On “Human Rights”For criticisms of “universal human rights”, i guess the topic is old. But Wikipedia provides some starting points if you are not already familiar with thisHuman rights#Critiques of human rightsUniversal human rights#DebateMaster-slave moralityNihilismNatural slavery(i don't necessarily agree with the above in particulars... but am just citing well-established philosophies against the universal “human rights” concept) Here's some selected quotes from different parts of Wikipedia:Philosophers who have criticized the concept of human rights include Jeremy Bentham, Edmund Burke, Friedrich Nietzsche and Karl Marx[citation needed]. A recent critique has been advanced by Charles Blattberg in his essay "The Ironic Tragedy of Human Rights." Blattberg argues that rights talk, being abstract, demotivates peo…

Torture Porn and Stupid Morality; Saw VI Review

Image
Perm url with updates: http://xahlee.org/Periodic_dosage_dir/t1/saw.htmlThe Art of Torture: a Photographic TourXah Lee, 2006-10, ..., 2010-08-14Shotgun collar. Jaw-splitter. This device snaps open jaws, set to a timer. Ice shower. Ice Shower turned sculpture. Skull Snapper. The victim is supposed to retrieve a key that were surgically placed in one of his eyes. A scalpel is provided for amenity. One-way razor wrist-trap. Chain thru body. The victim is supposed to free himself by ripping off his punctured flesh. Rib ripper. The victim is supposed to dip her hand into the acid to retrieve the key. Else, the harness that is attached to her ribs will rip her ribs apart. The aftermath. Modern Rack. The victim's limbs will be twisted beyond twistability by a mechanical force, and lastly, the neck as well. These images are screenshots or photos from the movie series Saw. (Images taken from Wikipedia)〈Sawamazon is a movie made by Americans. Its theme and central attraction, is explicit depiction…