New API: Expand URL

Today, the Internet is flooded with shortened URL. All links shared on Twitter are shortened (start with t.co). There is nothing wrong with it. I just don’t feel comfortable clicking a shortened URL without knowing where it will bring me to. How paranoid I am! There are several reason I don’t trust shortened URL: They might contain tracking or referral code. SlickDeals heavily uses it (to make money, of course). Again, there is nothing wrong with it. They provide you a service and they deserve to get some money out of it. They might hide malicious URL, like XSS I hate them! There are several expand URL services out there, however they just support a very limited set of URL shorten service. What I want is something more. I want to be able to track the final URL after a bunch of redirections. So I wrote this API: http://api.codepie.org/expand_url/<your_url_here_no_escape_needed> For example: http://api.codepie.org/expand_url/http://slickdeals.net/?pno=128958&lno=1&afsrc=1&trd=Newegg+com Here is the API result. You will be amazed how many hops it take to the final destination: http://slickdeals.net/?pno=128958&lno=1&afsrc=1&trd=Newegg+com http://www.jdoqocy.com/click-1225267-10440897?sid=1fea0918ac5e454fa2fc89be4e70d43b&url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3Fsdtid%3D7164970%26SID%3D1fea0918ac5e454fa2fc89be4e70d43b%26AID%3D10440897%26PID%3D1225267%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-cables-_-na-_-na%26Item%3D03V-003G-00433 http://cj.dotomi.com/a6106ar-zH/ry2/GFJJFNOM/GHHKHLM/F/F/F?c=v5vq%3DEsrnDMELnpIrHIHsnFspLMorHrKDqHGo%2674y%3Du662%25GN%25FS%25FS999.0r9rtt.p1z%25FSc41q7p6%25FSc41q7p6.n52A%25GS5q6vq%25GQKEJHMKD%25FJfVQ%25GQEsrnDMELnpIrHIHsnFspLMorHrKDqHGo%25FJNVQ%25GQEDHHDLMK%25FJcVQ%25GQEFFIFJK%25FJ0z_zp%25GQNSP-PLW70p6v10%25FJpz_zzp%25GQNSP-PLW70p6v10-_-pnoyr5-_-0n-_-0n%25FJV6rz%25GQDGi-DDGT-DDHGG%3C%3Cu662%3A%2F%2F999.wq131pB.p1z%3ALD%2Fpyvpx-EFFIFJK-EDHHDLMK%3C%3CT%3Cu6625%3A%2F%2F999.t11tyr.p1z%2F%3C http://www.emjcd.com/h4102tenm6/elq/32662AB9/3447489/2/39292468268596B574/87Ad4g9d4ggd33g6A24f3A25952f57g5?c=zC2x%3DLzyuKTLSuwPyOPOzuMzwSTvyOyRKxONv%26EB5%3D1DD9%25NU%25MZ%25MZGGG.7yGy00.w86%25MZjB8xEwD%25MZjB8xEwD.uC9H%25NZCxD2x%25NXRLQOTRK%25MQmcX%25NXLzyuKTLSuwPyOPOzuMzwSTvyOyRKxONv%25MQUcX%25NXLKOOKSTR%25MQjcX%25NXLMMPMQR%25MQ76_6w%25NXUZW-WSdE7wD287%25MQw6_66w%25NXUZW-WSdE7wD287-_-wuv5yC-_-7u-_-7u%25MQcDy6%25NXKNp-KKNa-KKONN%3Cw38!GQ96-PAKTEzy%3C1DD9%3A%2F%2FGGG.3x8A8wI.w86%3ASK%2Fw52w4-LMMPMQR-LKOOKSTR%3C%3Ca%3C1DD9C%3A%2F%2FGGG.08805y.w86%2F%3C http://www.newegg.com/Common/AdvancedLinkLanding.aspx?nm_mc=AFC-C8Junction&cm_mmc=AFC-C8Junction-_-na-_-na-_-na&AID=10440897&PID=1225267&SID=1fea0918ac5e454fa2fc89be4e70d43b&URL=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3Fsdtid%3D7164970%26SID%3D1fea0918ac5e454fa2fc89be4e70d43b%26AID%3D10440897%26PID%3D1225267%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-cables-_-na-_-na%26Item%3D03V-003G-00433 http://www.newegg.com/Product/Product.aspx?sdtid=7164970&SID=1fea0918ac5e454fa2fc89be4e70d43b&AID=10440897&PID=1225267&nm_mc=AFC-C8Junction&cm_mmc=AFC-C8Junction-_-cables-_-na-_-na&Item=03V-003G-00433&cm_sp= Suggestions welcome!

