<?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: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-7315857245558978151</id><updated>2011-10-25T05:39:01.143-07:00</updated><category term='graphic'/><category term='mail'/><category term='proxy'/><category term='javascript'/><category term='headers'/><category term='web'/><category term='HTTPS'/><category term='unix'/><category term='dynamic'/><category term='script'/><category term='option'/><category term='canvas'/><category term='sendmail'/><category term='command'/><category term='chart'/><category term='wget'/><category term='HTML 5'/><category term='HTTP'/><title type='text'>Techs Tricks</title><subtitle type='html'>Quotes about anything concerning programming and computer.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techs-tricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techs-tricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Biba</name><uri>http://www.blogger.com/profile/04625538399828095220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_r8hx4O4BXHU/SY8tjzRKNAI/AAAAAAAAAMY/0cInsnmj4JI/S220/ilovetechno.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7315857245558978151.post-8632429613846221352</id><published>2010-04-26T04:55:00.000-07:00</published><updated>2010-04-27T08:51:36.874-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='dynamic'/><category scheme='http://www.blogger.com/atom/ns#' term='graphic'/><category scheme='http://www.blogger.com/atom/ns#' term='canvas'/><category scheme='http://www.blogger.com/atom/ns#' term='chart'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML 5'/><title type='text'>Dynamic graphic chart with canvas</title><content type='html'>&lt;span style="color: rgb(0, 0, 102);"&gt;Hi,&lt;br /&gt;I tried to use canvas ability to draw graphs, dynamic in this case, client-side without need of flash or whatever demanding to install plugin to our web browser. It works in almost all browser except IE...&lt;br /&gt;Here is the code :&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;var mem = Array();var dataSpan = Array();var ctx;var timer;var inc=0;var scale;var initLimUp=200;var axisMid;var axisTop;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Init function including canvas context declaration, transformation to put the origin at left bottom (mor natural for me) and launching of the recursive main function.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function initGraph(){&lt;br /&gt;axisTop = document.getElementById('axisTop');&lt;br /&gt;axisMid = document.getElementById('axisMid');axisBot = document.getElementById('axisBot');&lt;br /&gt;var canvas = document.getElementById('canv');&lt;br /&gt;if (canvas.getContext){&lt;br /&gt;ctx = canvas.getContext('2d');&lt;br /&gt;//Put the origin at left bottom &lt;br /&gt;ctx.transform(1, 0, 0, -1, 0, 200);&lt;br /&gt;ctx.lineWidth = 5;ctx.lineJoin = 'round';&lt;br /&gt;ctx.save();&lt;br /&gt;timer = setInterval('process()', 500);&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Main function&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function process() {&lt;br /&gt;dataGeneration();&lt;br /&gt;scaling();&lt;br /&gt;draw();&lt;br /&gt;changeAxis();&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Function used to generate values feeding the graph.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function dataGeneration() {&lt;br /&gt;//A dummy way to generate data&lt;br /&gt;mem.push((inc%20==0)?Math.random()*400:mem[mem.length-1]+25);&lt;br /&gt;dataSpan=mem;&lt;br /&gt;//We keep only the last 35 values&lt;br /&gt;if(mem.length&amp;gt;35) {&lt;br /&gt;dataSpan.shift();&lt;br /&gt;}&lt;br /&gt;inc++;&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;I add a y-axis scaling ability to fit the graph with the values displayed.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function scaling() {&lt;br /&gt;//To find out what is the scaling to apply, I look for the highest value to display&lt;br /&gt;//then I compare it to the original display size of the canvas (that mean I'll have to apply scaling to the original state of the canvas)&lt;br /&gt;var dataToCheck = new Array();&lt;br /&gt;dataToCheck = dataToCheck.concat(dataSpan);&lt;br /&gt;dataToCheck.sort(sortNumber);&lt;br /&gt;var max = dataToCheck[dataToCheck.length-1];&lt;br /&gt;scale = 1/(Math.ceil(max/initLimUp));&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Simple function to chnage the legend of y-axis regarding the current scale.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"  &gt;&lt;br /&gt;function changeAxis() {&lt;br /&gt;axisTop.innerHTML=initLimUp/scale;&lt;br /&gt;axisMid.innerHTML=initLimUp/scale/2;&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt; Comparison function used to find out what is the highest value displayed.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function sortNumber(a,b) {return a - b;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Drawing function:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Clear the canvas&lt;/li&gt;&lt;li&gt;Adjust scaling&lt;/li&gt;&lt;li&gt;Add a plot for each value and join (stroke) them&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: rgb(0, 0, 0);font-family:courier new;font-size:85%;"&gt;&lt;br /&gt;function draw(){&lt;br /&gt;//We need to restore to the original state to be able to apply scaling (due to my scaling calculation method)&lt;br /&gt;ctx.restore();&lt;br /&gt;//We need to save directly to keep the original state in the stack else next restore won't work&lt;br /&gt;ctx.save();&lt;br /&gt;//As we've restored the initial scale, we can clear the whole canvas efficiently&lt;br /&gt;ctx.clearRect(0,0,350,initLimUp);&lt;br /&gt;//Then after applying the current scale value we draw the graphic&lt;br /&gt;ctx.scale(1,scale);&lt;br /&gt;ctx.beginPath();&lt;br /&gt;for(i=0;i &amp;lt; dataSpan.length;i++){&lt;br /&gt;ctx.lineTo(10*i,dataSpan[i]);&lt;br /&gt;}&lt;br /&gt;ctx.stroke();&lt;br /&gt;}&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;You can test the graph by clicking down the button under the graph.&lt;/span&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;var mem = Array();var dataSpan = Array();var ctx;var timer;var inc=0;var scale;var initLimUp=200;var axisMid;var axisTop;function initGraph(){axisTop = document.getElementById('axisTop');axisMid = document.getElementById('axisMid');axisBot = document.getElementById('axisBot');var canvas = document.getElementById('canv');if (canvas.getContext){ctx = canvas.getContext('2d');ctx.transform(1, 0, 0, -1, 0, 200);ctx.lineWidth = 5;ctx.lineJoin = 'round';ctx.save();timer = setInterval('process()', 500);}}function process() {dataGeneration();scaling();draw();changeAxis();}function dataGeneration() {mem.push((inc%20==0)?Math.random()*400:mem[mem.length-1]+25);dataSpan=mem;if(mem.length&gt;35) {dataSpan.shift();}inc++;}function scaling() {var dataToCheck = new Array();dataToCheck = dataToCheck.concat(dataSpan);dataToCheck.sort(sortNumber);var max = dataToCheck[dataToCheck.length-1];scale = 1/(Math.ceil(max/initLimUp));}function changeAxis() {axisTop.innerHTML=initLimUp/scale;axisMid.innerHTML=initLimUp/scale/2;}function sortNumber(a,b) {return a - b;}function draw(){ctx.restore();ctx.save();ctx.clearRect(0,0,350,initLimUp);ctx.scale(1,scale);ctx.beginPath();for(i=0;i &lt; dataSpan.length;i++){ctx.lineTo(10*i,dataSpan[i]);}ctx.stroke();}&lt;/script&gt;&lt;div id="block" style="clear: both; width: 400px;"&gt;&lt;canvas height="200" id="canv" style="border: 1px solid black; float: right; margin: 10px 0;" width="350"&gt;&lt;/canvas&gt;&lt;div id="axisTop" style="margin: 0; padding: 0;"&gt;0&lt;/div&gt;&lt;div id="axisMid" style="margin: 80px 0; padding: 0;"&gt;0&lt;/div&gt;&lt;div id="axisBot" style="margin: 0; padding: 0;"&gt;0&lt;/div&gt;&lt;/div&gt;&lt;input type="submit" value="Launch" onclick="javascript:initGraph()"&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7315857245558978151-8632429613846221352?l=techs-tricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techs-tricks.blogspot.com/feeds/8632429613846221352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7315857245558978151&amp;postID=8632429613846221352' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/8632429613846221352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/8632429613846221352'/><link rel='alternate' type='text/html' href='http://techs-tricks.blogspot.com/2010/04/dynamic-graphic-with-canvas.html' title='Dynamic graphic chart with canvas'/><author><name>Biba</name><uri>http://www.blogger.com/profile/04625538399828095220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_r8hx4O4BXHU/SY8tjzRKNAI/AAAAAAAAAMY/0cInsnmj4JI/S220/ilovetechno.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7315857245558978151.post-4050944134514751732</id><published>2008-12-11T06:59:00.000-08:00</published><updated>2011-10-25T05:39:01.185-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HTTP'/><category scheme='http://www.blogger.com/atom/ns#' term='option'/><category scheme='http://www.blogger.com/atom/ns#' term='command'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='HTTPS'/><category scheme='http://www.blogger.com/atom/ns#' term='wget'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><category scheme='http://www.blogger.com/atom/ns#' term='proxy'/><title type='text'>Test a HTTP request with wget</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: #000066;"&gt;Few usefull options of the &lt;/span&gt;&lt;span style="color: #000066;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Wget"&gt;wget&lt;/a&gt; command &lt;/span&gt;&lt;span style="color: #000066;"&gt;to quickly test the response of a web application.&lt;br /&gt;&lt;br /&gt;First&lt;/span&gt;  &lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new; font-size: 85%;"&gt;wget http://www.google.com &lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: #000066;"&gt;will save the result send by the server in a file with the samename as the page asked (index.html in the case of www.google.com)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #000066;"&gt;use "-o" option to log the wget operation&lt;/span&gt;  &lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new;"&gt;&lt;span style="font-size: 85%;"&gt;wget -o wget.log http://www.google.com&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: #000066;"&gt;Log you can &lt;span style="color: black; font-family: courier new;"&gt;grep 'HTTP request sent, awaiting response... 200 OK&lt;/span&gt;&lt;span style="color: black;"&gt;'&lt;/span&gt; in a script to simply know if the wget succeed&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;  &lt;span style="color: #000066;"&gt;use "-O" to redirect the result in a specified file&lt;/span&gt;  &lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new; font-size: 85%;"&gt;wget -O google.index.txt http://www.google.com&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: #000066;"&gt;&lt;br /&gt;"--post-file" allows you to POST data included in the specified file&lt;/span&gt; &lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new; font-size: 85%;"&gt;wget --post-file=POSTdata.txt http://xxxxxx.yyy&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="color: #000066;"&gt;&lt;br /&gt;Finally use "-no-check-certificate" option to don't check the server's certificate when connecting with SSL.&lt;/span&gt;  &lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new; font-size: 85%;"&gt;wget --no-check-certificate htt&lt;/span&gt;&lt;span style="color: black; font-family: courier new; font-size: 85%;"&gt;p&lt;/span&gt;&lt;span style="color: black; font-family: courier new;"&gt;&lt;span style="font-size: 85%; font-weight: bold;"&gt;s&lt;/span&gt;&lt;span style="font-size: 85%;"&gt;://xxxxxx.yyy&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span style="color: #000066;"&gt;If you need to go through proxy, just use export command before wget to specify the login, password and url of the proxy.&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="color: black; font-family: courier new;"&gt;&lt;span style="font-size: 85%;"&gt;export http_proxy="http://login:password@proxy.exemple.org:8080"&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7315857245558978151-4050944134514751732?l=techs-tricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techs-tricks.blogspot.com/feeds/4050944134514751732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7315857245558978151&amp;postID=4050944134514751732' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/4050944134514751732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/4050944134514751732'/><link rel='alternate' type='text/html' href='http://techs-tricks.blogspot.com/2008/12/test-http-request-with-wget.html' title='Test a HTTP request with wget'/><author><name>Biba</name><uri>http://www.blogger.com/profile/04625538399828095220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_r8hx4O4BXHU/SY8tjzRKNAI/AAAAAAAAAMY/0cInsnmj4JI/S220/ilovetechno.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7315857245558978151.post-6940106706078737042</id><published>2008-12-11T06:34:00.000-08:00</published><updated>2009-02-10T11:36:37.708-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='headers'/><category scheme='http://www.blogger.com/atom/ns#' term='sendmail'/><category scheme='http://www.blogger.com/atom/ns#' term='command'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='mail'/><category scheme='http://www.blogger.com/atom/ns#' term='script'/><title type='text'>Send a mail by tunning headers</title><content type='html'>&lt;span style="color: rgb(0, 0, 102);"&gt;You can do it thanks to the unix command : &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Sendmail"&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 102);"&gt;sendmail&lt;/span&gt;&lt;/a&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;.&lt;br /&gt;&lt;br /&gt;sendmail allows you to specify header fields before sending a mail thanks to "-t" option.&lt;br /&gt;&lt;br /&gt;So you can explicitly configure mail's attributes like: &lt;span style="font-weight: bold;"&gt;From, Subject, Bcc, or even Importance&lt;/span&gt;, etc... (You can find &lt;/span&gt;&lt;a style="font-weight: bold;" href="http://tools.ietf.org/html/rfc4021"&gt;here&lt;/a&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 102);"&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;an exhaustive list of these fields&lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;)&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 102);"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Here is a template called "mail.txt" containing both header and message to send :&lt;/span&gt;&lt;br /&gt;&lt;blockquote face="courier new" style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;From: XXX &amp;lt;xxx@mail.com&amp;gt;&lt;br /&gt;To: YYY &amp;lt;yyy@mail.com&amp;gt;&lt;br /&gt;CC: ZZZ &amp;lt;zzz@mail.com&amp;gt;&lt;br /&gt;Bcc: HHH &amp;lt;hhh@mail.com&amp;gt;&lt;br /&gt;Subject: Your subject&lt;br /&gt;Importance: High&lt;br /&gt;Content-Type: text/html&lt;br /&gt;MIME-Version: 1.0&lt;br /&gt;Return-Path: XXX &amp;lt;xxx@mail.com&amp;gt;&lt;br /&gt;Your message.&lt;br /&gt;Your message..&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Then simply send the mail with command:&lt;/span&gt;&lt;br /&gt;&lt;blockquote style="color: rgb(0, 0, 0); font-family: courier new;"&gt;sendmail -t &amp;lt; mail.txt&lt;/blockquote&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;Don't worry about Bcc field, it will not appear in the &lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;received &lt;/span&gt;&lt;span style="color: rgb(0, 0, 102);"&gt;mail  (sendmail removes it).&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7315857245558978151-6940106706078737042?l=techs-tricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techs-tricks.blogspot.com/feeds/6940106706078737042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7315857245558978151&amp;postID=6940106706078737042' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/6940106706078737042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7315857245558978151/posts/default/6940106706078737042'/><link rel='alternate' type='text/html' href='http://techs-tricks.blogspot.com/2008/12/send-mail-by-tunning-headers.html' title='Send a mail by tunning headers'/><author><name>Biba</name><uri>http://www.blogger.com/profile/04625538399828095220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_r8hx4O4BXHU/SY8tjzRKNAI/AAAAAAAAAMY/0cInsnmj4JI/S220/ilovetechno.jpg'/></author><thr:total>2</thr:total></entry></feed>
