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 Data.List | |
| import qualified Data.Map.Strict as Map | |
| import Data.Ord (comparing) | |
| wordFrequency :: (Ord a) => [a] -> Map.Map a Int | |
| wordFrequency xs = foldr (\word acc -> Map.insertWith (+) word 1 acc) Map.empty xs | |
| nBiggest :: Int -> Map.Map a Int -> [(a, Int)] | |
| nBiggest n m = take n $ sortBy (comparing $ negate . snd) $ Map.toList m |
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
| <?php | |
| use Yosymfony\Toml\Toml; | |
| ini_set('display_errors', false); | |
| ini_set('display_startup_errors', true); | |
| ini_set('newrelic.appname', 'gilad-dev'); | |
| error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING); |
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
| library(ggplot2) | |
| library(MASS) | |
| setwd('~/Downloads/jtls_and_more/') | |
| jtl <- read_csv("~/Downloads/jtls_and_more/sample.jtl.csv") | |
| df <- subset(jtl, jtl$lb == 'HomePage_01') | |
| ggplot(jtl, aes(t)) + | |
| facet_wrap( ~ lb, ncol = 3) + | |
| geom_histogram(bins = 75) + |
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
| library("ggplot2") | |
| sample.jtl <- read.csv("~/repos/work/csv-percentiles/sample.csv") | |
| sample.jtl$ts <- as.POSIXct(sample.jtl$ts / 1000, origin="1970-01-01") | |
| interval_size <- '5 sec' | |
| wanted_percentiles <- c(0.5, 0.9, 0.95, 0.99) | |
| get_quantiles <- function(items) { | |
| yy <- quantile(items, wanted_percentiles) |
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
| setwd("~/Documents/MA Statistics/Statistical Models A/targil 4") | |
| H <- matrix(c(0, 2, 4, 6, 8, 2, 0, 2, 4, 6, 4, 2, 0, 2, 4, 6, 4, 2, 0, 2, 8, 6, 4, 2, 0), byrow = TRUE, nrow = 5) | |
| X <- as.matrix(read.table("./targ3dat.txt", quote = "\"", comment.char = "")) | |
| n <- nrow(X) | |
| d <- ncol(X) | |
| S <- sum(apply(X, 1, crossprod)) | |
| calculate_V <- function(theta) { | |
| psi <- theta[1:d] |
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
| u <- c(0.1, 0.3, 0.5) | |
| chi_df <- 3 | |
| target_power <- 0.9 | |
| chi_base <- qchisq(0.95, chi_df) | |
| get_power <- function(n) { | |
| return (pchisq(q = chi_base, df = chi_df, ncp = n * u %*% u, lower.tail = FALSE)) | |
| } | |
| get_power(20) |
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
| cols <- c( | |
| c(3, 9, 2, 3, 2), | |
| c(8, 8, 1, 9, 0), | |
| c(1, 9, 5, 9, 8), | |
| c(8, 10, 7, 5, 3), | |
| c(5, 8, 8, 0, 8), | |
| c(5, 10, 4, 7, 2)) | |
| # prepare column vectors matrix | |
| mat <- matrix(cols, byrow = FALSE, nrow = 5) |
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
| [program:gilad-worker] | |
| command=php /home/gilad/vol/www/a.blazemeter.com/vendor/kamisama/php-resque-ex/bin/resque | |
| directory=/home/gilad/vol/www/a.blazemeter.com | |
| autorestart=true | |
| autostart=true | |
| startretries=10000 | |
| stderr_logfile=/var/log/blazemeter/%(program_name)s-error.log | |
| stdout_logfile=/var/log/blazemeter/%(program_name)s.log |
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
| :args `ag -l word` | |
| :argdo %s/word/newWord/gc | w |
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
| #!/usr/bin/env python2 | |
| # don't forget to `pip install toml` | |
| import json | |
| import sys | |
| import toml | |
| if len(sys.argv) < 3: raise Exception('Usage is `json_to_toml.py input.json output.toml`') | |
| json_file = sys.argv[1] |