if(A_TimeIdlePhysical > 60000) { ; 60,000 milliseconds
WinClose, ahk_class Chrome_WidgetWin_1
MsgBox, Google Chrome was closed due to user inactivity.
}
This check could be done periodically, e.g. using SetTimer.
myDebt := 9000
index := RegExMatch("You owe me $42", "\$(\d+)", dollars)
if(index > 0) { ; indices are usually 1-based in AHK
myDebt += dollars1
MsgBox, Current debt: %myDebt%
}
Result:
Current debt: 9042
myString := " hello, Trim()! "
trimmed := Trim(myString)
FileAppend, % trimmed "`n", TrimmedStrings.txt
Note that Trim() will not manipulate the original string, but return a new one which should be stored or output somewhere.
Comments in Tcl are best thought of as another command.
A comment consists of a # followed by any number of characters up to the next newline. A comment can appear wherever a command can be placed.
# this is a valid comment
proc hello { } {
# the next comment needs the ; before it to indicat...
Due to the way the Tcl language parser works, braces in the code must be properly matched. This includes the braces in comments.
proc hw {} {
# this { code will fail
puts {hello world}
}
A missing close-brace: possible unbalanced brace in comment error will be thrown.
proc hw {} {
...
You can use the following code for going back and forward.
if (!function_exists('codepoint_encode')) {
function codepoint_encode($str) {
return substr(json_encode($str), 1, -1);
}
}
if (!function_exists('codepoint_decode')) {
function codepoint_decode($str) {
re...
You can use the following code for going back and forward.
if (!function_exists('mb_internal_encoding')) {
function mb_internal_encoding($encoding = NULL) {
return ($from_encoding === NULL) ? iconv_get_encoding() : iconv_set_encoding($encoding);
}
}
if (!function_exists('mb_c...
When localizing different types of resources are required, each of which has its own home in the android project structure.
Following are the different directories that we can place under the \res directory. The resource types placed in each of these directories are explained in the table below:
D...
Each resource directory under the res folder (listed in the example above) can have different variations of the contained resources in similarly named directory suffixed with different qualifier-values for each configuration-type.
Example of variations of `` directory with different qualifier value...
C and C++ are well known as high-performance languages - largely due to the heavy amount of code customization, allowing a user to specify performance by choice of structure.
When optimizing it is important to benchmark relevant code and completely understand how the code will be used.
Common opti...
The most straightforward approach to optimizing is by executing less code. This approach usually gives a fixed speed-up without changing the time complexity of the code.
Even though this approach gives you a clear speedup, this will only give noticable improvements when the code is called a lot.
R...
Optimizing by using the right data structures at the right time can change the time-complexity of the code.
// This variant of stableUnique contains a complexity of N log(N)
// N > number of elements in v
// log(N) > insert complexity of std::set
std::vector<std::string> stableUnique...
Save the session variable as a variable.
$session = Yii::$app->session;
$sess = $session['keys'];
Then create or update the array value you want
$sess['first'] = 'abc';
And finally save to the session variable
$session['keys'] = $sess
Returns true or false, which indicates whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search.
/R.../.match?("Ruby") #=> true
/R.../.match?("Ruby"...
When storing JSON documents in SQL Server, We need to be able to efficiently filter and sort query results on properties of the JSON documents.
CREATE TABLE JsonTable
(
id int identity primary key,
jsonInfo nvarchar(max),
CONSTRAINT [Content should be formatted as JSON]
CHECK...
Creating a dictionary:
set mydict [dict create a 1 b 2 c 3 d 4]
dict get $mydict b ; # returns 2
set key c
set myval [dict get $mydict $key]
puts $myval
# remove a value
dict unset mydict b
# set a new value
dict set mydict e 5
Dictionary keys can be nested.
dict set mycars mustang colo...
The static keyword is used on a class, method, or field to make them work independently of any instance of the class.
Static fields are common to all instances of a class. They do not need an instance to access them.
Static methods can be run without an instance of the class they are in. However...
Abstraction is a process of hiding the implementation details and showing only functionality to the user. An abstract class can never be instantiated. If a class is declared as abstract then the sole purpose is for the class to be extended.
abstract class Car
{
abstract void tagLine();
}
...
A variable which is declared as transient will not be serialized during object serialization.
public transient int limit = 55; // will not persist
public int b; // will persist