Skip to content

Instantly share code, notes, and snippets.

View akastrin's full-sized avatar
🎯
Focusing

Andrej Kastrin akastrin

🎯
Focusing
View GitHub Profile
@akastrin
akastrin / helix.m
Created September 21, 2012 20:59
Helix construction in Matlab.
clear all; clc
a=1;
b=0.1;
w=1;
t=linspace(0,5*pi,500);
x=a*cos(w*t);
y=a*sin(w*t);
@akastrin
akastrin / residual_plots.R
Created October 2, 2012 19:47
Residual plots for detecting possible anomalies in the case of linear regression.
# Setup
library(ggplot2)
library(grid)
library(gridExtra)
# Rectangle
n <- 500
x = runif(n, -1, 1)
y = runif(n, -0.25, 0.25)
df <- data.frame(x = x, y = y)
@akastrin
akastrin / bayes_error.tikz
Created November 21, 2012 16:34
Bayes error with TikZ
\documentclass{article}
\usepackage{tkz-fct}
\usetikzlibrary{intersections}
\begin{document}
\tikzset{
name plot/.style={every path/.style={name path global=#1}}
}
dohodki <- c(15,18,22,23,24,
22,25,15,15,14,
18,22,15,19,21,
23,15,14,17,18,
23,15,26,18,14,
12,15,11,10,8,
26,12,23,15,18,
19,17,15,20,10,
15,14,18,19,20,
14,18,10,12,23,
# Input 1: a vector of n probabilities each 0 < p < 1 such that sum of all p = k
# Input 2: k - integer
# Output: all possible products of Pi where k of Pi are selected as such, the other n-k as (1-Pi)
# Run as: awk -f sampling.R
BEGIN {
n = 5;
k = 2;
p[1] = 0.15;
p[2] = 0.22;
@akastrin
akastrin / oneliners.sh
Last active August 15, 2019 03:24
My oneliners
# Remove all packages younger than a specified date
xargs -a <(expac --timefmt='%Y-%m-%d %T' '%l\t%n' | sort -n | awk -F"\t" -v "Date=$(date -d'2019-08-14 12:52:00' '+%Y-%m-%d %H:%M:%S')" '$1 > Date {print $0}' | cut -f2) sudo pacman -R
~/.../tsne-cuda/build >>> cmake .. -DBUILD_PYTHON=TRUE -DWITH_MKL=FALSE -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 ±[master]
-- The C compiler identification is GNU 6.5.0
-- The CXX compiler identification is GNU 6.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-6 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Scanning dependencies of target glog
Scanning dependencies of target gtest
Scanning dependencies of target faiss
[ 0%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/symbolize.cc.o
[ 0%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/logging.cc.o
[ 1%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/raw_logging.cc.o
[ 1%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/demangle.cc.o
[ 2%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/utilities.cc.o
[ 2%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/vlog_is_on.cc.o
[ 2%] Building CXX object third_party/glog/CMakeFiles/glog.dir/src/signalhandler.cc.o
@akastrin
akastrin / renew-gpgkey.md
Created April 1, 2023 12:03 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

Text Encoding

How are text files encoded, and what are the pros and cons of different encodings? This document introduces the ASCII and Unicode encodings to answer these questions. Some short pieces of Go code are provided which you can run yourself to see how strings are being encoded. Go is used because it has built-in support for Unicode, but you should be able to follow without any knowledge of Go.

ASCII