Skip to content

Instantly share code, notes, and snippets.

View dDondero's full-sized avatar

dDondero

  • Curamando AS
  • Oslo
View GitHub Profile
@dDondero
dDondero / find-cell-value-and-delete-row.js
Created December 8, 2015 19:03
Google Apps script function to delete rows based on value in cell.
function deleteRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var rowsDeleted = 0;
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
if (row[0] == 'delete' || row[0] == '') { // This searches all cells in columns A (change to row[1] for columns B and so on) and deletes row if cell is empty or has value 'delete'.
@dDondero
dDondero / text-to-columns.js
Last active December 27, 2019 04:00
Miss text to columns functionality (ex. .csv file to rows) in Google Apps. Here is a script that creates an extra menu with a few useful functions. Published by Evan Plaice on StackExchange. I share it here because it was very useful to me and hopefully more will find it.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [];
menuEntries.push({ name:"Text to columns", functionName:"textToColumns" });
menuEntries.push({ name:"Text to columns (custom separator)", functionName:"textToColumnsCustom" });
menuEntries.push(null);
menuEntries.push({ name:"Columns to Text", functionName:"columnsToText" });
menuEntries.push({ name:"Columns to Text (custom separator)", functionName:"columnsToTextCustom" });
ss.addMenu("Advanced", menuEntries);
}
@dDondero
dDondero / smooth-scroll-to-div.js
Last active January 28, 2016 11:28
SImple enough. Using jQuery to smooth scroll to certain <div>
jQuery(function(){
function scrollToAnchor(aid){
var aTag = jQuery("a[name='"+ aid +"']");
jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
jQuery("#menu-item-243").click(function() { // Item to click
scrollToAnchor('kontakt'); // Item to scroll to
});
})
@dDondero
dDondero / Search and replace in MySQL.
Last active January 28, 2016 11:31
Run in ex. phpMyAdmin to rename URL when moving a WordPress site.
UPDATE wp_options SET option_value = replace( option_value, 'URL_move_from', 'URL_move_to' ) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'URL_move_from','URL_move_to');
UPDATE wp_posts SET post_content = replace(post_content, 'URL_move_from','URL_move_to');
@dDondero
dDondero / GA-script-scroll_vertically_to_todays_date.gs
Last active September 28, 2023 06:07
This Google sheets / Google Apps script searches through all columns in a certain row to find the date matching today, then document automatically scrolls to today's date so you can continue working on the correct spot. Ment to be set up with a trigger On open document. Some other customizing set up here.
function onOpen() { // find where date maches today, then scroll to the end of sheet, then scroll back to matched date
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var values = sheet.getSheetValues(1,1,1,sheet.getMaxColumns());
var objvalues = Transpose(values);
var today = new Date().setHours(0,0,0,0); // change date format to numbers
for(var n=0;n<objvalues.length;++n){ // for each objvalues object run command