Location: Home Notes: Productive with 2 pomodoros
11:04 PM - 11:07 PM Plan 11:10 PM - 11:21 PM Mimic 11:21 PM - 12:03 AM Sales 02:19 PM - 03:32 PM Mimic 04:36 PM - 04:47 PM Mimic
| # coding: utf-8 | |
| class IAPScene < SKScene | |
| include ScreenSizes | |
| attr_accessor :root | |
| def button_size | |
| device_screen_width.fdiv(buttons_per_row + 2) | |
| end |
| def session_with_basic_auth | |
| return @session_with_basic_auth if @session_with_basic_auth | |
| configuration = NSURLSessionConfiguration.defaultSessionConfiguration.tap do |conf| | |
| any_username_will_do = 'xxx' | |
| userPasswordString = "#{any_username_will_do}: #{api_key}" | |
| userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding) | |
| base64EncodedCredential = userPasswordData.base64EncodedStringWithOptions(0) | |
| authString = "Basic #{base64EncodedCredential}" | |
| #TODO test error handling when authorization is invalid, or when URL is wrong | |
| conf.HTTPAdditionalHeaders = {'Accept'=>'application/json', |
| def session | |
| return @session if @session | |
| configuration = NSURLSessionConfiguration.defaultSessionConfiguration.tap do |conf| | |
| conf.HTTPAdditionalHeaders = {'Accept'=>'application/json', | |
| 'Accept-Language'=>'en', | |
| 'User-Agent'=> user_agent} | |
| end | |
| @session = NSURLSession.sessionWithConfiguration(configuration) | |
| @session | |
| end |
| //Prints: | |
| // | |
| //Get filenames | |
| //Progress 100000/2000000 | |
| //Progress 200000/2000000 | |
| //Progress 300000/2000000 | |
| //... | |
| //Progress 2000000/2000000 | |
| //Completed | |
| //Time taken to get filenames: 100 secs |
| <? | |
| //Using IP Sidekick for geolocation in PHP | |
| //[email protected] | |
| //https://ipsidekick.com | |
| //This uses the free plan which limits you to 1440 lookups/day. | |
| //For a higher rate limit, look at our paid plans at https://ipsidekick.com | |
| function resolveIP($ip) { | |
| $string = file_get_contents("https://ipsidekick.com/{$ip}"); | |
| $json = json_decode($string); |
| //Using appledevicenames.com in Swift | |
| //[email protected] | |
| //http://appledevicenames.com | |
| //Stick this somewhere | |
| private func deviceModel() -> String? { | |
| var keys = [CTL_HW, HW_MACHINE] | |
| var requiredSize = 0 | |
| let fetchSizeResult = sysctl(&keys, UInt32(keys.count), nil, &requiredSize, nil, 0) | |
| guard fetchSizeResult == 0 else { return nil } |
| //Using IP Sidekick for geolocation in Google Sheets | |
| //[email protected] | |
| //https://ipsidekick.com | |
| //Instructions: | |
| //1. In Google Sheets, under `Tools`, click `Script editor...`. | |
| //2. Paste the contents of this file. | |
| //3. Hit the `Save` button. You may be asked to give the project a name. | |
| //4. In your spreadsheet, click on the desired cell and enter something like | |
| //... `=resolveIP(A1)` where A1 is the cell you want to lookup. |
| //Using IP Sidekick for geolocation in Numbers.app | |
| //[email protected] | |
| //https://ipsidekick.com | |
| //Instructions: | |
| //1. Save this file as using-ipsidekick-with-numbers-app.scpt in Script Editor.app | |
| //2. In Numbers app, open your spreadsheet and select the cells with IP address | |
| //..you want to lookup and run this script in Script Editor.app | |
| /** | |
| * loadJSONP( url, hollaback [, context] ) -> Null | |
| * - url (String): URL to data resource. | |
| * - hollaback (Function): Function to call when data is successfully loaded, | |
| * it receives one argument: the data. | |
| * - context (Object): Context to invoke the hollaback function in. | |
| * | |
| * Load external data through a JSONP interface. | |
| * | |
| * ### Examples |