Skip to content

Instantly share code, notes, and snippets.

@howanghk
howanghk / gist:4222055
Created December 6, 2012 05:45
check internet connection with NSURLConnection and Google in response to http://stackoverflow.com/a/13736429/613541
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *urlString = @"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"HEAD"];
NSHTTPURLResponse *response;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
if ([response statusCode] == 200)
@howanghk
howanghk / cloudflare_ddns_updater.php
Last active February 26, 2017 03:48 — forked from kdallas/index.php
Invited by Matthew Prince (https://twitter.com/eastdakota/status/453542354117754882), I am switching to Cloudflare DDNS. However it's difficult to configure my dd-wrt router to update my Dynamic DNS host name with Cloudflare. So I ended up with my router calling a PHP script hosted on my website.
<?php
// ----- dd-wrt DDNS settings: -----
// DDNS Service: Custom
// DYNDNS Server: <your web server domain> (e.g. www.example.com)
// User Name: <anything>
// Password: <anything>
// Host Name: <your DDNS hostname> (e.g. home.example.com)
// URL: /cloudflare_ddns_updater.php?email=<your cloudflare account email>&apikey=<your cloudflare client api key>&domain=<your domain>&host=<your DDNS hostname>
// (e.g.: /cloudflare_ddns_updater.php?email=me@example.com&apikey=123456789012345678901234567890&domain=example.com&host=home.example.com)