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
// This does not set the color of a user-selected cell like using getActiveCell does, | |
// but it necessarily relies on getActiveSheet(), since ranges are defined as referencing cells within sheets. | |
function setBackgroundOfScriptDeclaredCell() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var range = sheet.getRange("A1"); | |
range.setBackground("red"); | |
} | |
// Will run when user opens/refreshes spreadsheet. | |
function onOpen() { |
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
// Alternatively: Using withCriteria. Requires more boilerplate than using whenFormulaSatisfied. | |
// This code shows the same case above as a specific instance of the general case of using withCriteria, | |
// which has a bit more boilerplate setup. | |
function setRangeToRedBackground(cellsInA1Notation) { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var range = sheet.getRange(cellsInA1Notation); | |
var customFormulaString = "=A1=1"; | |
var criteria = SpreadsheetApp.BooleanCriteria.CUSTOM_FORMULA; // booleanConditionCriteriaType is an alternative name for this | |
var argsArray = [customFormulaString]; // booleanConditionCriteriaValues is an alternative name for this | |
// Could have used the convenience method whenFormulaSatisfied instead of withCriteria (withCriteria is probably what it uses internally). |
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
function yourScript() { | |
// ... | |
var cellsInA1Notation = "A1"; // could also have been e.g. "C3:D4" | |
setRangeToRedBackground(cellsInA1Notation); | |
// ... | |
} | |
// This is a custom convenience function I made which is not provided directly by the Google Sheets API. | |
function addConditionalFormatRule(sheet, rule) { | |
var rules = sheet.getConditionalFormatRules(); |
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
# Couldn't update the tiny_tds version installed with yum, since the yum repo didn't have the latest tiny_tds version. | |
# So remove tiny_tds installed by yum, to avoid conflicts with the succeeding binary tarball install. | |
# Note: yum installs freetds.conf into /etc/freetds.conf | |
# Answer y to remove dependent libraries. | |
printf 'y' | sudo yum remove freetds | |
# Download FreeTDS latest stable version (as of Jan 4, 2018) from binary tarball. | |
cd /tmp | |
wget http://www.freetds.org/files/stable/freetds-1.00.80.tar.gz | |
tar -xzf freetds-1.00.80.tar.gz |
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
--- | |
My system specs: | |
--- | |
OSX Mavericks 10.9.5 | |
capybara 2.4.4 | |
capybara-webkit 1.5.2 | |
--- | |
Videojs code from [video.js](https://github.com/videojs/video.js): |
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
Regarding this article: http://makandracards.com/makandra/12317-capybara-selenium-evaluate_script-might-freeze-your-browser-use-execute_script | |
code: | |
puts page.evaluate_script("2+3;").to_i | |
output: | |
Started "Evaluate(2+3;)" | |
Finished "Evaluate(2+3;)" with response "Success(5)" | |
Wrote response true "5" |
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
--- | |
My system specs: | |
--- | |
OSX Mavericks 10.9.5 | |
capybara 2.4.4 | |
capybara-webkit 1.4.1 | |
--- | |
Videojs code from [video.js](https://github.com/videojs/video.js): | |
--- |
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
it "the state 'Completed' should be tracked correctly", :js => true do | |
visit show_video_path(:unit_id => @unit.id, :channel_id => Channel.first.id, :w => 600, :h => 450) | |
puts "--- trying to click video ---" | |
#page.find("div.vjs-big-play-button").click #click play video button | |
find(:xpath,'//div[contains(@class,"vjs-big-play-button")]').click #click play video button -- alternative find method | |
# some more code, not being reached during execution... | |
puts "---" | |
end | |
NewerOlder