Skip to content

Instantly share code, notes, and snippets.

View mingsai's full-sized avatar
🎯
Focusing

Tommie N. Carter, Jr. mingsai

🎯
Focusing
View GitHub Profile
@mingsai
mingsai / Web_CouchDB.php
Created August 9, 2020 12:22
A curl based PHP class to access CouchDB
<?php
class Wbb_CouchDB
{
/**
* The Server API Url .
*
* @var string
*/
@mingsai
mingsai / grid_liist_demo.dart
Created July 21, 2020 16:57
Grid List Demo
// Copyright 2019 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:gallery/l10n/gallery_localizations.dart';
enum GridListDemoType {
imageOnly,
header,
@mingsai
mingsai / debug_variables.info
Created May 28, 2020 12:15
Applescript: Debugging variables
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)
@mingsai
mingsai / trim_last_3_chars.applescript
Created May 28, 2020 12:11
Applescript: Trim the last three characters from text input
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
@mingsai
mingsai / trim_string_sample.applescript
Created May 28, 2020 11:54
Applescript: Trim text front and back example
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
@mingsai
mingsai / replace_handler.applescript
Created May 28, 2020 11:33
Applescript: Replace text handler
-- 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
@mingsai
mingsai / string_escaping.applescript
Last active May 28, 2020 11:27
Applescript - Escaping double quotes around variable text
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
@mingsai
mingsai / variable_to_bash.txt
Last active May 28, 2020 10:57
Applescript - pass variables to the terminal shell
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:
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.
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>[