Skip to content

Instantly share code, notes, and snippets.

View dshemetov's full-sized avatar

Dmitry Shemetov dshemetov

View GitHub Profile
@dshemetov
dshemetov / setup.R
Last active May 28, 2024 23:51
R setup
# If you need to, install R by visiting CRAN (https://cran.r-project.org/) and
# downloading the appropriate version for your operating system.
# Create a project folder `delphi_project` and open it.
# Open an R terminal and install the renv, pak, and rspm packages by running the
# commands below.
# * The pak package is the modern installer for R packages. Learn more at
# https://pak.r-lib.org/.
# * The rspm package is a package manager for R that allows you to install
@dshemetov
dshemetov / pyproject.toml
Created July 25, 2023 07:49
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "package_name"
version = "0.1.0"
description = "Useful utilities"
readme = "README.md"
requires-python = ">=3.10"
@dshemetov
dshemetov / python_speed.ipynb
Last active April 11, 2023 23:40
A Few General Notes on Python Internals and Making It Fast
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dshemetov
dshemetov / mac-setup.sh
Last active June 18, 2024 02:14
Installer for a fresh Mac
# Mac Setup Helper
#
# This my helper script for setting up a new Mac. It's not meant to be run
# as-is, but rather to be used as a reference for setting up a new Mac.
#
# Some resources I used:
# - An in-depth setup guide https://sourabhbajaj.com/mac-setup/
# Install xcode, many basics for Mac dev
xcode-select --install
(* Part 1 *)
a = 273025; b = 767253;
t = Flatten[Table[FromDigits[{i, j, k, l, m, n}],
{i, 1, 9}, {j, i, 9}, {k, j, 9},
{l, k, 9}, {m, l, 9}, {n, m, 9}]];
Length@Select[t, MemberQ[Differences@IntegerDigits[#], 0] && a <= # <= b &]
(* Part 2 *)
f[n_] := Differences@IntegerDigits[n] /. Thread[Range[2, 9] -> 1]
g[n_] := f[n][[1 ;; 2]] == {0, 1} || f[n][[-2 ;; -1]] == {1, 0} ||
import speedtest
st = speedtest.Speedtest()
st.get_servers()
st.get_best_server()
st.download()
st.upload()
res = st.results
with open('stats.json', 'a+') as f:
(**First we make a function to obtain every spiral corner, then we interpolate between each corner to get the sides, sum together, and finally convert the bijection to an integer sequence.*))
up = {0, 1};
right = {1, 0};
down = -up;
left = -right;
directions = {up, right, down, left};
start = {0, 0};
length = 100;