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
USE YOURDB; | |
CREATE TABLE DBO.RETAIL_454_CALENDAR (RETAIL_DATE DATE, RETAIL_WEEK INT, RETAIL_YEAR INT); | |
TRUNCATE TABLE DBO.RETAIL_454_CALENDAR; | |
/* Do not pick an arbitrary start date. This script relies on the correct start date for Retail year 2012 */ | |
DECLARE @BEGIN_DATE date = '29-Jan-2012' | |
DECLARE @END_DATE DATE = '01-May-2090' | |
DECLARE @WEEK_START_DATE DATE = @BEGIN_DATE; | |
DECLARE @DATES_TABLE TABLE (DT DATE); |
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
Save the contents of: https://raw.githubusercontent.com/artifex404/slack-dark-theme/master/custom.css into | |
C:\Users\%username%\AppData\Roaming\Franz\recipes\slack | |
Open this file: "C:\Users\%username%\AppData\Roaming\Franz\recipes\slack\webview.js" | |
Find the line that has the code: "Franz.injectCSS(_path2.default.join(__dirname, 'service.css'));" | |
Under that line add: Franz.injectCSS(_path2.default.join(__dirname, 'custom.css')); | |
Save and Ctrl+R your Franz slack windows |
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
import io | |
import gzip | |
import csv | |
import boto3 | |
import os | |
destination_bucket = 'your-directory' | |
destination_directory = 'your/directory/' | |
destination_filename = 'text.csv.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
JSON stuff: https://gist.github.com/sbealer/c2d4585570d9334861115c50208fb637 | |
Quick if exists drops! | |
drop table if exists dw.this_table_doesnt_exist; | |
Create or Alter! | |
create or alter view test_view AS | |
select 'testing new create or alter syntax' as val; | |
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
declare @json varchar(2000) = '{ | |
"colors": [ | |
{ | |
"color": "black", | |
"category": "hue", | |
"type": "primary", | |
"code": { | |
"rgba": [255,255,255,1], | |
"hex": "#000" | |
} |
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
INSERT INTO [YOURLINKEDSERVER].[YOURDB].[DBO].YOURTABLE | |
SELECT | |
* | |
,cast('2017-05-20' as date) | |
FROM OPENROWSET('MSDASQL' | |
, 'Driver={Microsoft Access Text Driver (*.txt, *.csv)}; | |
DBQ=C:\first_directory\second_directory\' | |
, 'select * from "your_file.csv"') |
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
/*Just use FIRST_VALUE. LAST_VALUE takes more coding (in SQL Server) to get the same thing done, such as the inclusion of a ROWS BETWEEN clause: | |
(Please note that this article applies to SQL Server. Redshift requires you to have a window function regardless of which method you use) | |
The below query tries to get the 'most recent' value without having to join back on itself. | |
Two methods, last_value and first_value are used in the attempt: | |
*/ | |
WITH DATES_EXAMPLE | |
AS |
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
CREATE VIEW dw.dim_time_vw AS | |
with nums AS ( | |
SELECT TOP 86400 | |
row_number() over ( | |
PARTITION BY NULL ORDER BY id) AS num | |
FROM l_browser) | |
SELECT | |
to_char( | |
DATEADD(second, num-1, cast('2000-01-01' AS date)), 'HH24MISS') AS time_key, |
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
create | |
--drop | |
view dw.dim_date_vw as | |
WITH nums AS ( | |
SELECT TOP 15000 row_number() over ( | |
PARTITION BY NULL order by id) n | |
FROM l_browser -- or some other large table; | |
) | |
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
import os | |
import multiprocessing | |
import random | |
import time | |
from services import logger | |
LOG = logger.get_logger(os.path.basename(__file__)) | |
proc_name = 'Parallel Processing Example using multiprocessing module' |
NewerOlder