Skip to content

Instantly share code, notes, and snippets.

View Pavel-Durov's full-sized avatar
😻

Pavel Durov Pavel-Durov

😻
View GitHub Profile
#!/bin/bash
# Usage: shrinkray --timeout 10 --parallelism 50 --no-clang-delta shrinkray_interest.sh ./cstack.minimal.lua
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <input.lua>"
exit 1
fi
INPUT="$1"
LUA_EXEC="$SCRIPT_DIR/../src/lua"
@Pavel-Durov
Pavel-Durov / python_mp3
Created December 1, 2023 17:40
Play mp3 sound on raspberry pi
# pip install pygame
```python
import pygame
def play_mp3(file_path):
pygame.mixer.init()
pygame.mixer.music.load(file_path)
pygame.mixer.music.play()
@Pavel-Durov
Pavel-Durov / download_landcover_data.py
Created November 22, 2023 16:17
Download landcover tile to local filesystem
import os
import requests
from take_home_test_starter.config import Config
BASE_URL = "https://s3-eu-west-1.amazonaws.com/vito.landcover.global/v3.0.1/2019/"
LATITUDES = ["S40", "S20", "N00", "N20", "N40", "N60", "N80"]
@Pavel-Durov
Pavel-Durov / main.rs
Created September 28, 2023 11:29
Writing an Interpreter in Rust: Bytecode and Stack-based VM - main.rs
use std::env;
use lrlex::lrlex_mod;
use lrpar::lrpar_mod;
lrlex_mod!("coconut.l"); // brings the lexer for `coconut.l` into scope.
lrpar_mod!("coconut.y"); // brings the Parser for `coconut.y` into scope.
mod ast;
mod instruction;
@Pavel-Durov
Pavel-Durov / ast.rs
Created September 28, 2023 11:29
Writing an Interpreter in Rust: Bytecode and Stack-based VM - ast.rs
#[derive(Debug)]
pub enum Node {
Add { lhs: Box<Node>, rhs: Box<Node> },
Mul { lhs: Box<Node>, rhs: Box<Node> },
Number { value: u64 },
}
@Pavel-Durov
Pavel-Durov / instruction.rs
Created September 28, 2023 11:27
Writing an Interpreter in Rust: Bytecode and Stack-based VM - instruction.rs
#[derive(Debug, PartialEq, Clone)]
pub enum Op {
Add, // Addition operation
Mull, // Multiplication operation
Push { value: u64 }, // Load numeric value onto stack
}
#!/bin/env bash
OUT="./mp3"
mkdir ${OUT}
for f in ls ./*.flac; do
echo "processing '${f}'"
if [ -f "${f}" ]; then
CMD='ffmpeg -i "'""${f}""'" ${OUT}/"'""$(echo ${f} | sed s/.flac/.mp3/)""'"'
eval "${CMD}"
fi
import os
import sys
def prime(n):
primes = []
for num in range(0, n):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
@Pavel-Durov
Pavel-Durov / prosoners.py
Last active February 18, 2019 10:27
n Prisoners riddle - solution
from random import shuffle
def generate_prisoner(pick, assigned, guess):
return {'pick': pick, 'guess': guess, 'assigned': assigned}
def generate_prisoners(prisoners_count):
collection1 = list(range(1, prisoners_count + 1))
collection2 = list(range(1, prisoners_count + 1))
set noeol
## Install pathogen and use a proper directory structure
```
cd
mkdir -p .vim/{autoload,colors,syntax,plugin,spell,config}
mv .vimrc .vim/vimrc
ln -s .vim/vimrc .vimrc
cd ~/.vim
git clone https://github.com/tpope/vim-pathogen.git pathogen