text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
on remove_columns(file_path, table_name, column_names)
|
SQLiteModifier.applescript
|
log "remove_columns()"
|
SQLiteModifier.applescript
|
set current_column_names to SQLiteParser's column_names(file_path, table_name) --get the columnNames
|
SQLiteModifier.applescript
|
set temp_table_name to "_TEMP_TABLE_" --create tempTableName
|
SQLiteModifier.applescript
|
rename_table(file_path, table_name, temp_table_name) --rename the original table with the tempTableName
|
SQLiteModifier.applescript
|
set new_column_names to every item of current_column_names --store the columnNames
|
SQLiteModifier.applescript
|
set new_column_names to ListModifier's remove_many(new_column_names, column_names) --ListModifier's removeItem(newColumnNames, columnName)
|
SQLiteModifier.applescript
|
create_table(file_path, table_name, new_column_names) --create the new table
|
SQLiteModifier.applescript
|
transfer_table(file_path, temp_table_name, table_name, new_column_names, new_column_names) --transferTable
|
SQLiteModifier.applescript
|
end remove_columns
|
SQLiteModifier.applescript
|
on remove_row(file_path, table_name, condition)
|
SQLiteModifier.applescript
|
log "remove_row()"
|
SQLiteModifier.applescript
|
set condition_string to SQLiteUtil's condition_procedure(condition, "AND")
|
SQLiteModifier.applescript
|
log condition_string
|
SQLiteModifier.applescript
|
set procedure to "sqlite3" & space & file_path & space & quote & "DELETE" & space & "FROM" & space & table_name & space & "WHERE" & space & condition_string & ";" & quote
|
SQLiteModifier.applescript
|
log procedure
|
SQLiteModifier.applescript
|
end remove_row
|
SQLiteModifier.applescript
|
on add_column(file_path, table_name, column_name)
|
SQLiteModifier.applescript
|
log "add_column()"
|
SQLiteModifier.applescript
|
set procedure to "sqlite3" & space & file_path & space & quote & "ALTER" & space & "table" & space & table_name & space & "ADD" & space & "column" & space & column_name & space & ";" & quote
|
SQLiteModifier.applescript
|
end add_column
|
SQLiteModifier.applescript
|
on add_columns(file_path, table_name, column_names)
|
SQLiteModifier.applescript
|
log "add_columns()"
|
SQLiteModifier.applescript
|
repeat with i from 1 to (length of column_names)
|
SQLiteModifier.applescript
|
add_column(file_path, table_name, (item i of column_names))
|
SQLiteModifier.applescript
|
end add_columns
|
SQLiteModifier.applescript
|
on year_start(theDate)
|
DEVONthink-date.scpt
|
copy theDate to yearStart
|
DEVONthink-date.scpt
|
set yearStart's month to January
|
DEVONthink-date.scpt
|
set yearStart's day to 1
|
DEVONthink-date.scpt
|
set yearStart's hours to 0
|
DEVONthink-date.scpt
|
set yearStart's minutes to 0
|
DEVONthink-date.scpt
|
set yearStart's seconds to 0
|
DEVONthink-date.scpt
|
return yearStart
|
DEVONthink-date.scpt
|
end year_start
|
DEVONthink-date.scpt
|
on create_quarter(theDate)
|
DEVONthink-date.scpt
|
set theThursday to get_nearest_thursday(theDate)
|
DEVONthink-date.scpt
|
set _month to month of theThursday as number
|
DEVONthink-date.scpt
|
set quarter to round ((_month - 1) / 3 + 1) rounding down
|
DEVONthink-date.scpt
|
return quarter
|
DEVONthink-date.scpt
|
end create_quarter
|
DEVONthink-date.scpt
|
on get_nearest_thursday(theDate)
|
DEVONthink-date.scpt
|
copy theDate to theThursday -- use copy to duplicate the variable, otherwise it's just the reference!
|
DEVONthink-date.scpt
|
set twd to weekday of theThursday as number
|
DEVONthink-date.scpt
|
if twd is 1 then
|
DEVONthink-date.scpt
|
set twd to 8
|
DEVONthink-date.scpt
|
set theThursday to (theThursday + (5 - twd) * 86400)
|
DEVONthink-date.scpt
|
return theThursday
|
DEVONthink-date.scpt
|
end get_nearest_thursday
|
DEVONthink-date.scpt
|
on get_week_number(theDate)
|
DEVONthink-date.scpt
|
set yearStart to year_start(theThursday)
|
DEVONthink-date.scpt
|
set theWeekNumber to round (((theThursday - yearStart) / 86400 + 1) / 7) rounding up
|
DEVONthink-date.scpt
|
return theWeekNumber
|
DEVONthink-date.scpt
|
end get_week_number
|
DEVONthink-date.scpt
|
on quarter_indicator(theDate)
|
DEVONthink-date.scpt
|
set _year to year of theDate
|
DEVONthink-date.scpt
|
set _quarter to create_quarter(theDate)
|
DEVONthink-date.scpt
|
return (_year) & "Q" & (_quarter)
|
DEVONthink-date.scpt
|
end quarter_indicator
|
DEVONthink-date.scpt
|
on format00(theNumber)
|
DEVONthink-date.scpt
|
return (text -2 thru -1 of ("00" & theNumber))
|
DEVONthink-date.scpt
|
end format00
|
DEVONthink-date.scpt
|
on week_indicator(theDate)
|
DEVONthink-date.scpt
|
set _week to get_week_number(theDate)
|
DEVONthink-date.scpt
|
return (_year) & "W" & format00(_week) -- create a string with the leading zeros
|
DEVONthink-date.scpt
|
end week_indicator
|
DEVONthink-date.scpt
|
on day_formatter(theDate, _sep)
|
DEVONthink-date.scpt
|
set _month to month of theDate as number
|
DEVONthink-date.scpt
|
set _day to day of theDate as number
|
DEVONthink-date.scpt
|
set _ms to format00(_month)
|
DEVONthink-date.scpt
|
set _ds to format00(_day)
|
DEVONthink-date.scpt
|
return ((_year) & _sep & (_ms) & _sep & (_ds))
|
DEVONthink-date.scpt
|
end day_formatter
|
DEVONthink-date.scpt
|
on day_indicator(theDate)
|
DEVONthink-date.scpt
|
return day_formatter(theDate, "")
|
DEVONthink-date.scpt
|
end day_indicator
|
DEVONthink-date.scpt
|
on day_string(theDate)
|
DEVONthink-date.scpt
|
return day_formatter(theDate, "-")
|
DEVONthink-date.scpt
|
end day_string
|
DEVONthink-date.scpt
|
on get_date_input()
|
DEVONthink-date.scpt
|
set todaysDate to current date
|
DEVONthink-date.scpt
|
set _todayDay to day of todaysDate as number
|
DEVONthink-date.scpt
|
set _todayMonth to month of todaysDate as number
|
DEVONthink-date.scpt
|
set _todayYear to year of todaysDate as number
|
DEVONthink-date.scpt
|
set _todayString to ((_todayYear as string) & "-" & (_todayMonth as string) & "-" & (_todayDay as string))
|
DEVONthink-date.scpt
|
display dialog "What is the target date?" & return & return & "format YYYY-MM-DD" & return default answer _todayString with title "Target date"
|
DEVONthink-date.scpt
|
set dueDate to (the text returned of the result)
|
DEVONthink-date.scpt
|
set taskDueDate to todaysDate
|
DEVONthink-date.scpt
|
set the year of taskDueDate to word 1 of dueDate
|
DEVONthink-date.scpt
|
set the month of taskDueDate to word 2 of dueDate
|
DEVONthink-date.scpt
|
set the day of taskDueDate to word 3 of dueDate
|
DEVONthink-date.scpt
|
return taskDueDate
|
DEVONthink-date.scpt
|
end get_date_input
|
DEVONthink-date.scpt
|
set targetDate to get_date_input()
|
DEVONthink-date.scpt
|
set qt to quarter_indicator(targetDate)
|
DEVONthink-date.scpt
|
set wk to week_indicator(targetDate)
|
DEVONthink-date.scpt
|
set dt to day_indicator(targetDate)
|
DEVONthink-date.scpt
|
set ds to day_string(targetDate)
|
DEVONthink-date.scpt
|
set quarterLabel to ("/" & qt)
|
DEVONthink-date.scpt
|
set quarterGroup to get record at quarterLabel
|
DEVONthink-date.scpt
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.