This file contains hidden or 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
switch ( true ) { | |
// Search Applied filter | |
case /^(search)?applied$/.test( selectStr ): | |
return { search: 'applied' } | |
break | |
// Search Removed filter | |
case /^(search)?removed$/.test( selectStr ): | |
return { search: 'removed' } |
This file contains hidden or 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
DESCRIPTION: | |
Needed a pattern to regex through the console output for all commands, regardless of user/date/time/result. And I have a stupidly advanced PS1 prompt | |
PATTERN: | |
^\(\s*[0-9]+\)\[[a-zA-Z0-9\s:]*\|\s*[0-9]{1,5}\:[0-9]{3}\s*(?:\[[0-9]{1,3}\:[0-9]{1,3}\])?\]\{[0-9]{1,4}\}[a-zA-Z0-9\s:@\/~]+\(?:.+\)[\$|#]\s{1}(?<!\n)(.+)$ | |
LINK: https://regex101.com/r/fH8eA4/1 | |
EXAMPLES: |
This file contains hidden or 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
$ file --brief --no-dereference baz | |
symbolic link to foo | |
$ file --mime-type baz | |
baz: application/x-directory | |
$ file --brief --no-dereference --mime-type baz | |
application/x-symlink | |
$ file --brief --no-dereference --mime-encoding baz |
This file contains hidden or 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
var Utils = { | |
//... | |
/** | |
* Convert a date/timestamp to an epoch timestamp | |
* | |
* @param {Date|string} date Either a date in string format, or a Date object | |
* @param {string} round Since the date inputs are day specific (no hour/minute/second), | |
* this dictates if it will be rounded up or down. Allowed values are "start", "stop", "up" and "down" | |
* @param {string} dateFormat Dates input format (default is "mm/dd/yy") |
This file contains hidden or 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
\{(?P<noun>(?:cols?|range))\:(?:(?<=col:)(?P<col>(?:[a-zA-Z]+|[0-9]+))|(?<=cols:)(?P<cols>(?:[a-zA-Z0-9\-\,]+))|(?<=range:)(?P<col_start>(?:[a-zA-Z]+|[0-9]+))\-(?P<col_stop>(?:[a-zA-Z]+|[0-9]+)))\}(?P<modifier>(?:[\?\!]))? | |
\{ (?# Opening delimiter match) | |
(?P<noun>(?:cols?|range)) (?# Match the noun (col, cols, or range)) | |
\: | |
(?: | |
(?<=col:) (?# Look-behind conditional for the 'col' noun) | |
(?P<col>(?:[a-zA-Z]+|[0-9]+)) (?# Creates named group 'col' with either alpha or numeric value(s) (but not both)) | |
| |
This file contains hidden or 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
import sys | |
import re | |
strings = [ | |
'{cols:a,b,c}', | |
'{range:b-z}', | |
'{col:A}', | |
'{cols:a,b,c:,}', | |
'{range:b-z:,}', | |
'{col:1}', |
This file contains hidden or 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
If query provided was: | |
"UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = '{col:A}!' AND STOREID = '{col:B}!' AND ITEMID IN ({range:F-*:,}) AND MANAGERID IN ({cols:C,E:,});" | |
Then it will iterate over each row in said spreadsheet, spitting out queries formatted like so: | |
UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = '<Value of column A in current row>' AND STOREID = '<Value of column B in current row>' AND ITEMID IN (<Concatenated string of values from col F to the last col, joined by a comma>) AND MANAGERID IN (<Concatenated string of values in cols C and E>); |
This file contains hidden or 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
\{ | |
(?:(?# Macro settings start) | |
\;? | |
(?# Noun ptrn start)(?P<noun>(?:cols|col|range))\: | |
(?# Column idx start)(?: | |
(?P<colgroup> | |
(?<=cols:)(?# Colgroup 'cols' EG: A,C,E,G)(?P<cols>(?:(?:[a-zA-Z]+|[0-9]+)(?:,(?:[a-zA-Z]+|[0-9]+))+)) | |
| | |
(?<=range:)(?# Colgroup 'range' EG: A-Z)(?P<col_start>(?:[a-zA-Z]+|[0-9]+))\-(?P<col_stop>(?:[a-zA-Z]+|[0-9]+|\*)) | |
)? |
This file contains hidden or 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
import sys | |
help_items = [ | |
{ | |
'short' : '-h', | |
'long' : '--help', | |
'arg_val' : 'topic', | |
'required' : False, | |
'description' : 'Shows the general help menu, or help regarding a specific item or topic.', | |
'default' : 'general', |
This file contains hidden or 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
$ time xls2sql -i /Users/jhyland/Documents/scripts/python/work/excel-to-sql/excel-templates/ON-DTS\ Replen\ OFF\ -\ 20-rows.xls -q "UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = '123' AND STOREID = '{col:A}' AND ITEMID IN ({range:B-*;j:,})" --row-start 5 | |
UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = '123' AND STOREID = '532' AND ITEMID IN (118469,117677,118233,118474,118467,116726,116727,116732,116730,117676,117859,117460,116729,119056,117472,116731,117481,117866,117461,117463,117868,117462,117483,117869,117464,117484,117493,118509,118507,117466,118508,117891,117468,117469,118566,118466,118471,118472,118470,118468,117878,118946,118947,118948,118950,117880,118510,117471,117473,117893,117892,117476,117895,117896,117897,117485,118624,118517,117474,117475,117486,118626,117901,117496,117490,117906,117908,118527,118526,117479,117477,117910,117912,117478,117480,117491,117501,118711,118716,118714,118712,118713); | |
UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = '123' AND S |