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
--https://www.citusdata.com/blog/2018/05/15/fun-with-sql-recursive-ctes/ | |
--Return: x | |
WITH RECURSIVE tens(x) AS ( | |
SELECT 10 | |
UNION | |
SELECT x + 10 FROM tens WHERE x + 10 <= 100 | |
) | |
SELECT x FROM tens; | |
--Without having to drop down to a procedural language like plpgsql or plv8. |
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
#XLarge DBInstanceClassMemory = 15892177440 = 14.8GB | |
#/32 = 496630545 = 473MB | |
#/64 = 248315272 = 236MB | |
#/128 = 124157636 = 118MB | |
#/256 = 62078818 = 59MB | |
#/512 = 31039409 = 29MB | |
#/12582880 = 1263 #default same divisor as max_connections = 4041.6MB = 4237924762 | |
#/25165760 = 623 # half of max_connections = 1993.6MB | |
#/50331520 = 315 # quarter of max_connections = 1008MB = 1056964608 | |
#*(3/4) #default innodb pool size = 11922309120 |
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
rds-modify-db-parameter-group {param-group-name} \ | |
--parameters="name=character_set_server, value=utf8, method=pending-reboot" \ | |
--parameters="name=collation_server, value=utf8_general_ci, method=pending-reboot" \ | |
--parameters="name=tmp_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \ | |
--parameters="name=max_heap_table_size, value={DBInstanceClassMemory/16}, method=pending-reboot" \ | |
--parameters="name=query_cache_type, value=1, method=pending-reboot" \ | |
--parameters="name=query_cache_size, value=131072, method=pending-reboot" \ | |
--parameters="name=table_open_cache, value=2500, method=pending-reboot" \ | |
--parameters="name=join_buffer_size, value={DBInstanceClassMemory/64}, method=pending-reboot" \ | |
--parameters="name=thread_cache_size, value={DBInstanceClassMemory/12582880}, method=pending-reboot" \ |
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
SELECT | |
x, | |
WIDTH_BUCKET(x, 1, 10, 9) AS "x In Which Bucket ?" | |
FROM | |
generate_series(1, 10) x; | |
SELECT | |
ROW_NUMBER() OVER(), | |
* | |
FROM |
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
drop table if exists sales; | |
create table sales ( | |
prod_id int, | |
month_end varchar(10), | |
amount int | |
); | |
-- need to paddle zero if no sales, but we fill manually here | |
insert into sales values | |
(1, '2017-01-31', 100), (1, '2017-02-28', 300), |
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
#!/usr/bin/perl | |
## ----------------------------------------------------------------------- | |
## | |
## Copyright 2002-2008 H. Peter Anvin - All Rights Reserved | |
## Copyright 2009 Intel Corporation; author: H. Peter Anvin | |
## | |
## This program is free software; you can redistribute it and/or modify | |
## it under the terms of the GNU General Public License as published by | |
## the Free Software Foundation, Inc., 53 Temple Place Ste 330, | |
## Boston MA 02111-1307, USA; either version 2 of the License, or |
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
#!/bin/bash | |
# usage: | |
# ls *.avi | ./video_to_audio.sh | |
# for f in `ls *.avi`; | |
# do | |
# echo item: $f | |
# done |
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
#!/bin/bash | |
# Bash Progress Bar: https://gist.github.com/F1LT3R/fa7f102b08a514f2c535 | |
progressBarWidth=20 | |
# Function to draw progress bar | |
progressBar () { | |
# Calculate number of fill/empty slots in the bar |
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
% !TeX spellcheck = <yes> | |
\documentclass[14pt,a4paper]{article} | |
\usepackage[latin1]{inputenc} | |
\usepackage{amsmath} | |
\usepackage{amsfonts} | |
\usepackage{amssymb} | |
\usepackage{graphicx} | |
\author{MZ} | |
\title{Share Terms} | |
\begin{document} |
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
# a slightly more realistic version of the 'Healthy' vs. 'Fever' model is outlined and then generated | |
import random | |
states = ('Healthy', 'Fever') | |
observations = ('normal', 'cold', 'dizzy') | |
start_probability = {'Healthy': 0.6, 'Fever': 0.4} | |
transition_probability = { | |
'Healthy' : {'Healthy': 0.8, 'Fever': 0.2}, | |
'Fever' : {'Healthy': 0.4, 'Fever': 0.6} |