This file contains 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
Displaying variables | |
The display command is how you produce a text version of the contents of any variable. Various commands display text, making it natural to display information about the run while a script is executing. | |
quietmsg(s): displays the string s in the console, | |
msg(s): like quietmsg(s), but brings the console to the front, | |
postit s displays a message in the floating Message window. postit "" closes the floating Message window. | |
postit "job in progress …" | |
set x to 1 | |
quietmsg(x) | |
set x to x + 1 | |
quietmsg(x) |
This file contains 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
on run {input, parameters} | |
set output to ((characters 1 thru -4 of (item 1 of input as string)) as string) | |
--set output to (item 1 of input as string) | |
(* Your script goes here *) | |
(* if output ends with ".js" then | |
set output to ((characters 1 thru -4 of output) as string) | |
--display dialog updated | |
end if | |
*) | |
--display dialog output |
This file contains 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
set whichFile to choose file with multiple selections allowed | |
repeat with aFile in whichFile | |
tell application "Finder" | |
set filename to name of aFile | |
set name of aFile to ((characters 4 thru -1 of filename) as string) --trim first 3 | |
--set name of whichFile to ((characters 1 thru -4 of filename) as string) --trim last 3 | |
end tell | |
end repeat |
This file contains 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
-- Replaces a substring with another substring | |
(* | |
set my_var to StringsLib's replace_text(some_text, "abc", "def") | |
*) | |
on replace_text(this_text, search_string, replacement_string) | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to the search_string | |
set the item_list to every text item of this_text | |
set AppleScript's text item delimiters to the replacement_string | |
set this_text to the item_list as string |
This file contains 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
set myString to "This is a \"quoted\" text." | |
Sample usgage: | |
on run {input, parameters} | |
set filename to item 1 of input | |
set desc to "\"" & item 2 of input & "\"" | |
--display dialog filename & desc |
This file contains 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
Applescript: Run or Call a Shell Script | |
How do run a shell script with an AppleScript? How do I integrate shell scripts into AppleScript? | |
How do I call a shell script called /path/to/chkhost.sh using an applescript? | |
AppleScript is a scripting for Mac OS. It is the Mac OS scripting interface, which is meant to operate in parallel with the graphical user interface. With AppleScript, you can control, and communicate among, applications, databases, networks, Web services, and even the operating system itself. | |
Running Shell Commands From AppleScript Scripts | |
You can easily execute shell commands from your AppleScript using the following syntax: |
This file contains 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
Gem installs can be slooow. One of the biggest culprits is documentation. Every time you install a gem, your computer has to scan the source of that gem and generate documentation. | |
This can be useful if you often need to check gem documentation when you're offline. Just run gem server and point your browser at http://localhost:8808 to access them. The ri command is also handy to search documentation from the terminal. | |
But if you're like me, you probably don't use local docs. You probably have a decent internet connection at most times. So the time spent generating documentation is just time wasted. | |
If you're using bundler to install all of your gems, you don't have to do anything. Bundler skips rdoc/ri by default. If you happen to be using the gem command directly, you'll need to do a bit of configuration. | |
You may already know that you can disable rdoc/ri generation when you run gem install, by passing in certain flags. |
This file contains 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 'package:flutter/material.dart'; | |
Future<void> _ackAlert(BuildContext context) { | |
return showDialog<void>( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: Text('Not in stock'), | |
content: const Text('This item is no longer available'), | |
actions: <Widget>[ |
This file contains 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
// Subscribe to any incoming purchases at app initialization. These can | |
// propagate from either storefront so it's important to listen as soon as | |
// possible to avoid losing events. | |
class _MyAppState extends State<MyApp> { | |
StreamSubscription<List<PurchaseDetails>> _subscription; | |
@override | |
void initState() { | |
final Stream purchaseUpdates = | |
InAppPurchaseConnection.instance.purchaseUpdatedStream; |
This file contains 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
In App Purchase | |
A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store (on iOS) and Google Play (on Android). | |
Features | |
Add this to your Flutter app to: | |
Show in app products that are available for sale from the underlying shop. Includes consumables, permanent upgrades, and subscriptions. | |
Load in app products currently owned by the user according to the underlying shop. | |
Send your user to the underlying store to purchase your products. | |
Getting Started |