Posts

Showing posts from 2012

vim problems with ^M (caret M), due to file format incompatibility

The problem with ^M or caret M that you see in files during editing or modifying is that incompatibility with vim 's default file format. Usually, if I have a file edited or created in Mac OS X, and when its edited via Linux, I got ^M plus the lines are displayed as one line which is freaking hard to edit. To fix this, just do edit the file, then reload the file in vim , :e ++ff=mac or :e ++ff=unix if it was created in Unix. This will render with a great view editor of your file from what you expected it should be. According to vim's Wiki, " unix LF only (each line ends with an LF character). dos CRLF (each line ends with two characters, CR then LF). mac CR only (each line ends with a CR character). CR is  carriage return  (return cursor to left margin), which is Ctrl-M or ^M or hex 0D "   You can read for more info for file format in this page  http://vim.wikia.com/wiki/File_format

Understanding Threads and Multithreading

In this blog, I just wanna accumulate all things that I need to note regarding threads. Threads are just a light-weight process. It's actually a process but it runs under a process, literally a subsets of a process, where in this process, threads can share resources like memory. Threads in this subject is distinct from multi-core systems, which deals with instructions that are sent in the hardware resources like instruction set pass from USB to processor, stuff like that, in which multi-core can empower an OS to implement multi-threading. So multi-core is more of dealing with central processing units to execute program instructions . Multithreading aims to increase utilization of a single ore by using thread-level as well as instruction-level parallelism. As the two (multithreading in cores and threads in OS) techniques are complementary, they are sometimes combined in systems with multiple multithreading CPUs and in CPUs with multiple multithreading cores. courtesy of Wi

Programming Advice

I wanna take note on this blog  "The Best Programming Advice I Ever Got" with Andrei Alexandrescu  as I found this notably important as a programmer or developer. How about yours? What do you think a good programmer should have?

Programming Opinions - Great Blog to Read

I think this blog is cool to read 20 controversial programming opinions

Lossy Image Optimization

I have enjoyed this youtube video regarding lossy image optimization from Velocity. Hope you find this video helpful. O'Reilly Webcast: The Best of Velocity - Take it all off! Lossy Image Optimization

Coding standard in C

I got this file as such a noteworthy to read. JPL Institutional Coding Standard for the C Programming Language Hope you like it :-)

difference between Orthogonal and Isometric

I wanna note this myself so I can't forget this stuff. Orthogonal vs Isometric Via StackExchange.com or this link StackExchange Orthogonal vs Isometric Orthogonal vs Isometric via Yahoo Asnwers With regards to foreshortened, according to Wikipedia on Perspective , it means as, Foreshortened: the size of an object's dimensions along the line of sight are relatively shorter than dimensions across the line of sight

10 Reasons You're Not the Boss

I came across reading this article from Yahoo and wanted to save this as a note for myself. This is such a good article and notes to follow, IMHO.

On Multiple programming languages ?

Well, I just wanted to note from this blog  Keeping multiple programming languages straight . I found this very helpful to read, and thus he has also his notes with what he had done and contributed so far, in Open Source world. Keep on reading on his blog. It has lot to learn from what he have done so far.

MySQL: list all fields into a CSV result or set custom delimiter

So the topic here is how would you come up with listing all the fields of a table where it will output into a comma separated values? Say for example, you have a database named BILLING with a sample table name and fields below. __________________ |                 | |     CUSTOMERS         | |_________________| | name              | | address           | | username          | | password        | |_________________| and wanted to have a result of name, address, username, and password. You have to query the database supplied by default in MySQL using the DB name INFORMATION_SCHEMA and then filter the result with its table name and select only the COLUMNS field. So the query should look something like this, // set a value for the variable @table mysql > set @table='customers'; mysql> select GROUP_CONCAT(COLUMN_NAME SEPARATOR ',') from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA='BILLING' AND TABLE_NAME=@table; The r

Zend Framework: How to include directories with dash or hyphen

So before I can forgot it in Zend, I will post this as a notes and reference. When you want to include a directory with dash or hyphen (-) symbol, like for example, a helper. You can do it by using the code below.              protected function _initActionHelpers()     {            Zend_Controller_Action_HelperBroker::addPath(             APPLICATION_PATH . '/../library/dash-classes/Action/Helper/' ,             'DashClasses_Action_Helper'         );     } Where you have your helper stored in ../library/dash-classes/Action/Helper/Example.php Where your Example.php might look something as, class DashClasses_Action_Helper_Example  extends Zend_Controller_Action_Helper_Abstract {     function direct()     {         $session = new Zend_Session_Namespace( 'exampleSession' );         return $session;     } }

Converting mp4 to AVI using ffmpeg

I got this commands until it works on mine. Currently, I am running on Mac OS X Lion so, in particular, I would say this works in my part using Mac OS X Lion. $> ffmpeg -i batman.begins.mp4 -vcodec libxvid -ab 192k -sameq -acodec libmp3lame -ar 48000 -ac 2 batman-begins.avi Specifically, my choices are are need to be converted to AVI so I can put it into my USB and play via our HD TV which seemed to consistently support using this encoding or conversion. -vcodec which I use libxvid codec for my video encoding -ab        192k which, I believe, using stereo would need this bit rate. -sameq   So I got the same quantization values -acodec  so I use libmp3lame -ar          is set to 48000 audio sampling frequency -ac          is set to 2 to have a dual stereo type of audio Hope this helps.

Richest man in the valley

