JavaScriptCore is a built-in iOS library that enables you to use JavaScript in apps alongside Objective-C and Swift. It lets developers read JavaScript from a string, execute it from Objective-C or Swift, and share data structures and functions across languages. We JavaScriptCore to share code between Web and iOS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Cocoa | |
| extension NSObject { | |
| func tap(blk:(AnyObject) -> Void) -> Self { | |
| blk(self as NSObject) | |
| return self | |
| } | |
| } | |
| // Alternative, you will need to specify the type :: view:NSView = ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Taken zigmob's (http://forums.macrumors.com/showthread.php?t=1742566) workaround a step further | |
| And added some triggers to clean up these dodgy character combinations (ff, fi, fl). | |
| Still crashes on initial message read but saves having to manually run the sql query eve time a message contains the character combinations */ | |
| -- Working well for me so far -- | |
| CREATE TRIGGER insert_Ff AFTER INSERT ON ZWAMESSAGE | |
| BEGIN | |
| UPDATE ZWAMESSAGE | |
| SET ZTEXT = replace( ZTEXT, 'ff', 'f f') | |
| WHERE ZWAMESSAGE.ZTEXT like '%ff%'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /** | |
| Determine whether Optional collection is nil or an empty collection | |
| :param: collection Optional collection | |
| :returns: true if collection is nil or if it is an empty collection, false otherwise | |
| */ | |
| public func isNilOrEmpty<C: CollectionType>(collection: C?) -> Bool { | |
| switch collection { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # $ gem install CFPropertyList | |
| require 'cfpropertylist' | |
| path = File.expand_path '~/Library/Safari/Bookmarks.plist' | |
| plist = CFPropertyList::List.new file: path | |
| list = plist.value.value["Children"].value.select do |item| | |
| if title = item.value["Title"] | |
| title.value == 'com.apple.ReadingList' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def build_path | |
| "build/iPhoneOS-7.0-Release/" | |
| end | |
| def ipa_name | |
| "APP_FILE_NAME.ipa" | |
| end | |
| def dsym_name | |
| "APP_FILE_NAME.app.dSYM" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Basically what we are going to do is use and profit from NSURLRequests being conformant to NSCoding, | |
| and a little known API from NSURLProtocol which allows us attach info to requests. | |
| */ | |
| //Step 0: For the purpose of this gist, we'll already have a background session setup and assume a bunch of stuff. | |
| NSURLSession *bgSession = [NSURLSession magicMethodWhichGivesMeTheAlreadySetupSession]; //Geeez, Methods are long in Obj-C. | |
| //IMPORTANT: Request must be mutable in order for this to work. Got an immutable one. Make a copy. Can't? Well, Make it so!. | |
| //Step 1: Setup your basic request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add this snippet to the top of your playbook. | |
| # It will install python2 if missing (but checks first so no expensive repeated apt updates) | |
| # [email protected] | |
| - hosts: all | |
| gather_facts: False | |
| tasks: | |
| - name: install python 2 | |
| raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import WebKit | |
| final class WebCacheCleaner { | |
| class func clean() { | |
| HTTPCookieStorage.shared.removeCookies(since: Date.distantPast) | |
| print("[WebCacheCleaner] All cookies deleted") | |
| WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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 | |