Tutorial by Examples: f

Is the relative path to the file from the current execution directory Assume we have this directory structure: /home/stackoverflow/script.rb script.rb contains: puts __FILE__ If you are inside /home/stackoverflow and execute the script like ruby script.rb then __FILE__ will output script.rb ...
This code opens a file for writing. Returns an error if the file couldn't be opened. Also closes the file at the end. #!/usr/bin/perl use strict; use warnings; use open qw( :encoding(UTF-8) :std ); # Make UTF-8 default encoding # Open "output.txt" for writing (">") and ...
The permutation method, when called with a block yields a two dimensional array consisting of all ordered sequences of a collection of numbers. If this method is called without a block, it will return an enumerator. To convert to an array, call the to_a method. ExampleResult[1,2,3].permutation#&lt...
DatabaseTransactions trait allows databases to rollback all the change during the tests. If you want to rollback multiple databases , you need to set $connectionsToTransact properties use Illuminate\Foundation\Testing\DatabaseMigrations; class ExampleTest extends TestCase { use Databas...
let configuration = WKWebViewConfiguration() if let path = NSBundle.mainBundle().pathForResource("customUserScript", ofType: "js"), source = try? NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String { let userScript = WKUserScript(source...
Messages can be sent from JavaScript using the following code window.webkit.messageHandlers.{NAME}.postMessage() Here how to create a script message handler to handle the messages: class NotificationScriptMessageHandler: NSObject, WKScriptMessageHandler { func userContentController(userCon...
function createGoogleDriveFileOfMimeType() { var content,fileName,newFile;//Declare variable names fileName = "Test File " + new Date().toString().slice(0,15);//Create a new file name with date on end content = "This is the file Content"; newFile = DriveApp.cre...
function createGoogleDriveTextFile() { var content,fileName,newFile;//Declare variable names fileName = "Test Doc " + new Date().toString().slice(0,15);//Create a new file name with date on end content = "This is the file Content"; newFile = DriveApp.createFile...
function createGoogleDriveFileWithBlob() { var blob,character,data,fileName,i,L,max,min,newFile,randomNmbr;//Declare variable names fileName = "Test Blob " + new Date().toString().slice(0,15);//Create a new file name with date on end L = 500;//Define how many times to loo...
function processGoogleDriveFolders() { var arrayAllFolderNames,continuationToken,folders,foldersFromToken,thisFolder;//Declare variable names arrayAllFolderNames = [];//Create an empty array and assign it to this variable name folders = DriveApp.getFolders();//Get all folders from ...
function processGoogleDriveFiles() { var arrayAllFileNames,continuationToken,files,filesFromToken,fileIterator,thisFile;//Declare variable names arrayAllFileNames = [];//Create an empty array and assign it to this variable name files = DriveApp.getFiles();//Get all files from Googl...
function DriveAppAddFolder(child) {//Adds file to the root drive in Google Drive var body,returnedFolder;//Declare variable names if (!child) { body = "There is no folder"; MailApp.sendEmail(Session.getEffectiveUser().getEmail(), "", "Error Adding Folder!&q...
function DriveAppAddFile(child) {//Adds file to the root drive in Google Drive var body,returnedFolder;//Declare variable names if (!child) { body = "There is no file"; MailApp.sendEmail(Session.getEffectiveUser().getEmail(), "", "Error Adding File!",...
Get all Google Forms with the word "Untitled" in the file name. function mainSearchFunction(searchStr) { var fileInfo,arrayFileIDs,arrayFileNames,arrayOfIndexNumbers, allFileIDsWithStringInName,i,searchStr,thisID;//Declare variables if (!searchStr) { searchStr = &quo...
In simple words: A Flyweight factory that for a given, already known, key will always give the same object as response. For new keys will create the instance and return it. Using the factory: ISomeFactory<string, object> factory = new FlyweightFactory<string, object>(); var result1...
Visual Studio also features an available Bundler and Minifier Extension that is capable of handling this process for you. The extension allows you to easily select and bundle the files you need without writing a line of code. Building Your Bundles After installing the extension, you select all of ...
To run multiple processes e.g. an Apache web server together with an SSH daemon inside the same container you can use supervisord. Create your supervisord.conf configuration file like: [supervisord] nodaemon=true [program:sshd] command=/usr/sbin/sshd -D [program:apache2] command=/bin/bash...
var List: TList<Integer>; ... List := TList<Integer>.Create; { Create List } try List.Add(100); { Add Items } List.Add(200); WriteLn(List[1]); { 200 } finally List.Free; end;
type TIntegerList = class(TList<Integer>) public function Sum: Integer; end; ... function TIntegerList.Sum: Integer; var Item: Integer; begin Result := 0; for Item in Self do Result := Result + Item; end;
Elm allows the definition of custom infix operators. Infix operators are defined using parenthesis around the name of a function. Consider this example of infix operator for construction Tuples 1 => True -- (1, True): (=>) : a -> b -> ( a, b ) (=>) a b = ( a, b ) Most of t...

Page 178 of 457