Skip to content

Instantly share code, notes, and snippets.

View amchercashin's full-sized avatar
🎩

Alexander Cherkashin amchercashin

🎩
View GitHub Profile
=ПСТР(ЯЧЕЙКА("filename";A1);НАЙТИ("]";ЯЧЕЙКА("filename";A1))+1;255)
@amchercashin
amchercashin / app.js
Last active July 5, 2018 15:52
asyncAPI
const axios = require("axios");
async function getLastRecord(indexID) {
const response = await axios.get("http://iss.moex.com/iss/history/engines/stock/markets/index/securities/" + indexID + ".json?limit=1");
const lastRecord = response.data["history.cursor"]["data"][0][1];
return lastRecord;
}
async function getDataAsync(indexID) {
const lastRecord = await getLastRecord(indexID);
from math import sqrt, ceil
def solve(room_number):
s = room_number
square_float = 1/2*((sqrt(3)*sqrt(3888*s**2-1)+108*s)**(1/3)/3**(2/3) + 1/(3**(1/3)*(sqrt(3)*sqrt(3888*s**2-1)+108*s)**(1/3)) - 1)
level_float = (1/2)*(1+square_float)*square_float
square = ceil(square_float)
level = ceil(level_float)
approx_position = level_float - level + 1
position = round(approx_position / (1/square))
@amchercashin
amchercashin / sdsj-C.R
Last active November 11, 2016 06:48
SDSJ contest, C ex., example
library(readr)
library(stringr)
library(dplyr)
library(ggplot2)
library(lubridate)
library(glmnet)
library(purrr)
library(tidyr)
train_gender <- read_csv("./data/customers_gender_train.csv", col_types = "ci")
@amchercashin
amchercashin / CUDnn.conf
Last active July 31, 2018 11:34
Permanently add CUDA lib to enviroment. Create CUDnn.conf at /etc/ld.so.conf.d/CUDnn.conf then run seconf scrypt
/usr/local/cuda/lib64
@amchercashin
amchercashin / TensorFlow: connect to CUDnn
Last active May 9, 2016 13:16
Run every time so TensorFlow could find CUDA lib and home directory
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda
@amchercashin
amchercashin / Restart to Windows from Ubuntu script
Last active May 9, 2016 13:17
Restarts Ubuntu and preselect specified option in GRUB list starting from 0 (2 is 3rd option)
#!/bin/bash
sudo grub-reboot 2
reboot
@amchercashin
amchercashin / numberWithSpacesFormat.R
Created February 12, 2016 07:30
Formatting function: numbers with spaces
space <- function(x, ...) {format(x, ..., big.mark = " ", scientific = FALSE, trim = TRUE)}
@amchercashin
amchercashin / multivariateGaussian.R
Created February 11, 2016 13:31
Returns Multivariate Gaussian probability distribution for data points (rows) of X.
multGaussian = function(X) {
#Number of rows
m <- nrow(X)
#Column means
mu <- colMeans(X)
#Number of columns
@amchercashin
amchercashin / pca_var.R
Last active February 11, 2016 13:32
Returns reduces data after PCA with desired percent of variance retained.
pca_var <- function(X, percent) {
#Normalize data before start
X = scale(X)
#Covariance matrix
Sigma = (1 / nrow(X)) * t(X) %*% X
#Singular value decomposition of covariance matrix
Sigma_svd <- svd(Sigma)