You know, I got this story from my e-mail a very very long time ago and still, this is the most shortest and simplest story that I like most in my entire life. Anyway, here it goes. [courtesy of MountainWings.com] Enjoy reading!!! The Richest Man In The Valley ============================= A rich landowner named Carl often rode around his vast estate so he could congratulate himself on his great wealth.  One day while riding around his estate on his favorite horse, he saw Hans, an old tenant farmer.  Hans was sitting under a tree when Carl rode by.  Hans said, "I was just thanking God for my food." Carl protested, "If that is all I had to eat, I wouldn't feel like giving thanks." Hans replied, "God has given me everything I need, and I am thankful for it." The old farmer added, "It is strange you should come by today because I had a dream last night.  In my dream a voice told me, 'The richest man in the valley will die tonight.'  I d

Partial Derivative

Image
For my notes, this is a good explanation of partial derivative is.

what is love?

Love is patient, love is kind, Love does not insist on its own way. Love bears all things, believes all things, Hopes all things, Endures all things. Love never fails - 1 Corinthians 13:4-8

Locate Downloaded Apps in Apple's App Store

Image
1. Open Terminal 2. Enter defaults write com.apple.appstore ShowDebugMenu -bool true 3. Open AppStore Application 4. Choose the menu item Debug Menu -> Show Download Folder Then you can check here where's the downloaded files are located.

Dijkstra's Algorithm

Image
I found this great tutorial in youtube under Creative Commons Attribution 2.5 Canada License. This one too is helpful from Khan and this one is a long discussion but it's helpful. There are good links or sites also that has a sample code and explanation. Follow the links below. http://renaud.waldura.com/doc/java/dijkstra/ http://www.vogella.com/articles/JavaAlgorithmsDijkstra/article.html  - has a Java Code http://en.literateprograms.org/Dijkstra's_algorithm_(Java)#chunk def:relax the edge (u,v)  - has a java code too with explanation (cool!) Hope you enjoy learning Dijkstra's Algorithm.

Explaining B-Trees: animated video

This video is not owned by me, I just screen casted it and put into video so you can do track by time compared to their flash base which is annoying when you wanted to back track. This video is taken from  http://www.csanimated.com/animation.php?t=B-tree

Using your calculator to validate logarithms with exponents and get result of logarithms

I just stumbled this earlier when I was playing with my calculator and I forgot how to use it, so I remember that logarithms is just a way of a reverse formula of exponents. So I came up with this solution, log 2 (8) = 3 in calculator, press 8 + press x radical symbol(y) + press 3 = 2 log 2 (3) = 1.58496250072116 in calculator press 3 + press x radical symbol(y) + 1.58496250072116 = 2 log 4 (16) = 4294967296 in calculator press 4294967296 + press x radical symbol(y) + 16 = 4 So the formula is, log base (logarithm number) = result or result as the index then radical symbol(logarithm number as the radicand) = base then, base result = logarithm number Now to get the result of a logarithm in calculator, you can use natural logarithm. To calculate it, do, ex. ln(16)/ln(2) = 4 which is equivalent to, log 2 (16) = 4 another ex. ln(65536)/ln(4) = 7.99 = 8 which is equivalent to log 4 (65536) = 8

Using "use strict" in JavaScript

Image
Using Firefox, as of this writing, version 12.0. Here's a tiny part of using "use strict" syntax in JavaScript. without "use strict", var x = 17; var evalX = eval("var x = 42; x"); alert(x === 17);  // results to  false alert(x === 42);  // results to true alert(evalX === 42); // results to true with "use strict", var x = 17; var evalX = eval("'use strict'; var x = 42; x"); alert(x === 17);  // results to true alert(x === 42); // results to false alert(evalX === 42); // results to true To know more about "use strict", read more on Mozilla's page at  https://developer.mozilla.org/en/JavaScript/Strict_mode  or another interesting blog to read at  http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ A tabular view shows what browsers does support strict mode in JavaScript. Taken from  http://caniuse.com/#feat=use-strict , as of this writing, I got this tabular view below,

Understanding Anchor point in iOS

Image
Just to take notes for this regarding anchor point in iOS. This is taken from  developer.apple.com Specifying a Layer’s Geometry While layers and the layer-tree are analogous to views and view hierarchies in many ways, a layer's geometry is specified in a different, and often simpler, manner. All of a layer’s geometric properties, including the layer’s transform matrices, can be implicitly and explicitly animated. Figure 1  shows the properties used to specify a layer's geometry in context. Figure 1   CALayer geometry properties The  position  property is a  CGPoint  that specifies the position of the layer relative to its superlayer, and is expressed in the superlayer's coordinate system. The  bounds  property is a  CGRect  that provides the size of the layer ( bounds.size ) and the origin ( bounds.origin ). The bounds origin is used as the origin of the graphics context when you override a layer's drawing methods. Layers have an implicit  frame  tha

Comet - long-polling using Ajax

I just wanted to save this video for any references wanted to understand what Comet is. So what exactly Comet is? Comet is still using AJAX but its just a technique done in the server. It uses timestamp for comparison of updates, then AJAX request will have just to wait until the server will response, so it's the sever will have to push data to the browser. This is a long-polling method and can save traffic than running an AJAX request from time-to-time.

checkout only one file using git

First clone the repo with the following command below, git clone -n git://path/to/the_repo.git --depth 1 The -n option suppresses the default checkout of all files, and the --depth 1 option, which means it only gets the most recent revision of each file Then check out just the file you want like so: Then you can checkout the file that you wanted to get or save to your machine. $> cd the_repo $> git checkout HEAD name_of_file