Skip to content

Instantly share code, notes, and snippets.

@Georgitanev
Georgitanev / psql_useful_stat_queries.sql
Created July 11, 2021 14:23 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@Georgitanev
Georgitanev / data_science_with_R_for_non_programmers
Last active June 14, 2018 07:36
Data science code with R for non programmers and excel users
#
# Copyright 2018 Georgi Tanev (Bulgaria)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@Georgitanev
Georgitanev / Python 2.7 basics.py
Last active December 20, 2017 14:05
Python 2.7 basics calculations, func, vars and strings
print "Hello Universe"
3+4
3*4
2*4+2*3
2**3
2**0.5
3/4
3./4.
type(3)
type(3.)
@Georgitanev
Georgitanev / basic_python_begginer_tutorial.py
Created November 14, 2017 09:12
basic_python_begginer_tutorial
@author: G
"""
import matplotlib.pyplot as plt
x = [1,2,3]
y = [4,5,6]
plt.plot(x,y)
@Georgitanev
Georgitanev / Get archive urls from archibe.org in loop from list of file.r
Created November 1, 2017 14:22
Get archive urls from archibe.org in loop from list of file, and get 5-7 URLS per domain
############ Prolet script
#No prottection if URL not working, or in empty reccord.
library(jsonlite)
library(dplyr)
setwd("C:/Users/G/Desktop/prolet")
dir()
#importing list of domains for the loop!
domains_txt <- readLines("domains_weekly.txt")
domains_txt
@Georgitanev
Georgitanev / Majestic top pages in loop.r _ import from list
Last active September 28, 2018 11:26
Majestic top pages in loop
library(jsonlite)
library(data.table)
tooldomains <- fromJSON("https://api.majestic.com/api/json?app_api_key=API_key&cmd=GetTopPages&Query=tool.domains&Count=1&datasource=fresh")
names(tooldomains$DataTables$DomainInfo$Data)
test123 <- as.data.table(tooldomains$DataTables$DomainInfo$Data)
#View(test123)
for(i in seq_along(urls)) {
tmp <- GET(urls[i])
print(status_code(tmp))
}
@Georgitanev
Georgitanev / extracting, title, desc, h1, h2, link
Created October 11, 2017 12:57
extracting, title, desc, h1, h2, link
@Georgitanev
Georgitanev / How to read and write fast huge csv files wirh r
Last active September 8, 2017 06:56
How to read from huge csv files wirh r and Rstudio and write nomber of rows in csv file
# console log file
#reading all the files in a directory
#system time is for measuring time
#loading library
# FROM ROW 92 - pure code no console messages
library(data.table)
system.time(files <- list.files(path = "E:/work-TK/extracting_from_file/multiple/all/5", pattern = ".csv"))
@Georgitanev
Georgitanev / gist:83dcca74bf1db099f35e28dff1df5a6d
Last active September 7, 2017 15:16
How to merge big files in r wirh rstudio 100MB
#This is a system time for opening a large file of 100MB+
#It read it with read.csv for a long time
system.time(file1 <- read.csv("E:/work-TK/extracting_from_file/multiple/file1.csv"))
user system elapsed
230.27 0.94 257.69
# The same size of file with fread function (you must install data.table library in R and launch it -> ellapsed time is much less
library(data.table)
system.time(file2 <- fread("E:/work-TK/extracting_from_file/multiple/file2.csv"))