- Open Automator
- Create a new Service
- Set “Service receives selected” to
files or folders
inany application
- Add a
Run Shell Script
action - Set the script action to
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
- Set “Pass input” to
as arguments
- Save as
Open in Sublime Text
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 node | |
const | |
path = require("path"), | |
fs = require("fs"); | |
/** | |
* List all files in a directory recursively in a synchronous fashion | |
* | |
* @param {String} dir |
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
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"] |
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
# 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): |
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
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") | |
} |
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 | |
class WindowController: NSWindowController { | |
} | |
class AppDelegate: NSObject { | |
var mainWindow: NSWindow? | |
var mainController: NSWindowController? | |
} |
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
// 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; |
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 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 |