<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>The Magic DIrk</title><link>http://dirk.sh/</link><description>我们所命定的目标，不是享乐，不是受苦，而是行动，在每一个明天，都要比今天前进一步。</description><atom:link href="https://dirk.sh/xml/rss/feed.xml" rel="self"></atom:link><language>zh_cn</language><lastBuildDate>Wed, 16 Apr 2014 22:22:37 +0800</lastBuildDate><ttl>40</ttl><item><title>Mac OS X 下 /bin/csh 加载配置信息的完整顺序</title><link>http://dirk.sh/diary/full-read-order-of-csh-login-loading-under-MacOS/</link><description>&lt;p&gt;今天在 Mac 下配置一个 Go Lang 的开发环境，我是使用 /bin/csh 作为默认 shell（爱上了其强大的历史命令回溯功能），所以需要将 $GOPATH 设置到 ~/.cshrc 文件里：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;setenv GOPATH /export/projects/mygo
set path = ($path $GOPATH/bin)&lt;/pre&gt;&lt;p&gt;设置后发现不能自动加载，即使重新启动系统也无效。每次需要手动 &amp;quot;source ~/.cshrc&amp;quot; 才能生效。&lt;/p&gt;
&lt;p&gt;经过不断摸索和研究，发现这是由于我的 Home 目录下存在 .tcshrc 文件引起的问题。tcsh（MacOS 下的 csh 与 tcsh 相同）在登录、开启终端时会依照以下顺序读取配置文件：&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;/etc/csh.cshrc : Read first by every shell.&lt;/li&gt;
&lt;li&gt;/etc/csh.login : Read by login shells after /etc/csh.cshrc.&lt;/li&gt;
&lt;li&gt;~/.tcshrc : Read by every shell after /etc/csh.cshrc.&lt;/li&gt;
&lt;li&gt;~/.cshrc : Read by every shell, if ~/.tcshrc doesn't exist.&lt;/li&gt;
&lt;li&gt;~/.history : Read by login shells after ~/.tcshrc if savehist is set, but see also histfile.&lt;/li&gt;
&lt;li&gt;~/.login : Read by login shells after ~/.tcshrc or ~/.history.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;找到问题所在，将 ~/.tcshrc 文件移除即可（该文件是 Macports 自动安装，无实际设置）。&lt;/p&gt;
</description><pubDate>Wed, 16 Apr 2014 22:22:37 +0800</pubDate><guid>http://dirk.sh/diary/full-read-order-of-csh-login-loading-under-MacOS/</guid><category>Macintosh</category></item><item><title>iOS 7 为何要把“向右滑动删除”改为向左？</title><link>http://dirk.sh/diary/why-ios7-changed-swipe-right-to-delete-to-swipe-left/</link><description>&lt;p&gt;最新的 iOS 7 里大量使用了向右滑动返回上级视图的机制，这就与原先 UITableView 下向右滑动表示删除的功能有所冲突（比如短信、邮件等等），所以，在 iOS 7 里将原先的往左往右都可以删除条目的功能修改为只能向左滑动才可以删除。&lt;/p&gt;
</description><pubDate>Fri, 27 Sep 2013 09:15:11 +0800</pubDate><guid>http://dirk.sh/diary/why-ios7-changed-swipe-right-to-delete-to-swipe-left/</guid><category>iPhone</category></item><item><title>联通页面JavaScript强制注入的“域名纠错”</title><link>http://dirk.sh/diary/shit-lndnserror-x-wo-com-cn/</link><description>&lt;p&gt;以往见识过的联通所谓“域名纠错”页面是通过DNS劫持来实现的，我们只需要使用联通之外的DNS服务器即可避免。&lt;/p&gt;
&lt;p&gt;最近发现联通在某些页面尾部强制注入JavaScript来显示“域名纠错”页面的，这个问题现在可能只出现于个别网站或者个别页面，具体是否注入的判断条件未知，可能和某些页面内容相关。&lt;/p&gt;
&lt;p&gt;垃圾公司，垃圾内容，只能暂时屏蔽 lndnserror2.wo.com.cn 相关地址。&lt;/p&gt;
&lt;p&gt;联通在页面底部注入以下JavaScript内容：&lt;/p&gt;
&lt;img src="https://img.dirk.sh/illustration/a8/93/a97cf406ab848d0e000ab0943b259038/600.jpg{$ASSET_UUID$}" alt="狗屎 lndnserror2.wo.com.cn" class="tc-illustration" /&gt;</description><pubDate>Fri, 27 Sep 2013 08:55:10 +0800</pubDate><guid>http://dirk.sh/diary/shit-lndnserror-x-wo-com-cn/</guid><category>TMD生活</category></item><item><title>用谷歌浏览器模拟手机浏览器</title><link>http://dirk.sh/diary/user-google-chrome-to-simulate-mobile-browser/</link><description>&lt;p&gt;　　很多网站都通过 HTTP 头信息中的 User-Agent 标志来判断设备和浏览器类型，如果是 3G 手机，显示手机页面内容，如果是普通浏览器，显示普通网页内容。&lt;/p&gt;
&lt;p&gt;　　谷歌的 &lt;a class="reference external" href="http://www.google.com/chrome/"&gt;Chrome&lt;/a&gt; 浏览器，可以很方便的用来模拟手机下的浏览器，这样测试移动网站和页面就变得非常方便。&lt;/p&gt;
&lt;p&gt;　　在 Mac OS X 的“终端”窗口 (Terminal.app) 中输入以下命令启动谷歌浏览器，就可以模拟不同手机设备下的移动浏览器去访问 3G 手机网页：&lt;/p&gt;
&lt;p&gt;　　谷歌 Android：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;open 'Google Chrome.app' --args '--user-agent="Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"'&lt;/pre&gt;&lt;p&gt;　　苹果 iPhone：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;open 'Google Chrome.app' --args '--user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"'&lt;/pre&gt;&lt;p&gt;　　苹果 iPad：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;open 'Google Chrome.app' --args '--user-agent="Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"'&lt;/pre&gt;&lt;p&gt;　　三星手机：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;open 'Google Chrome.app' --args '--user-agent="Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; GT-S6010 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"'&lt;/pre&gt;&lt;p&gt;　　更多手机浏览器的 User-Agent 标识：&lt;a class="reference external" href="http://www.zytrax.com/tech/web/mobile_ids.html"&gt;http://www.zytrax.com/tech/web/mobile_ids.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;　　如果想切换回普通浏览器模式，彻底关闭 Chrome 浏览器后重新开启即可（Command + Q 快捷键）。&lt;/p&gt;
</description><pubDate>Thu, 05 Sep 2013 09:43:20 +0800</pubDate><guid>http://dirk.sh/diary/user-google-chrome-to-simulate-mobile-browser/</guid><category>移动开发</category></item><item><title>Godaddy Live Promotion Coupon Codes - 2013 August</title><link>http://dirk.sh/diary/godaddy-live-promotion-coupon-codes-2013-august/</link><description>&lt;p&gt;Popular Codes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Special Offer! Save 30%* Off Your Order of $100 or More! -Jul2013d&lt;/li&gt;
&lt;li&gt;SAVE 30%* off your order of $130 or more! - gd3733bb&lt;/li&gt;
&lt;li&gt;Special Savings! $2.99 . COMs at Godaddy! - CJC299C&lt;/li&gt;
&lt;li&gt;Special Offer! .COM Just $0.99*! Additional .COMs Just $9.99* per Year! - 99COMS / HINCH199 / FBTGT9&lt;/li&gt;
&lt;li&gt;Save 35% Off First Order - CJC35NC&lt;/li&gt;
&lt;li&gt;Save 30% Off Your Order of No Minimum! -   GDBBE1026 / GDBBE994 /  GDBBE1562 /  GDX737W /  BBTLD30 / GDBBIA1562 / GDBBIA1026&lt;/li&gt;
&lt;li&gt;Save More Then 90% on SSL Certificates! -Just $12.99* for The First Year! - CJCSSL12T2&lt;/li&gt;
&lt;li&gt;Save 30% - Hosting Renewal Included! - GDBBHA994 / GDBBHA1026  ( Expires : July 06, 2013)&lt;/li&gt;
&lt;/ul&gt;
&lt;a name="fulltext"&gt;&lt;/a&gt;&lt;p&gt;General Godaddy Codes (All codes tested on 01 July 2013)&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Save 10$ off your order 50$ or more - cjcsave10&lt;/li&gt;
&lt;li&gt;SPECIAL OFFER! SAVE 10% OFF YOUR ORDER! Private Registrations just $3.99 per year! - gdbb776&lt;/li&gt;
&lt;li&gt;SAVE 15%* off your order - gdbbd566&lt;/li&gt;
&lt;li&gt;SAVE 15%* off your purchase of $50 or more - gdbba1583&lt;/li&gt;
&lt;li&gt;Save 25% from any purchase over $60 - gd3747y&lt;/li&gt;
&lt;li&gt;Save 25% from any purchase over $75 - gdbb1901&lt;/li&gt;
&lt;li&gt;Get 25% OFF* your order of $100 or more - gdbbc730&lt;/li&gt;
&lt;li&gt;Save 25% from any order- No Minimum! - bb1964dd5 /HPFBE25 /  HPFB3E25&lt;/li&gt;
&lt;li&gt;Save 25%* off your next purchase of $75 or more - GDBBA2228&lt;/li&gt;
&lt;li&gt;Save 20% off your order of $65 or more* - gdbbi729 / GDBBE729 / GDBBE2093&lt;/li&gt;
&lt;li&gt;Save 30% from any order- No Minimum!- gdbbe1026 / gdbbe994 /  gdbbe1562 /  gdx737w /  bbtld30 / gdbbia1562 / gdbbia1026&lt;/li&gt;
&lt;li&gt;Save 30%* off your order of $100 or more! - DEC2012B&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Godaddy Domain Promo Codes (All codes tested on 01 July 2013)&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;SPECIAL SAVINGS! $2.99 . COMs at GoDaddy! - cjc299c&lt;/li&gt;
&lt;li&gt;SPECIAL OFFER! NEW .COMs just $4.00* up to 3 domains! Additional .COMs $9.99 * per year! -  cjc4c&lt;/li&gt;
&lt;li&gt;SPECIAL OFFER! .COM just $0.99*! Additional .COMs just $9.99* per year! - 99COMS  / HINCH199&lt;/li&gt;
&lt;li&gt;Smoking Hot Savings! .COMs just $5.99* per year up to 5 domains! - cjc599V&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Godaddy Hosting Promo Codes (All codes tested on 17/06/2013)&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;SPECIAL OFFER! 15% Off Dedicated/Virtual Dedicated Server Purchase. - fbServer15 (Expires 30/6/2013)&lt;/li&gt;
&lt;li&gt;Save an additional 20% off Web Hosting -- 1, 2 or 3 year plans! - cjcchp20&lt;/li&gt;
&lt;li&gt;Web Hosting from just $1.99 per month for 3 months! - cjc199HSTG&lt;/li&gt;
&lt;li&gt;Save 20% off new hosting plans - cjc20hst1&lt;/li&gt;
&lt;li&gt;The power of the Cloud for 25% off with Virtual DataCenter from GoDaddy.com - cjcVDC25&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Promo Codes for Other Products&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Take 80% Off SSL Certificates, now only $4.99.Applies to 1st year new SSL- LKSRTL499&lt;/li&gt;
&lt;li&gt;Secure Certificate offer! Standard SSL Certificates -- Just $12.99* for the first year! - cjcssl12t2&lt;/li&gt;
&lt;li&gt;Save 20% off costum website design. - cjc20cwd&lt;/li&gt;
&lt;li&gt;SAVE 30%* on Online Storage plans! - gdx539a&lt;/li&gt;
&lt;li&gt;Save 20% off premium ssl certificates! - cjcSSLP20c&lt;/li&gt;
&lt;li&gt;Godaddy Auction Discount-save more then 40% - AUCTION12&lt;/li&gt;
&lt;li&gt;Save an EXTRA 20%* on Premium Search Engine Visibility plans! -cjcsev20&lt;/li&gt;
&lt;/ul&gt;
</description><pubDate>Wed, 04 Sep 2013 19:55:37 +0800</pubDate><guid>http://dirk.sh/diary/godaddy-live-promotion-coupon-codes-2013-august/</guid><category>Web开发</category></item><item><title>禁用 UIWebView 里面的链接长按弹出效果</title><link>http://dirk.sh/diary/disable_popup_menu_in_uiwebview/</link><description>&lt;p&gt;　　苹果的审核越来越严格，现在都会拒绝单纯用 UIWebView 内嵌 HTML5 页面的 iPhone、iPad APP应用上架到 App Store，建议这样的 APP 去做成 Safari 的 Web 应用。但是，苹果的审核人员只从界面、URL 去判断是否 HTML5 的。如果一个 APP 应用的 URL 地址被他们拷贝出来，放到浏览器中能够访问，应用就会悲催地被拒绝上架。&lt;/p&gt;
&lt;p&gt;　　对付方法：&lt;/p&gt;
&lt;p&gt;　　1、URL不让直接通过浏览器访问（在 UIWebView 的请求 Header 中附加点自有的特殊标志，以便在服务器端将 APP 内嵌的访问和通过浏览器直接访问区分开来），或者通过浏览器访问时，返回 JSON、XML 信息，甚至输出 “Interface Error”，忽悠苹果审核人员说这是 HTTP 协议下的数据接口，不是单纯的网页。&lt;/p&gt;
&lt;p&gt;　　2、禁用、禁止 UIWebView 里面的链接长按弹出效果。在所加载文件中加入一行 CSS 代码，禁用类似下图的链接长按弹出效果：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;html, body { -webkit-touch-callout: none; }&lt;/pre&gt;</description><pubDate>Tue, 03 Sep 2013 08:14:10 +0800</pubDate><guid>http://dirk.sh/diary/disable_popup_menu_in_uiwebview/</guid><category>iPhone</category></item><item><title>你妹的，iPhone丢失后Apple的不作为</title><link>http://dirk.sh/diary/apple_do_not_use_locate_when_iphone_lost/</link><description>&lt;p&gt;网上盛传的都是如何利用 MobileMe （新版是 iCloud）定位遗失的 iPhone，但要求预先绑定了 ID 并开启了定位服务。而对于没有来得及绑定 ID 并开启定位服务的用户，只能自认倒霉；在北京，号称去派出所开具遗失证明后可以到苹果专卖店登记，如果发现对应序列号 iPhone 就通知。这种消极的等待纯粹是苹果的推诿之词，根本不为用户着想；实际，你根本别指望能靠这种方式再找回你的 iPhone。&lt;/p&gt;
&lt;p&gt;去他妹的。其实只要 iPhone 一开启，不管是否插入了 SIM 卡，也不管是否绑定 ID 和开启定位服务，苹果的定位机制立马就可以跟踪到，能发送信息、能锁定，也能抹掉信息。苹果啊苹果，你妹的，你就是希望丢失的用户找不回来，你就是希望自己卖出更多的设备。&lt;/p&gt;
&lt;p&gt;所以，另一方面，用 iPhone 的用户要小心，其实你真没啥隐私可言。&lt;/p&gt;
&lt;p&gt;（另外，3G 版的 iPad 也是如此啦！）&lt;/p&gt;
</description><pubDate>Tue, 07 Feb 2012 22:14:02 +0800</pubDate><guid>http://dirk.sh/diary/apple_do_not_use_locate_when_iphone_lost/</guid><category>iPhone</category></item><item><title>Mac OS X 下刷新 DNS 缓存</title><link>http://dirk.sh/diary/how-to-flush-dns-cache-in-mac-os-x-lion/</link><description>&lt;p&gt;对于低版本系统，在命令行窗口（terminal）输入 lookupd -flushcache 即可：&lt;/p&gt;
&lt;pre name="code" class="brush: shell"&gt;[idesk@imac:~]$ sudo lookupd -flushcache&lt;/pre&gt;&lt;p&gt;命令执行完毕，你的DNS缓存就得到了更新。&lt;/p&gt;
&lt;p&gt;对于较新的苹果 Mac OS X 系统应该使用下面的命令：&lt;/p&gt;
&lt;pre name="code" class="brush: css"&gt;[idesk@imac:~]$ sudo dscacheutil -flushcache&lt;/pre&gt;</description><pubDate>Fri, 09 Dec 2011 20:11:45 +0800</pubDate><guid>http://dirk.sh/diary/how-to-flush-dns-cache-in-mac-os-x-lion/</guid><category>Macintosh</category></item><item><title>Lion 下无线经常断线的临时解决方法</title><link>http://dirk.sh/diary/how-to-fix-airpoint-break-status-in-lion/</link><description>&lt;p&gt;Lion 下无线网络总是时不时的断线，而系统栏显示的状态没问题，每次都要关闭再开启一下无线才能恢复，有时候晚上无人看守的传东西经常中途断了，结果传输没完成，还浪费一晚的电费。&lt;/p&gt;
&lt;p&gt;没太多时间和精力去研究，暂时写了一个 shell 脚本检测网络状态，如果断了，自动关闭再开启一下网络端口，虽然不能百分百解决问题，但 99.99% 的情况下能用，基本能连续保持几天的连接状态。&lt;/p&gt;
&lt;pre name="code" class="brush: plain"&gt;#!/bin/sh

