This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.
— Erik
| # taken from user Albert's answer on StackOverflow | |
| # http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title | |
| # tested on Mac OS X 10.7.5 | |
| global frontApp, frontAppName, windowTitle | |
| set windowTitle to "" | |
| tell application "System Events" | |
| set frontApp to first application process whose frontmost is true | |
| set frontAppName to name of frontApp |
| // http://stackoverflow.com/questions/2107657/mac-cocoa-getting-a-list-of-windows-using-accessibility-api | |
| // http://stackoverflow.com/questions/853833/how-can-my-app-detect-a-change-to-another-apps-window | |
| // http://cocoatutorial.grapewave.com/tag/axuielementcopyattributevalue/ | |
| - (NSDictionary *)axInfoForProcessIdentifier:(NSNumber *)processIdentifier | |
| { | |
| NSMutableDictionary *ret = [NSMutableDictionary dictionaryWithCapacity:2]; | |
| pid_t pid = (pid_t) [processIdentifier integerValue]; | |
| AXUIElementRef app = AXUIElementCreateApplication(pid); | |
| AXUIElementRef frontWindow = nil; | |
| NSString *title = nil; |
| import Cocoa | |
| class WindowController: NSWindowController { | |
| } | |
| class AppDelegate: NSObject { | |
| var mainWindow: NSWindow? | |
| var mainController: NSWindowController? | |
| } |
| async function getData(){ | |
| const a = await someFunction().catch((error)=>console.log(error)); | |
| const b = await someOtherFunction().catch((error)=>console.log(error)); | |
| if(a && b ) console.log("some result") | |
| } |
| # Uses PyWin32 http://timgolden.me.uk/pywin32-docs/win32clipboard.html | |
| import win32clipboard | |
| def get_clipboard(): | |
| win32clipboard.OpenClipboard() | |
| data = win32clipboard.GetClipboardData() | |
| win32clipboard.CloseClipboard() | |
| return data | |
| def set_clipboard(text): |
| var str = "The quick brown fox jumped over the box like an ox with a sox in its mouth"; | |
| str.match(/\w(ox)/g); // ["fox", "box", "sox"] | |
| // match (when used with a 'g' flag) returns an Array with all matches found | |
| // if you don't use the 'g' flag then it acts the same as the 'exec' method. | |
| str.match(/\w(ox)/); // ["fox", "ox"] | |
| /\w(ox)/.exec(str); // ["fox", "ox"] |
| #!/usr/bin/env node | |
| const | |
| path = require("path"), | |
| fs = require("fs"); | |
| /** | |
| * List all files in a directory recursively in a synchronous fashion | |
| * | |
| * @param {String} dir |