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/env bash | |
RAW_PATH_TMP=`mktemp` | |
CLEAN_PATH_TMP=`mktemp` | |
echo $PATH | sed 's/:/\n/g' | sort > $RAW_PATH_TMP | |
cat $RAW_PATH_TMP | uniq > $CLEAN_PATH_TMP | |
declare -i LINES=$(( `diff $RAW_PATH_TMP $CLEAN_PATH_TMP | wc -l` / 2 )) |
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
WITH cteRevenueDays(Orders, StoreDate, Revenue) AS ( | |
SELECT COUNT(SalesOrderID) AS Orders | |
,CAST(OrderDate AS DATE) as [StoreDate] | |
,SUM(SubTotal) AS Revenue | |
FROM [AdventureWorks2019].[Sales].[SalesOrderHeader] | |
WHERE DATEPART(YEAR, CAST(OrderDate as DATE)) = 2011 | |
AND DATEPART(MONTH, CAST(OrderDate as DATE)) = 7 | |
GROUP BY CAST(OrderDate as DATE) | |
) SELECT | |
StoreDate |
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
data <- -10:10 | |
lims <- range(data) | |
x <- sample(data, 50, replace = TRUE) | |
par(mfrow=c(1, 5)) | |
plot(x, ylim=lims, main="initial data") | |
# only positive | |
plot(pmax(x, 0), ylim=lims, main="clip bottom") |
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
# casting as integer | |
int_cyl <- as.integer(mtcars$cyl) | |
int_cyl | |
# creating a factor | |
factor_cyl <- as.factor(mtcars$cyl) | |
factor_cyl | |
# flag columns / dummy variables | |
library(caret) |
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
library(tidyverse) | |
ROLLS <- 4 | |
SIMS <- 10000 | |
#calculate | |
ncombos <- choose(ROLLS,2) | |
two_sixes <- 1/6 * 1/6 * 5/6 * 5/6 | |
print(sprintf("choose(4, 2) * 25/(6^4) = %f", ncombos * two_sixes)) |
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
from mcstatus import MinecraftServer | |
import argparse | |
import json | |
parser = argparse.ArgumentParser() | |
parser.add_argument("server", help="server name or ip", nargs='?', type=str, default="localhost") | |
parser.add_argument("port", help="server port", nargs='?', type=int, default=25565) | |
args = parser.parse_args() | |
print("Querying server host: {} port: {}".format(args.server, args.port)) |
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
args <- commandArgs() | |
trailing_args <- commandArgs(trailingOnly = TRUE) | |
print(args) | |
writeLines("\n====Just Trailing====\n\n") | |
print(trailing_args) |
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
provider "aws" { | |
region = "us-east-1" | |
profile = "${var.aws_profile}" | |
shared_credentials_file = "~/.aws/credentials" | |
} | |
resource "aws_instance" "mlbox" { | |
ami = "ami-00ffbd996ef2211e3" | |
instance_type = "p2.xlarge" | |
key_name = "${var.keyname}" |
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
tensorboard --logdir /tmp/myproject --host 0.0.0.0 |
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
from shared.get_start_time get_start_time, get_curr_time | |
# the tensorboard log directory will be a unique subdirectory based on the start time fo the run | |
TBLOGDIR="/tmp/myproject/{}".format(get_start_time()) | |
# ...your model code here... | |
history = model.fit(train_images, | |
train_images, | |
epochs=EPOCHS, |
NewerOlder