tag:blogger.com,1999:blog-66387762024-03-13T16:58:32.457+03:00Odds end evens of web-developmentDeveloping client-side day by day. JS, CSS, HTML, Google Chrome extensions. Browser-caused headaches. Dead ways and serendipitous findings.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-6638776.post-36816225974754843642014-09-16T16:36:00.000+04:002014-09-16T16:36:29.522+04:00git, npm, bower and corporate proxies<p>Sometimes, when you work behind evil corporate proxy (that is, evil proxy, not evil corporation), you can run into some connection problems using git or npm or bower or similar open-source instruments. For example, <code>Download of https://github.com/some/package/archive/v0.1.9.tar.gz failed with ECONNRESET, retrying in 1.2s</code>, or <code>fatal: unable to access 'https://github.com/mikeric/rivets.git/': Failed connect to github.com:443; No error</code>. This is all caused by corporate proxies, especially with AD authentication ones.</p>
<p>You need up to 4 pieces of information to set up proxies in mentioned software:</p>
<ul>
<li>Proxy domain</li>
<li>Proxy port</li>
<li>If your proxy needs AD authentication, you need your domain login</li>
<li>and domain password</li>
</ul>
<p>In latter case you may need also AD domain name.</p>
<p>All following configs are storing your passwords in non-encrypted plain text files. So it'll be good idea (well, it always is) to use latest AV/firewall software and/or use some kind of disk encryption.</p>
<p><code><</code> and <code>></code> are not the part of config, they're just markers.</p>
<h3><code>.gitconfig</code></h3>
<p>My <code>.gitconfig</code> looked like this:</p>
<pre>[http]
proxy = http://<AD>\\<AD username>:<AD password>@<proxy domain>:<proxy port>
[https]
proxy = http://<AD>\\<AD username>:<AD password>@<proxy domain>:<proxy port></pre>
<p>Note <code>\\</code> separating AD domain and AD username. This config allowed me to <code>git clone</code> over https protocol.</p>
<h3><code>.npmrc</code></h3>
<pre>registry = http://registry.npmjs.org/
proxy = http://<AD>%5C<AD username>:<AD password>@<proxy domain>:<proxy port></pre>
<p>Note that <code>\</code> is URL-encoded here and that you need to change default repository address to http version (instead of https).</p>
<h3><code>.bowerrc</code></h3>
<p>My <code>.bowerrc</code> was tricky:</p>
<pre>{
"proxy": "http://<AD>%5C<AD username>:<AD password>@<proxy domain>:<proxy port>/",
"https-proxy": "http://<AD>%5C<AD username>:<AD password>@<proxy domain>:<proxy port>/",
"registry": "http://bower.herokuapp.com",
"strict-ssl": false
}</pre>
<p>Note <code>"strict-ssl": false</code> option, <code>http://</code> in <code>https-proxy</code> value, <code>registry</code> change to non-https (like in .npmrc) and trailing slash after proxy port number.</p>Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-11903122981943213182013-09-10T19:51:00.001+04:002013-09-10T19:54:35.545+04:00Easing in javascript animationAlthough we now have great CSS animation API in modern browsers, we still should support older browser. This means we'll continue to implement animations in JS.<br />
Great interactive tool for choosing easing function for your animation: <a href="http://www.gizma.com/easing/">www.gizma.com/easing/</a>. Please note that <var>c</var> argument is <strong>not</strong> destination value, it's difference between starting value and end value. See this <a href="http://upshots.org/actionscript/jsas-understanding-easing">thorough explanation</a> for more details and <a href="http://www.robertpenner.com/easing/">collection of links on easing</a>.<br />
Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-82542715661725313062012-04-26T13:19:00.001+04:002012-04-26T13:19:47.944+04:00FiddleSalad<a href="http://fiddlesalad.com/">fiddlesalad.com</a> is another one fiddler with rather wide range of supported technologies: HTML, HAML, Zen Coding, Markdown, CoffeeCup, Jade, CSS, SCSS, SASS, LESS, Stylus, JavaScript, CoffeeScript, Python, Roy.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-81473499995067666682012-02-16T23:43:00.000+04:002012-02-16T23:43:45.656+04:00jsbin.comJsFiddle seems a nice tool, but it always annoys me some way or another.<br />
Anyway, I found another sandbox: <a href="http://jsbin.com">jsbin.com</a>. Has it's own pros and cons. For example, it have linter built-in. But you can't adjust it. Give it a try.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-31040864911768405352012-02-16T23:29:00.000+04:002012-02-21T19:01:47.642+04:00How to pass data from markup to JS<p>Imagine we have some component system, similar to Dojo. Kernel find nodes, detects which components (let's call them widgets) they going to be coming from className or anything else. After that kernel must instantiate widgets and pass respective nodes and parameters.</p><p>So, we became all declarative and such, and it's just reasonable to store parameters near our node.</p><p>In my practice I saw three ways of doing that.</p><dl><dt>Usage of expando attributes (like Dojo does) or <code>data-</code> attributes (Bootstrap components).</dt>
<dd>May stretch yor node to several LOC. You can make it shorter using JSON instead of several attributes, to make it faster and less verbose, but JSON requires keys in double quotes, and it conflicts with markup if you used to double quotes around attributes values</dd>
<dt>Putting data in <code>input[type=hidden]</code> that resides inside your widget.</dt>
<dd><code>Name</code> attribute became key and value of input became, er, value. Seems reasonable and may be useful, if your server-side puts extra data for itself in hidden inputs when rendering forms. But you should specify names inside your widget's code. Performance also suffer due to numerous DOM queries.</dd>
<dt>Just write your params in like Javascript's hash, prepend it with <code>return</code> keyword, and put it into <code>onclick</code> attribute.</dt>
<dd>Not very semantic and all, but this way has several advantages, which I describe next.</dd></dl><p>Pros of putting params through <code>onclick</code>:</p><ol><li>It's not JSON, so it wont conflict with markup.</li>
<li>You don't need neither <code>JSON.parse</code> nor <code>eval</code> (which is evil). You just call it as function — as easy as <code>var params = node.onclick()</code>.</li>
<li>Some code editors can highlight JavaScript code inside <code>onclick</code>. So less typos, no missed parens and quotes, less bugs.</li>
<li>Though it is not semantic usage of attributes, it can't break anything. Validator wont complain either.</li>
</ol><p>Cons:</p><ol><li>Not semantic. Purists gonna pure.</li>
<li>It fires every time you click widget. Though it doesn't do much of job, performance can suffer slightly, I suppose. But you can use some other attribute — e.g. <code>ondblclick</code>. Double clicks rarely appears and rarely occurs in modern interfaces. Anyway, it's minor impact and minor flaw of method.</li>
<li>It can be hard to exlain this to people. Use this article as reference:)</li>
</ol><p>Pros wins!</p><p>I'm not inventor of this method parameters passing. I first met this approach while working at Yandex. JS in most their services use it; developer and browsers both seems happy with it.</p>Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-12341409394956318112012-01-20T22:32:00.001+04:002012-01-20T22:32:29.300+04:00Coder 80 lvlSome guys wrote <a href="http://channel9.msdn.com/Blogs/C9Team/Announcing-Visual-Studio-Achievements">achievements add-in for Visual Studio</a>. Too pity I'm not using VS; hope it will be ported to IntelliJ WebStorm or Vim or whatever editor which is crossplatform. And other languages; currently it supports only C# seemingly.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-82626407610975170682012-01-13T16:05:00.000+04:002012-01-13T16:06:24.032+04:00JS and semicolons<a href="http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding">Great article on automatic semicolon insertion</a>. In short, author states that before arguing for mandatory using of semicolons, one must firstly learn what expressions in JS are.<br />
Article confirmed my thoughts that writing:<br />
<code><pre>return
7</pre></code>you should blame yourself, not AIS.<br />
<br />
I personally go slight further: semicolons was design error in C back in 70th. There are no real need in writing several statements in one line, and never was. There are plenty of languages which never has semicolons as statement separators, and they prosper.<br />
<br />
I definitely must translate that article to Russian.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-2377615102852222202011-12-11T14:35:00.001+04:002012-02-15T11:40:27.110+04:00staticloud.comI used to use Dropbox for instant static hosting (experiments and such), but now they serve xhtml files only; any .html causes 404.<br />
Today I found a staticloud.com, which provides static hosting at almost the same level of simplicity as DropBox. You just dragdrop your zipped files and choose subdomain, and after couple of seconds (watching upload bar) yoursite.staticloud.com is up and running. No ads and 1GB bandwidth per month should be enough for just about any static site.<br />
They use Amazon's cloud. Great job!<br />
<br />
P.S. There is similar tool: <a href="http://coralrift.com">coralrift.com</a>Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-61540579569844397802011-08-21T16:38:00.002+04:002012-02-01T00:09:50.780+04:00GNU (and others) make in web-development<var>make</var> can be very useful both in combining static files together and squeezing them. I've found detailed and complete manual on this: <a href="http://nefariousdesigns.co.uk/archive/2010/02/website-builds-using-make/">Website builds using Make</a>. While Makefile syntax may seems confusing and arcane at first glance, basically it is just shell script with some addition to manage dependencies. <br />
<br />
Since Makefile basically is shell script, you can use watever commandline-fu you learned. There is one thing to consider though: for loops.<br />
<code><pre>for i in $(my-src-files) do; echo $$i >> $(my-dest-file); done</pre></code><br />
It takes me couple of hours to realize that one must use <var>$$i</var> when referencing loop variable instead of just <var>$i</var> like in plain shell scripts.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-47523883542312875862011-04-24T01:29:00.002+04:002011-08-21T16:40:13.501+04:00Google Chrome's requestFileSystem APII've needed to dump database from Chrome extension and walked to <code>requestFileSystem</code> API. This API described quite detailed on <a href="http://www.html5rocks.com/tutorials/file/filesystem/">HTML5 Rocks</a>, but it gave no idea where my files are located on my hard drive. <a href="http://technet.microsoft.com/sysinternals/bb896645">Process Monitor</a> gaved me directions, and there it is. For each application, would it be site or extension, Google Chrome creates subdir in your <var>%LOCALAPPDATA%\Google\Chrome\User Data\Default\FileSystem</var> (on Windows (I'll give path for Linux later)). This subdir is named after application's URL, including protocol with slashes and colons replaced with underscores. For html5test.com it looks this way: <var>http_www.html5rocks.com_0</var> Inside URL-named folder one can find one or two folders: Persistent or Temporary or both, which depends on type of access given application used. Inside each of them there is a directory with some kind of hash in name. And that hashed-name directory is root directory for your application's filesystem.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com0tag:blogger.com,1999:blog-6638776.post-41718241006813637852011-04-21T02:09:00.000+04:002011-08-21T16:45:53.635+04:00e-mail validationDevelopers should always remember that e-mail adressess may contain dot before <var>@</var>. For example, one of my e-mails is doctor.hogart@gmail.com. I've created it in late 2004 and I periodically still got messages like „invalid e-mail“.Konstantin Kitmanovhttp://www.blogger.com/profile/02841974930981320469noreply@blogger.com2