<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Sniptools &#187; Shanx</title> <atom:link href="http://sniptools.com/author/shanx/feed/" rel="self" type="application/rss+xml" /><link>http://sniptools.com</link> <description>Design &#38; Technology Observations</description> <lastBuildDate>Tue, 15 May 2012 09:23:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Have Google Chrome remember an SSL certificate on Mac OSX</title><link>http://sniptools.com/mac-osx/google-chrome-remember-trust-ssl-certificate-mac-osx</link> <comments>http://sniptools.com/mac-osx/google-chrome-remember-trust-ssl-certificate-mac-osx#comments</comments> <pubDate>Mon, 27 Feb 2012 17:38:38 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Browsers]]></category> <category><![CDATA[Mac OSX]]></category><guid
isPermaLink="false">http://sniptools.com/?p=583</guid> <description><![CDATA[You access https sites. Chrome, in its security genius, warns you. Every. Single. Time. No more. You can make it remember that you trust a certificate. When on a secure site, click the warning icon on the location bar. The precise icon may change, but at the time of writing, it's a red cross. Then [...]]]></description> <content:encoded><![CDATA[<p>You access https sites. Chrome, in its security genius, warns you. Every. Single. Time.</p><p>No more. You can make it remember that you trust a certificate.</p><p>When on a secure site, click the warning icon on the location bar. The precise icon may change, but at the time of writing, it's a red cross.</p><p><img
title="Google Chrome - remember SSL certificate and trust site" src="http://cache.sniptools.com/2012/02/chrome_cert_1.png" alt="Google Chrome - remember SSL certificate and trust site" /></p><p>Then click on the "Certificate Information". This will bring up a small popup window like this:</p><p><img
src="http://cache.sniptools.com/2012/02/chrome_cert_2.png" alt="Google Chrome - remember SSL certificate and trust site 2" title="Google Chrome - remember SSL certificate and trust site 2" /></p><p>The certificate icon there. Just drag it to your desktop.</p><p>Double-click the <code>.crt</code> file on the desktop.</p><p>Then click on "Accept Certificate".</p><p>This may ask for your admin password. Enter it, and you're done. Revisiting this site will never show you the ominous red page again.</p><p>Very useful for working with our own CPanel/WHM sites, for instance.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/mac-osx/google-chrome-remember-trust-ssl-certificate-mac-osx/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Fix slow network file transfers across Mac OSX Lion</title><link>http://sniptools.com/mac-osx/fix-slow-network-file-transfers-across-mac-osx-lion</link> <comments>http://sniptools.com/mac-osx/fix-slow-network-file-transfers-across-mac-osx-lion#comments</comments> <pubDate>Mon, 10 Oct 2011 01:54:28 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Mac OSX]]></category> <category><![CDATA[lan]]></category> <category><![CDATA[Mac]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[wifi]]></category> <category><![CDATA[wireless]]></category><guid
isPermaLink="false">http://sniptools.com/?p=567</guid> <description><![CDATA[Suddenly, after the upgrade from Snow Leopard to the much vaunted OSX Lion, my wireless transfers over a home LAN network became sluggish. It was taking a few *minutes* to transfer a simple file. Apparently I am not the only one with these issues. I tried a few fixes gleaned from a bunch of separate [...]]]></description> <content:encoded><![CDATA[<p>Suddenly, after the upgrade from Snow Leopard to the much vaunted OSX Lion, my wireless transfers over a home LAN network became sluggish. It was taking a few *minutes* to transfer a simple file.</p><p>Apparently I am <a
href="https://discussions.apple.com/message/6676691?messageID=6676691#6676691" title="Apple Support Discussion about slow network speed ">not the only one</a> with these issues.</p><p>I tried a few fixes gleaned from a bunch of separate threads on the Apple forum, and off the web. Not everything is a smart suggestion. Here's what finally works, so hope this saves some people with similar problems the time:</p><p>[You need root access for the "<code>sudo</code>" bits of the following code to work, of course.]</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo 'net.inet.tcp.delayed_ack=0' &gt;&gt; /etc/sysctl.conf&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo 'net.inet.tcp.recvspace=40960' &gt;&gt; /etc/sysctl.conf&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;echo 'net.inet.tcp.rfc1323=0' &gt;&gt; /etc/sysctl.conf&quot;</span></pre></td></tr></table></div><p></p><p>Make sure the single quotes remain single quotes in the above code share. These new <code>sysctl</code> settings will take effect <strong>after a reboot</strong>.</p><p>Another useful suggestion is to disable the IPV6 stuff. Not needed for now. Done using:</p><p><code><br
/> System Preferences -><br
/> Network -><br
/> Airport (or your WiFi listing) -><br
/> Advanced (button) -><br
/> TCP/IP (tab)<br
/> </code></p><p>Change the IPV6 to "Link — Local".</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/mac-osx/fix-slow-network-file-transfers-across-mac-osx-lion/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Making Java work in browsers on Mac OSX Lion</title><link>http://sniptools.com/mac-osx/making-java-work-in-browsers-on-mac-osx-lion</link> <comments>http://sniptools.com/mac-osx/making-java-work-in-browsers-on-mac-osx-lion#comments</comments> <pubDate>Fri, 29 Jul 2011 10:02:47 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Mac OSX]]></category><guid
isPermaLink="false">http://sniptools.com/?p=555</guid> <description><![CDATA[So I updated to OSX Lion 10.7. Very cool, especially with the easy gestures. Biggest problem: my bank website, which uses Java applets for secure logins, stopped working. In the area where the login form should have been I saw a message that said: "Inactive Plug-in". Same problem across Firefox, Safari, Chrome — all updated [...]]]></description> <content:encoded><![CDATA[<p>So I updated to OSX Lion 10.7. Very cool, especially with the easy gestures.</p><p>Biggest problem: my bank website, which uses Java applets for secure logins, stopped working. In the area where the login form should have been I saw a message that said: "Inactive Plug-in". Same problem across Firefox, Safari, Chrome — all updated to their latest versions.</p><p>I installed the <a
href="http://support.apple.com/kb/DL1421">latest Java for OSX Lion</a> from the Apple website. In hindsight, this was not necessary as the "Software Update" from the Apple menu, as usual, takes care of everything including updating the latest Java.</p><p>So the problem was clearly not with the browsers. The listing of plugins in Firefox showed me that "Java Applet Plugin" is in fact active.</p><p>The problem was annoyingly simple: the update to OSX Lion 10.7 and above often (not always, apparently) disables Java inside browsers for some odd security reason.</p><p>All I had to do was go into "Java Preferences" and enable this back again. Apple hasn't made it easy, but it's a simple command in Terminal:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>Utilities<span style="color: #000000; font-weight: bold;">/</span>Java\ Preferences.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>MacOS<span style="color: #000000; font-weight: bold;">/</span>Java\ Preferences</pre></div></div><p>This will bring up a window as in the screenshot below. Just enable the bit that says to allow applets in browsers, and you're all set. (It will work when you restart your browser.)</p><p><img
src="/cms/wp-content/uploads/2011/07/java_pref.png?348443" alt="Java Preferences on Mac OSX Lion" title="Java Preferences on Mac OSX Lion"  /></p><p>(Edit: You can also search in Spotlight for "Java Preferences".)</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/mac-osx/making-java-work-in-browsers-on-mac-osx-lion/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Speed up OSX Terminal with one command</title><link>http://sniptools.com/mac-osx/speed-up-osx-terminal-with-one-command</link> <comments>http://sniptools.com/mac-osx/speed-up-osx-terminal-with-one-command#comments</comments> <pubDate>Sun, 15 May 2011 09:23:03 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Mac OSX]]></category> <category><![CDATA[System Maintenance]]></category><guid
isPermaLink="false">http://sniptools.com/?p=602</guid> <description><![CDATA[When you start up Terminal, does it take over 10 seconds or so before the prompt appears? Turns out the Terminal.app stores logs of previous sessions and over time this grows. Even apps like MainMenu, that delete the "User Cache", do not delete these files. These files are stored in an esoteric location, hidden from [...]]]></description> <content:encoded><![CDATA[<p>When you start up Terminal, does it take over 10 seconds or so before the prompt appears?</p><p>Turns out the <code>Terminal.app</code> stores logs of previous sessions and over time this grows. Even apps like MainMenu, that delete the "User Cache", do not delete these files.</p><p>These files are stored in an esoteric location, hidden from the regular user. The files have the <code>.asl</code> file extension.</p><p>Here's the command.</p><blockquote><p><code><br
/> sudo rm -f /private/var/log/asl/*.asl<br
/> </code></p></blockquote><p>Execute that in a Terminal window. Then quit and restart Terminal. No more delays or lags. Much faster Terminal. The lack of logs to seek really speeds up Terminal.</p><p>This has been tried and tested in Snow Leopard, Leopard and OSX Lion. Wonder why Macs don't come with this already!</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/mac-osx/speed-up-osx-terminal-with-one-command/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Increase size of /tmp folder on CentOS Linux under Cpanel</title><link>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel</link> <comments>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel#comments</comments> <pubDate>Sat, 30 Apr 2011 09:28:23 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Hosting]]></category> <category><![CDATA[Unix]]></category> <category><![CDATA[centos]]></category> <category><![CDATA[cpanel]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[unix]]></category><guid
isPermaLink="false">http://sniptools.com/?p=590</guid> <description><![CDATA[Any dedicated server hosting some websites that get meaningful traffic will quickly ourgrow Cpanel's default /tmp folder size of 512MB. It houses PHP session files, temporary file uploads, your database temporary files, your web server's cache including the one from caches such as APC or eAccelerator, and other such stuff. With the tmp partition full, [...]]]></description> <content:encoded><![CDATA[<p>Any dedicated server hosting some websites that get meaningful traffic will quickly ourgrow Cpanel's default <code>/tmp</code> folder size of 512MB. It houses PHP session files, temporary file uploads, your database temporary files, your web server's cache including the one from caches such as APC or eAccelerator, and other such stuff.</p><p>With the tmp partition full, the server will experience many random issues such as server crashes. Your sites will quickly go down and leave you head-scratching.</p><p>Fortunately, it's quite easy to resize the /tmp partition on cPanel servers — especially if it is the default one created by cPanel installs. There's a handy script at <code>/scripts/securetmp</code>.</p><p>Open this file:</p><blockquote><p><code>pico /scripts/securetmp<br
/> </code></p></blockquote><p>And find this line:</p><blockquote><p><code>my $tmpdsksize     = 512000;    # Must be larger than 250000<br
/> </code></p></blockquote><p>Change it to a larger number than 512 MB. Say you want it to be 2 GB:</p><blockquote><p><code>my $tmpdsksize     = 2097152;   # 2GB for the /tmp folder<br
/> </code></p></blockquote><p>Now close and save the file.</p><p>We need to stop all services that may be using this folder. For me, this includes MySQL, Apache and Nginx.</p><blockquote><p><code>service mysql stop<br
/> service nginx stop<br
/> service httpd stop<br
/> </code></p></blockquote><p>Now we will simply unmount the /tmp folder and recreate it. Here's the sequence of commands to create it:</p><blockquote><p><code>lsof /tmp<br
/> umount -l /tmp<br
/> umount -l /var/tmp<br
/> rm -fv /usr/tmpDSK<br
/> /scripts/securetmp<br
/> </code></p></blockquote><p>Done. You can verify the size of the /tmp folder among others:</p><blockquote><p><code>df -h<br
/> </code></p></blockquote><p>This should show you something like this:</p><blockquote><p><code>...<br
/> /usr/tmpDSK   ext3    2.0G  996M  1.1G  51%   /tmp<br
/> ...<br
/> </code></p></blockquote><p>NOTE: If you have any problems, for instance, the size of the recreated /tmp folder is not really 2GB despite that code in the /scripts/securetmp we changed, it may be because of some settings you have in the /etc/fstab file. Take a look at it and comment out any lines that interfere with the LABEL for /tmp mount.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/hosting/increase-size-of-tmp-folder-on-centos-linux-under-cpanel/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Create ringtones for iPhone on Mac OSX (for free)</title><link>http://sniptools.com/mac-osx/create-ringtones-for-iphone-for-free</link> <comments>http://sniptools.com/mac-osx/create-ringtones-for-iphone-for-free#comments</comments> <pubDate>Fri, 11 Dec 2009 17:59:30 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[iPhone]]></category> <category><![CDATA[Mac OSX]]></category><guid
isPermaLink="false">http://sniptools.com/?p=540</guid> <description><![CDATA[A simple app ought to do it. Download iRinger. It used to be a Windows app, but is now available for Mac OSX! A very intuitive application. Select a song (mp3 for example), it clips it and shows you the ringtone-worthy segment of it, you basically export it as a ".m4r" file. When done, just [...]]]></description> <content:encoded><![CDATA[<p>A simple app ought to do it.</p><p><a
href="http://www.iringer.net/"><img
src="http://www.iringer.net/img/mainss.png" alt="iRinger - Free app" /></a></p><p>Download <a
href="http://www.iringer.net/">iRinger</a>. It used to be a Windows app, but is now <a
href="http://www.macupdate.com/info.php/id/31517/ringer">available for Mac OSX</a>!</p><p>A very intuitive application. Select a song (mp3 for example), it clips it and shows you the ringtone-worthy segment of it, you basically export it as a ".m4r" file.</p><p>When done, just open the file and iTunes will automatically open it. Done.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/mac-osx/create-ringtones-for-iphone-for-free/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Finding non-UTF8 values in PostgreSQL</title><link>http://sniptools.com/databases/finding-non-utf8-values-in-postgresql</link> <comments>http://sniptools.com/databases/finding-non-utf8-values-in-postgresql#comments</comments> <pubDate>Thu, 23 Jul 2009 01:56:02 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[postgresql]]></category> <category><![CDATA[sql]]></category><guid
isPermaLink="false">http://sniptools.com/?p=528</guid> <description><![CDATA[This regexp worked for me. 1 2 3 4 5 6 7 8 9 10 11 12 SELECT * FROM TABLE WHERE NOT COLUMN ~ &#40; '^('&#124;&#124; $$&#91;\09\0A\0D\x20-\x7E&#93;&#124;$$&#124;&#124; -- ASCII $$&#91;\xC2-\xDF&#93;&#91;\x80-\xBF&#93;&#124;$$&#124;&#124; -- non-overlong 2-byte $$\xE0&#91;\xA0-\xBF&#93;&#91;\x80-\xBF&#93;&#124;$$&#124;&#124; -- excluding overlongs $$&#91;\xE1-\xEC\xEE\xEF&#93;&#91;\x80-\xBF&#93;&#123;2&#125;&#124;$$&#124;&#124; -- straight 3-byte $$\xED&#91;\x80-\x9F&#93;&#91;\x80-\xBF&#93;&#124;$$&#124;&#124; -- excluding surrogates $$\xF0&#91;\x90-\xBF&#93;&#91;\x80-\xBF&#93;&#123;2&#125;&#124;$$&#124;&#124; -- planes 1-3 $$&#91;\xF1-\xF3&#93;&#91;\x80-\xBF&#93;&#123;3&#125;&#124;$$&#124;&#124; -- planes 4-15 $$\xF4&#91;\x80-\x8F&#93;&#91;\x80-\xBF&#93;&#123;2&#125;$$&#124;&#124; [...]]]></description> <content:encoded><![CDATA[<p>This regexp worked for me.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #993333; font-weight: bold;">TABLE</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> ~ <span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'^('</span><span style="color: #66cc66;">||</span>
 $$<span style="color: #66cc66;">&#91;</span>\09\0A\0D\x20<span style="color: #66cc66;">-</span>\x7E<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>               <span style="color: #808080; font-style: italic;">-- ASCII</span>
 $$<span style="color: #66cc66;">&#91;</span>\xC2<span style="color: #66cc66;">-</span>\xDF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>             <span style="color: #808080; font-style: italic;">-- non-overlong 2-byte</span>
  $$\xE0<span style="color: #66cc66;">&#91;</span>\xA0<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>        <span style="color: #808080; font-style: italic;">-- excluding overlongs</span>
 $$<span style="color: #66cc66;">&#91;</span>\xE1<span style="color: #66cc66;">-</span>\xEC\xEE\xEF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>  <span style="color: #808080; font-style: italic;">-- straight 3-byte</span>
  $$\xED<span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\x9F<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>        <span style="color: #808080; font-style: italic;">-- excluding surrogates</span>
  $$\xF0<span style="color: #66cc66;">&#91;</span>\x90<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>     <span style="color: #808080; font-style: italic;">-- planes 1-3</span>
 $$<span style="color: #66cc66;">&#91;</span>\xF1<span style="color: #66cc66;">-</span>\xF3<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">|</span>$$<span style="color: #66cc66;">||</span>          <span style="color: #808080; font-style: italic;">-- planes 4-15</span>
  $$\xF4<span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\x8F<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span>\x80<span style="color: #66cc66;">-</span>\xBF<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#125;</span>$$<span style="color: #66cc66;">||</span>      <span style="color: #808080; font-style: italic;">-- plane 16</span>
 <span style="color: #ff0000;">')*$'</span> <span style="color: #66cc66;">&#41;</span>
;</pre></td></tr></table></div><p>Or, if you have iconv on your system, as most UNIX variants do, you can pg_dumpall a database and run the following command on it:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">@</span>iconv<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$input</span>, <span style="color: #ff0000;">'UTF-8'</span>, <span style="color: #ff0000;">'UTF-8'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> == <span style="color: #007800;">$input</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Good UTF-8!&quot;</span>; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Nope.&quot;</span></pre></div></div><p>Then take a plain text pg_dump of the database in UTF-8. Let's call it "db.orig.dmp". Strip all problem characters:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">iconv <span style="color: #660033;">-f</span> UTF-<span style="color: #000000;">8</span> <span style="color: #660033;">-t</span> UTF-<span style="color: #000000;">8</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">&lt;</span>db .orig.dmp <span style="color: #000000; font-weight: bold;">&gt;</span>db.stripped.sql
<span style="color: #000000; font-weight: bold;">&lt;/</span>db<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div><p>Compare both files:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">-u</span> db.orig.dmp db.stripped.sql</pre></div></div><p>That output will show all lines containing a problem character. Now the tedious part: Use "db.orig.dmp" to find out which tables they belong to, locate the records in the database by primary key and fix them. Alternatively, you can use iconv's auto-repair if you know which bytes give you a problem.</p><p>For example, if you know that the trouble stems only from 0x80 bytes that should be Euro symbols, you could:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">iconv <span style="color: #660033;">-f</span> UTF-<span style="color: #000000;">8</span> <span style="color: #660033;">-t</span> UTF-<span style="color: #000000;">8</span> <span style="color: #660033;">--byte-subst</span>=<span style="color: #ff0000;">&quot;&amp;lt;0x%x&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> db.orig.sql <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/&amp;lt;0x80&gt;/EUR/g'</span> <span style="color: #000000; font-weight: bold;">&gt;</span>db.fixed.sql</pre></div></div><p>The resulting "db.fixed.sql" could then be loaded into the new database.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/databases/finding-non-utf8-values-in-postgresql/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>KeepVid: saving videos from Youtube or Vimeo, from anywhere</title><link>http://sniptools.com/webtools/keepvid-saving-videos-from-youtube-or-vimeo-from-anywhere</link> <comments>http://sniptools.com/webtools/keepvid-saving-videos-from-youtube-or-vimeo-from-anywhere#comments</comments> <pubDate>Mon, 02 Feb 2009 04:54:06 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Web Tools]]></category> <category><![CDATA[Tips/Tricks]]></category> <category><![CDATA[video]]></category><guid
isPermaLink="false">http://sniptools.com/?p=455</guid> <description><![CDATA[If you use Firefox (and if not, what are you waiting for?) you are familiar with useful extensions such as Video Downloader, which allow you to save local copies of the videos you watch on websites such as Youtube or Vimeo. You can then watch these videos whenever you please. But this doesn't account for [...]]]></description> <content:encoded><![CDATA[<p>If you use Firefox (and if not, what are you waiting for?) you are familiar with <a
href="https://addons.mozilla.org/en-US/firefox/search?q=video++downloader&#038;cat=all">useful extensions</a> such as Video Downloader, which allow you to save local copies of the videos you watch on websites such as Youtube or Vimeo. You can then watch these videos whenever you please.</p><p>But this doesn't account for those rare but possible times when you are not on your machine, or don't have access to a browser set up to your tastes. No extensions available.</p><p>That's where "<a
href="http://keepvid.com/">KeepVid</a>" comes in. Just enter your URL and it automatically extracts any video(s) found on that website and allows you to download in both FLV and MP4 formats. The MP4 would play on your Nokia, iPhone, or Blackberry too. The FLV file is a flash viewer file, and easily played using common video players–if you don't have <a
href="http://www.videolan.org/vlc/">VLC</a>, get it pronto.</p><p>Here's a straightforward screenshot:</p><p><img
src="http://farm4.static.flickr.com/3299/3246681630_d42704b048.jpg" alt="KeepVid screenshot saving a Youtube video" /></p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/webtools/keepvid-saving-videos-from-youtube-or-vimeo-from-anywhere/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Resize a column in a PostgreSQL table without changing data</title><link>http://sniptools.com/databases/resize-a-column-in-a-postgresql-table-without-changing-data</link> <comments>http://sniptools.com/databases/resize-a-column-in-a-postgresql-table-without-changing-data#comments</comments> <pubDate>Tue, 13 Jan 2009 05:49:21 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Databases]]></category> <category><![CDATA[postgresql sql databases]]></category><guid
isPermaLink="false">http://sniptools.com/?p=432</guid> <description><![CDATA[You use PostgreSQL. You find that a column you have in a table is of a smaller length than you now wish. In my case, this was a varchar(20) that I now wished to make varchar(35). Nothing else. I just want to change the size, keeping the data intact. The ALTER TABLE ...ALTER COLUMN...TYPE... command [...]]]></description> <content:encoded><![CDATA[<p>You use PostgreSQL. You find that a column you have in a table is of a smaller length than you now wish. In my case, this was a <code>varchar(20)</code> that I now wished to make <code>varchar(35)</code>. Nothing else. I just want to change the size, keeping the data intact.</p><p>The <code>ALTER TABLE ...ALTER COLUMN...TYPE...</code> <a
href="http://www.postgresql.org/docs/current/interactive/sql-altertable.html">command</a> is useful only if you want to alter the data somehow, or change the data type. Otherwise, it'll be an aeon before this finishes even inside a transaction on a database of any meaningful size.</p><p>Until now, I was not familiar with any sensible mechanism to simply change the size in PG. But yesterday, Tom Lane himself suggested something ubercool in the list.</p><p>Let's assume for the sake of simplicity that your table is called "<code>TABLE1</code>" and your column is "COL1". You can find the size of your "<code>COL1</code>" column by issuing the following query on the system tables:</p><div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> atttypmod <span style="color: #993333; font-weight: bold;">FROM</span> pg_attribute
<span style="color: #993333; font-weight: bold;">WHERE</span> attrelid <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'TABLE1'</span>::regclass
<span style="color: #993333; font-weight: bold;">AND</span> attname <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'COL1'</span>;
&nbsp;
atttypmod
<span style="color: #808080; font-style: italic;">-----------</span>
<span style="color: #cc66cc;">24</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ROW</span><span style="color: #66cc66;">&#41;</span></pre></div></div><p>This means that the size is 20 (4 is added for legacy reasons, we're told). You can now conveniently change this to a <code>varchar(35)</code> size by issuing this command:</p><div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> pg_attribute <span style="color: #993333; font-weight: bold;">SET</span> atttypmod <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">35</span><span style="color: #66cc66;">+</span><span style="color: #cc66cc;">4</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> attrelid <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'TABLE1'</span>::regclass
<span style="color: #993333; font-weight: bold;">AND</span> attname <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'COL1'</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #cc66cc;">1</span></pre></div></div><p>Note that I manually added the 4 to the desired size of 35..again, for some legacy reasons inside PG. Done. That's it. Should we check?</p><div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;">d TABLE1
&nbsp;
<span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;public.TABLE1&quot;</span>
<span style="color: #993333; font-weight: bold;">COLUMN</span>  <span style="color: #66cc66;">|</span>  <span style="color: #993333; font-weight: bold;">TYPE</span>                 <span style="color: #66cc66;">|</span> Modifiers
<span style="color: #808080; font-style: italic;">--------+-----------------------+-----------</span>
COL1    <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">CHARACTER</span> <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">35</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span></pre></div></div><p>Such a simple yet effective trick. Of course it'd be nicer if this is somehow included in a more proper way in the database, but this does the job.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/databases/resize-a-column-in-a-postgresql-table-without-changing-data/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Recovering Bad Hard Disks (CRC on Windows, Error –36 on Mac OSX)</title><link>http://sniptools.com/windows/fix-crc-hard-disk-error-recover-data</link> <comments>http://sniptools.com/windows/fix-crc-hard-disk-error-recover-data#comments</comments> <pubDate>Sun, 05 Oct 2008 02:58:23 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Mac OSX]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[hard disk]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[storage]]></category><guid
isPermaLink="false">http://sniptools.com/?p=423</guid> <description><![CDATA[So you've been visited by the much dreaded CRC — Cyclical Redundancy Check error, most likely encountered while copying files between hard disks. On Mac OSX, this will usually appear as some cryptic permissions message with an Error –36. To cut the geek-speak, this simply means that you hard disk may have certain files that [...]]]></description> <content:encoded><![CDATA[<p>So you've been visited by the much dreaded CRC — <a
href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">Cyclical Redundancy Check error</a>, most likely encountered while copying files between hard disks. On Mac OSX, this will usually appear as some cryptic permissions message with an <a
href="http://support.apple.com/kb/HT1618">Error –36</a>.</p><p>To cut the geek-speak, this simply means that you hard disk may have certain files that may have "bad sectors", or are corrupted in other words.</p><p>Fortunately, this is a common enough problem in our technically advanced world of external storage. I recommend solving this on Windows (I use both XP and OSX Leopard at the time of this writing).</p><h3>Step 1: CHKDSK</h3><p>Use what Windows offers you by default. The <code>chkdsk</code> command. Just open an MS-DOS command prompt window and go to the drive you wish to check (I'm hoping you already know your way around a command prompt; if you don't please consider Step 2 below). With the command prompt showing the drive letter of the disk you wish to check, enter this command:</p><pre>e:&gt; chkdsk /R</pre><p>Here, "<code>e:</code>" is my drive to be checked. The "<code>/R</code>" attribute asks the <code>chkdsk</code> command to "recover" whatever bad sectors it finds during its scan. In most cases, and if you're lucky, this ought to do it.</p><h3>Step 2: CDCheck (Free)</h3><p>Only if the problem you were facing still remains after you have run the chkdsk command, should you consider doing this. This is <a
href="http://www.kvipu.com/CDCheck/helplink.php?helpfn=overview">a freeware program</a> that makes it super-easy to check/recover your disk. It can be any disk–your current hard disk, a CD or a DVD, or even an external hard disk. The interface is pretty simple as you can see in the <a
href="http://www.kvipu.com/CDCheck/helplink.php?helpfn=screenshots">screenshots here</a>.</p><h3>Step 3: SpinRite (US$ 90)</h3><p>If all else has failed, just save yourself some heartburn and go straight to SpinRite. This is hands-down the <a
href="http://www.grc.com/sr/spinrite.htm">best software for this purpose</a>, as anyone in a dire need of data recovery will confirm. I would trust any piece of software from GRC. Only catch: it's not free, but when you use it you know why it's worth every last cent. It gives you a simple option to save an ISO file, which you can then easily burn on to a CD using any CD writer tool (including Windows' own right-click). Then reboot your machine so it starts from the CD. SpinRite will automatically report and recover whatever is recoverable.</p><h2>Next Steps</h2><p>Basically, a CRC error is the beginning of the end. If this is on an external hard disk, I highly recommend that you consider backing up the data immediately.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/windows/fix-crc-hard-disk-error-recover-data/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 1/5 queries in 0.001 seconds using disk: basic
Object Caching 1257/1259 objects using disk: basic

Served from: sniptools.com @ 2012-05-17 19:09:29 -->
