<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4800974608822482757</id><updated>2024-10-24T12:03:59.656-07:00</updated><category term="CSS"/><category term="Linux"/><category term="PHP"/><category term="Xampp"/><category term="html"/><category term="javascript"/><category term="performance"/><category term="sort"/><category term="table"/><category term="time"/><category term="upload"/><title type='text'>My Programming Tricks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://myprogrammingtricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://myprogrammingtricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>GoNiS</name><uri>http://www.blogger.com/profile/08619213584822399900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://photos1.blogger.com/blogger/3381/1974/1600/yo_southpark.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4800974608822482757.post-4876117668044520411</id><published>2010-05-31T09:51:00.000-07:00</published><updated>2010-05-31T10:03:13.841-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><category scheme="http://www.blogger.com/atom/ns#" term="upload"/><category scheme="http://www.blogger.com/atom/ns#" term="Xampp"/><title type='text'>PHP problems uploading large files</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;It took me a while to realize that the reason why some PDFs I wanted to upload using a PHP scrip I developed to the Thesis Library I am building would not make it to the server. The symptoms where funny:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;Small PDFs would be uploaded fine. That should have immediately ringed a bell&lt;/li&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;The PHP script getting the file plus some other information appeared as if no data was passed to it.&lt;/li&gt;&lt;/ol&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;My web server based on &lt;a href=&quot;http://www.apachefriends.org/en/index.html&quot;&gt;XAMPP&lt;/a&gt; has an default limitation on the size of both uploaded files (2 MB) and POST data (8 MB). I was like to get to the &lt;a href=&quot;http://www.eddieoneverything.com/linux/uploading-large-files-to-a-lamp-setup-upload_max_filesize-post_max_size-and-max_allowed_packet.php&quot;&gt;Eddie on Everything blog&lt;/a&gt; where I could find how to fix this. Very simple instructions:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li style=&quot;text-align: justify;&quot;&gt;Locate your php.ini file. Most probably at &lt;tt&gt;/opt/lampp/etc/php.ini&lt;/tt&gt;&lt;/li&gt;&lt;li&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Edit it and replace the following configurations:&lt;/div&gt;&lt;tt&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;file_uploads = On&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;upload_max_filesize = 30M&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;post_max_size = 30M&lt;/div&gt;&lt;/tt&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myprogrammingtricks.blogspot.com/feeds/4876117668044520411/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/05/php-problems-uploading-large-files.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/4876117668044520411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/4876117668044520411'/><link rel='alternate' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/05/php-problems-uploading-large-files.html' title='PHP problems uploading large files'/><author><name>GoNiS</name><uri>http://www.blogger.com/profile/08619213584822399900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://photos1.blogger.com/blogger/3381/1974/1600/yo_southpark.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4800974608822482757.post-7574151057811650324</id><published>2010-01-16T14:22:00.000-08:00</published><updated>2010-05-31T09:51:16.468-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><category scheme="http://www.blogger.com/atom/ns#" term="time"/><title type='text'>Trying to measure the total time used by a process in GNU/Linux...</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;Are you trying to measure how long (in CPU, and in total) does it take a process you are running in Linux? Yeah, you do that from time to time to see the performance of your machine, and you always execute the &lt;tt style=&quot;font-weight: bold;&quot;&gt;time&lt;/tt&gt; command. Something like:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;table style=&quot;border: 1px dotted black; background-color: rgb(173, 216, 230); width: 100%; padding-left: 10px; text-align: left; margin-left: 0px; margin-right: 0px;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;tt&gt;[host]$ &lt;b&gt;time somecomnand&lt;/b&gt;&lt;br /&gt;...&lt;br /&gt;&lt;br /&gt;real    0m1.127s&lt;br /&gt;user    0m0.002s&lt;br /&gt;sys     0m0.015s&lt;br /&gt;&lt;/tt&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;great! That is what we wanted... except that we would probably like to run this automatically and get the output to some log file. So you try to redirect the output and it doesn&#39;t work. Therefore, you run &lt;tt&gt;man time&lt;/tt&gt; to see if you find something there and &lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_time.htm&quot;&gt;you see&lt;/a&gt; the &lt;tt&gt;-o outputfile&lt;/tt&gt; parameter. Yeah! That&#39;s what you need, so you try:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;table style=&quot;border: 1px dotted black; background-color: rgb(173, 216, 230); width: 100%; padding-left: 10px; text-align: left; margin-left: 0px; margin-right: 0px;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;tt&gt;[host]$ &lt;b&gt;time -o time.log somecommand&lt;/b&gt;&lt;br /&gt;-bash: -o: command not found&lt;br /&gt;&lt;br /&gt;real    0m0.002s&lt;br /&gt;user    0m0.000s&lt;br /&gt;sys     0m0.002s&lt;br /&gt;&lt;/tt&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;Ups! What happened?&lt;br /&gt;&lt;br /&gt;Well, the problem here is that you are really using &lt;tt&gt;time&lt;/tt&gt; reserved word in the &lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_bash.htm&quot;&gt;bash shell&lt;/a&gt;. And the solution is to run the &lt;tt&gt;time&lt;/tt&gt; program in your linux distribution by specifying the full path to it:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;table style=&quot;border: 1px dotted black; background-color: rgb(173, 216, 230); width: 100%; padding-left: 10px; text-align: left; margin-left: 0px; margin-right: 0px;&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;tt&gt;[host]$ &lt;b&gt;/usr/bin/time -o time.log yes&lt;/b&gt;&lt;br /&gt;...&lt;br /&gt;[host]$ &lt;b&gt;cat time.log&lt;/b&gt;&lt;br /&gt;4288.24user 80.40system 1:53:44elapsed 64%CPU (0avgtext+0avgdata 0maxresident)k&lt;br /&gt;0inputs+0outputs (277major+178073minor)pagefaults 0swaps&lt;br /&gt;&lt;/tt&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;The format is slightly different, but you have everything you need.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myprogrammingtricks.blogspot.com/feeds/7574151057811650324/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/trying-to-measure-total-time-used-by.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/7574151057811650324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/7574151057811650324'/><link rel='alternate' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/trying-to-measure-total-time-used-by.html' title='Trying to measure the total time used by a process in GNU/Linux...'/><author><name>GoNiS</name><uri>http://www.blogger.com/profile/08619213584822399900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://photos1.blogger.com/blogger/3381/1974/1600/yo_southpark.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4800974608822482757.post-8972755713622602341</id><published>2010-01-11T13:57:00.000-08:00</published><updated>2010-01-12T01:27:19.436-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CSS"/><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="sort"/><category scheme="http://www.blogger.com/atom/ns#" term="table"/><title type='text'>Sorting tables in HTML using javascript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;You may have seen those tables out there which are able to sort themselves by clicking on some of their column headers. How do you do that? If you search around you may see that one of the first solutions is the &lt;a style=&quot;font-weight: bold; font-family: courier new;&quot; href=&quot;http://www.kryogenix.org/code/browser/sorttable/&quot;&gt;sorttable&lt;/a&gt; by &lt;span style=&quot;font-style: italic;&quot;&gt;Stuart Langridge&lt;/span&gt;. Well, it is really good and has quite some features. But according to what I was looking for it lacks two features:&lt;br /&gt;&lt;ol style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;The column headers are clickable, but you have no way to know it unless you click on them. This can be solved by simply adding the following few lines to the CSS style file and by using &lt;tt&gt;&amp;lt;th&amp;gt;&lt;/tt&gt; at the column headers:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;brush: css&quot;&gt;&lt;br /&gt;table.sortable th {&lt;br /&gt; cursor:pointer;&lt;br /&gt;}&lt;br /&gt;table.sortable th.sorttable_nosort {&lt;br /&gt;  cursor:auto;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The rows do not show alternated background colors. Solving this one is a bit more tricky and requires a couple of inserts in the javascript file Stuart provides. Part of the code come from &lt;a href=&quot;http://yoast.com/articles/sortable-table/&quot;&gt;this other good example&lt;/a&gt; from &lt;span style=&quot;font-style:italic;&quot;&gt;Joost de Valk&lt;/span&gt;. The first modification happens on line 159, just before:&lt;br /&gt;&lt;pre class=&quot;brush: js&quot;&gt;delete row_array;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;At that point insert the following line:&lt;br /&gt;&lt;pre class=&quot;brush: js&quot;&gt;&lt;br /&gt;sorttable.alternate(this.sorttable_tbody);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After that you need to insert the following code around line 254, just before the   line saying &quot;&lt;span style=&quot;font-style:italic;&quot;&gt;/* sort functions&lt;/span&gt;&quot;:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;brush: js&quot;&gt;&lt;br /&gt;alternate: function(tbody) {&lt;br /&gt;  var tableRows = tbody.getElementsByTagName(&quot;tr&quot;);&lt;br /&gt;  for (var j = 0; j &lt; tableRows.length; j++) {&lt;br /&gt;    // Check if j is even, and apply classes for both possible results&lt;br /&gt;    if ( (j % 2) == 0  ) {&lt;br /&gt;      if ( !(tableRows[j].className.indexOf(&#39;odd&#39;) == -1) ) {&lt;br /&gt;        tableRows[j].className = tableRows[j].className.replace(&#39;odd&#39;, &#39;even&#39;);&lt;br /&gt;      }&lt;br /&gt;      else if ( tableRows[j].className.indexOf(&#39;even&#39;) == -1 ) {&lt;br /&gt;        tableRows[j].className += &quot; even&quot;;&lt;br /&gt;      }&lt;br /&gt;    } &lt;br /&gt;    else {&lt;br /&gt;      if ( !(tableRows[j].className.indexOf(&#39;even&#39;) == -1) ) {&lt;br /&gt;          tableRows[j].className = tableRows[j].className.replace(&#39;even&#39;, &#39;odd&#39;);&lt;br /&gt;      } else if ( tableRows[j].className.indexOf(&#39;odd&#39;) == -1 ) {&lt;br /&gt;          tableRows[j].className += &quot; odd&quot;;&lt;br /&gt;      }               &lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;},&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Then, you might change the background color (or any other aspect of the row) for the even and odd rows by adding some styles in your CSS file. For example:&lt;br /&gt;&lt;pre class=&quot;brush: css&quot;&gt;&lt;br /&gt;.odd {&lt;br /&gt;  background-color: #ddd;&lt;br /&gt;}&lt;br /&gt;.even {&lt;br /&gt;  background-color: #222;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;One more tip. For some font types the up and down arrows that are shown in the header when a column is sorted may look small. The rendering can be improved by tweaking the CSS file again. For example:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;brush: css&quot;&gt;&lt;br /&gt;#sorttable_sortrevind, #sorttable_sortfwdind {&lt;br /&gt;  font-size: 14px;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myprogrammingtricks.blogspot.com/feeds/8972755713622602341/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/sorting-tables-in-html-using-javascript.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/8972755713622602341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/8972755713622602341'/><link rel='alternate' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/sorting-tables-in-html-using-javascript.html' title='Sorting tables in HTML using javascript'/><author><name>GoNiS</name><uri>http://www.blogger.com/profile/08619213584822399900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://photos1.blogger.com/blogger/3381/1974/1600/yo_southpark.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4800974608822482757.post-5970545203907242488</id><published>2010-01-11T13:51:00.000-08:00</published><updated>2010-01-11T13:57:45.279-08:00</updated><title type='text'>Welcome</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;This is the starting point of a blog which will be targeted at tricks I use on my day by day life while programming various different things. I routinely use some of the most common programming languages in a variety of environments: C++, java, javascript, php, python, shell (bash/tcsh),... and a few other languages which can vaguely considered that way: HTML, LaTeX, etc. The idea is to give back to the community some of the tricks I learnt by googling. Hope someone benefits.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myprogrammingtricks.blogspot.com/feeds/5970545203907242488/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/welcome.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/5970545203907242488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4800974608822482757/posts/default/5970545203907242488'/><link rel='alternate' type='text/html' href='http://myprogrammingtricks.blogspot.com/2010/01/welcome.html' title='Welcome'/><author><name>GoNiS</name><uri>http://www.blogger.com/profile/08619213584822399900</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://photos1.blogger.com/blogger/3381/1974/1600/yo_southpark.png'/></author><thr:total>0</thr:total></entry></feed>