beautyofnewyork.com and wigtypes.com are likely to be the same company

Normally I don’t care who owns what. However, when it come to spam email, it’s a completely different problem. I hate spam. Yes. I setup a specific domain to act as honeypot to catch spam. This week I received more than 3 emails from wigtypes.com under the email I submitted into beautyofnewyork.com. I don’t remember giving my email to wigtypes.com and I generated an unique email every time I submit to a website. Surprise? In their websites, there is no link to each other and they don’t claim they are the same company either. So who the hell give wigtypes.com the permission to spam me? They share the same address, same phone number and used to be in the same server. In my opinion, they are likely to be the same, or under the same owner. Some information: https://web.archive.org/web/20140826173318/http://myip.ms/info/whois/208.109.184.216/k/4212716814/website/wigtypes.com https://web.archive.org/web/20140826174529/http://www.telephoneactivity.com/516/307/1851.html

Speedtest for your Linux server

Have you ever wonder how to test network speed (Internet specifically) of your server? Well, with GUI you can use something like speedtest.net, but how about CLI server, where you only have command-line interface? There are indeed several option: 1. Speedtest for CLI: https://pypi.python.org/pypi/speedtest-cli Install: easy_install speedtest-cli Use: speedtest 2. wget You first need to find some “big” files. My favorite is Ubuntu image: http://mirror.anl.gov/pub/ubuntu-iso/DVDs/ubuntu/14.04/release/ubuntu-14.04-server-amd64+mac.iso Use: wget -O /dev/null your_link It will actually not save anything on your system, so you don’t have to deal with clean up stuffs after you’ve done.

DigitalOcean droplets (at least for NYC2 region) are having trouble connecting to 4.2.2.2

I noticed a noticeable degrade in network performance in my droplets. It took forever to open a connection. It happened from last week I guess. Restart server does not help. I though it’s just temporary. However today I noticed that, DigitalOcean by default assign 2 DNS servers for every droplet in NYC2 region: nameserver 4.2.2.2 nameserver 8.8.8.8 Here is the result for ping from my droplet to both servers: tuananh@codepie:~$ ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_req=1 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=2 ttl=46 time=13.8 ms 64 bytes from 8.8.8.8: icmp_req=3 ttl=46 time=13.8 ms 64 bytes from 8.8.8.8: icmp_req=4 ttl=46 time=13.8 ms 64 bytes from 8.8.8.8: icmp_req=5 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=6 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=7 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=8 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=9 ttl=46 time=13.7 ms 64 bytes from 8.8.8.8: icmp_req=10 ttl=46 time=13.7 ms ^C — 8.8.8.8 ping statistics — 10 packets transmitted, 10 received, 0% packet loss, time 9014ms rtt min/avg/max/mdev = 13.705/13.774/13.883/0.147 ms tuananh@codepie:~$ ping 4.2.2.2 PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data. ^C — 4.2.2.2 ping statistics — 167 packets transmitted, 0 received, 100% packet loss, time 167318ms Performing dig returns similar problem: tuananh@codepie:~$ dig google.com @4.2.2.2 ; < > DiG 9.8.1-P1 < > google.com @4.2.2.2 ;; global options: +cmd ;; connection timed out; no servers could be reached As you can see, somehow my droplet won’t be able to connect to 4.2.2.2. A simple switch to 8.8.8.8 as main DNS resolver and thing’s back to normal.

Bài học trong ngày: DC