echo "AirPort Monitor start at `date`"

while [ 1 ] ; do
    ping -v -c 4 192.168.0.1 &gt; /dev/null 2&gt;&amp;1
    PINGSTA=$?

    if [ ! $PINGSTA -eq 0 ]; then
        echo "Lost AirPort, refresh now... `date` ..."
        ifconfig en1 down
        sleep 5
        ifconfig en1 up
        echo "Done."
    fi

    sleep 60
done&lt;/pre&gt;</description><pubDate>Wed, 30 Nov 2011 11:44:19 +0800</pubDate><guid>http://dirk.sh/diary/how-to-fix-airpoint-break-status-in-lion/</guid><category>Macintosh</category></item><item><title>Firefox下FoxyProxy的DNS污染问题</title><link>http://dirk.sh/diary/foxyproxy-firefox-dns-leaking/</link><description>&lt;p&gt;最近将 Lion 下的 Firefox 升级到了 8.x 版本系列，速度还是有所提升的；但在更新 FoxyProxy 插件后，发现通过 SSH 代理没法访问 &lt;a class="reference external" href="http://twitter.com"&gt;http://twitter.com&lt;/a&gt; 了。刚开始还以为 VPN 服务器出了故障，但访问某些过滤网站没问题。研究了一下，发现是遭遇 DNS 污染了，而且原因是 FoxyProxy 插件引起的。&lt;/p&gt;
&lt;p&gt;网上搜搜了好久，找到了解决方法。&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;1、将 FoxyProxy 一切照常设置妥当。&lt;/li&gt;
&lt;li&gt;2、在 Firefox 地址栏输入“&lt;a class="reference external" href="about:config"&gt;about:config&lt;/a&gt;”开启设置页面；&lt;/li&gt;
&lt;li&gt;3、在过滤输入框输入“network.proxy”；&lt;/li&gt;
&lt;li&gt;4、将“network.proxy.type”设置修改为数字“1”；&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;据说这是 FoxyProxy 本身没有正确设置引起的 DNS 污染故障。&lt;/p&gt;
&lt;p&gt;熊啊！&lt;/p&gt;
</description><pubDate>Wed, 30 Nov 2011 11:35:18 +0800</pubDate><guid>http://dirk.sh/diary/foxyproxy-firefox-dns-leaking/</guid><category>TMD生活</category></item></channel></rss>