1. The Capitol có free tour, nhưng nên đến sớm để đỡ phải xếp hàng. Sau khi vào trong Capitol Visitor Center, bạn sẽ phải xếp hàng để được vào xem 1 đoạn phim ngắn chừng 10 phút nói về lịch sử nước Mỹ. Sau đó sẽ được hướng dẫn viên đưa đi tham quan điện Capitol. Các chi tiết đều giống hệt như mô tả của Dan Brown trong truyện The Lost Symbol 2. Washington Monument muốn vào phải đặt trước 6 tháng (giống như muốn lên Crown của Liberty Statue vậy) hoặc xếp hàng 1-2 tiếng trước 8h30 sáng để nhận Free Ticket 3. DC có Circulator Bus, giá $1 và có thể đi hầu hết các địa điểm chính của DC. Giá xe bus bình thường là $1.75 4. Georgetown Cupcake: https://www.georgetowncupcake.com 5. Paper Source: chuyên bán đồ stationary: http://www.papersource.com

Bài học trong ngày

1. Nhân tiện đang đọc cuốn sách “The Sixth Extinction: An Unnatural History” của Elizabeth Kolbert: Charles Darwin chịu ảnh hưởng rất lớn từ Charles Lyell – nhà địa chất học tiên phong. Lyell viết quyển “Principles of Geology” khi Darwin mới có 22 tuổi. Ở bất cứ đâu và bất cứ thời điểm nào, những người đi tiên phong thường là những người bị xã hội chê cười trước hết vì “dám” phá vỡ lối mòn trong suy nghĩ. Chúng ta tin vào những điều được đọc, được học, được quan sát và phản bác những gì đi ngược lại. 2. Đại số tổ hợp khá thú vị, tuy rằng mình đã không dành nhiều thời gian cho nó trong những năm cấp 3 và đại học. 3. http://bellard.org/jslinux/ – Linux viết bằng Javascript 4. Không có kiến thức nào là lãng phí. Đừng bao giờ đặt câu hỏi về điều đó. Hãy học, đọc và làm càng nhiều càng tốt, sẽ có lúc dùng đến. 5. Bạn bè không cần nhiều, chỉ cần tốt. 6. Lucy (2014) là một bộ phim cực nhảm. 7. Chuyển từ Facebook sang Quora. Cũng là mất thời gian, nhưng không lãng phí thời gian.

Free course: The Complete iOS 7 Course – Learn by Building 14 Apps (was $499)

I always want to learn how use build an iOS app, and I have some idea in mind. However, I’m just lazy and procrastinating to do so. Today I found a free course (via Slickdeal) to build an iOS app, and already registered (and you should). It’s free (was $499). Link: http://bitfountain.io/course/the-complete-ios-7-course-learn-by-building-14-apps/?couponCode=COUPON111677

Markdown is available for self-hosted WordPress through Jetpack

Jay! I’ve just noticed that. It’s funny when searching for Markdown on WordPress return this article: Write (More) Effortlessly With Markdown Basically, they mentioned that Markdown is only available for WordPress.com blog, by a simple switch in configuration. I am skeptical, so I always try to use “official” version of plugins. Yes, there are many Markdown plugins out there http://wordpress.org/plugins/tags/markdown When I check my Jetpack version, it’s already there! So if you want to write in Markdown style (like Github and StackOverflow), just enable it (why not?).

MySQL bug prevents you from connecting to custom port on MySQL server

It took me a great deal of time and effort to figure out this. In MySQL-client you can specify hostname and port to connect to a different MySQL instance on a different machine and/or different port rather than default localhost instance on your machine. For example, I have 2 MySQL instances running on two different machine, and one of them is behind firewall. Therefore, I need to use SSH tunnel to forward requests to port 3306 of the machine behind firewall. Things got little complicated when I tried to connect using –port or -P. Since I used the same password for both MySQL server (which I shouldn’t), it took me a while to figure out I still connect to the localhost instance. The reason is that, when you specify -P only, mysql will switch to socket mode instead of TCP mode. Here is what you need to do: mysql -P port –protocol TCP Adding –protocol TCP will force mysql to use TCP connection, thus will connect to the remote instance instead. Hope that helps!