Skip to content

Instantly share code, notes, and snippets.

@StSav012
StSav012 / rk4_mpi.c
Created November 29, 2016 12:58
RK4 w/ MPI
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <mpi.h>
#define formaster if(id==0)
#define forothers if(id!=0)
#define dim 2
#define USE_DEFAULT 1 // skip user input
#define DO_HARLEM_SHAKE 1 // show the result
@StSav012
StSav012 / rk4_omp.cpp
Last active November 29, 2016 12:59
RK4 w/ OMP
#include <cstdlib>
#include <iostream>
#include <vector>
#include <ctime>
#include <omp.h>
using namespace std;
#define dim 2
#define USE_DEFAULT 1 // skip user input
@StSav012
StSav012 / get_weather.sh
Last active October 30, 2017 17:38
rp5 site parser
lang="ru"
place="Нижний Новгород"
code=5797
file=$(curl -s -o - "http://pda.rp5.ru/?lang=${lang}&q=${place}")
links=$(echo ${file} | grep -o -e "p class=\"navy\">.*<form id=\"f\"" | grep -o -e "=[^=]*" | tail -n +2 | head -n -1)
code=$(echo ${links} | grep -Eo -e "\"[[:digit:]]+" | grep -Eo -e "[[:digit:]]+" | head -n 1)
name=$(echo ${links} | grep -Eo -e "${lang}\">[^<]+" | grep -Eo -e ">.+" | grep -Eo -e "[^>]+" | head -n 1)
file=$(wget -q -O - "http://rp5.ru/${code}/${lang}")
@StSav012
StSav012 / sliders.html
Last active October 31, 2017 15:21
An example of a dynamically created table of sliders, and their values, and miscellaneous info
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
* {
color: inherit;
background: inherit;
}
@StSav012
StSav012 / calendar.tex
Last active December 7, 2017 17:15
Calendar Generator
\documentclass[a4paper,landscape,14pt]{extarticle}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,english]{babel}
\usepackage{color}
\usepackage{tabularx}
\usepackage[margin=1cm]{geometry}
\usepackage{pgffor,etoolbox}
\usepackage{hyperref}
\hypersetup{pdftex, pdftitle=Calendar, pdfauthor=StSav012}
@StSav012
StSav012 / parser.c
Last active February 27, 2018 06:34
INI file parser
#include <stdlib.h>
#include <stdio.h>
/*****************************************************************************
* @function readValue extracts a string value from an INI file
* @param f is a file opened for reading outside the function
* @param section is the section name to look into
* @param key is the key which value is required
* @param buffer is a buffer to store the key value into
* @note @param buffer should be long enough to store the value
# -*- coding: utf-8 -*-
from typing import List, Dict
import urllib.request
import urllib.error
import os.path
FILES: List[str] = [
# 'test',
# 'aes_light',
@StSav012
StSav012 / longest_common_sequences.py
Last active October 4, 2022 07:47
Find the longest common sequences of two sequences given
from typing import Iterable, Iterator, Sequence, TypeVar
_T = TypeVar('_T')
def arg_max(x: Iterable[_T]) -> int | None:
""" find the index of the largest item in the series """
am: int | None = None
max_x: _T | None = None
for i, x_i in enumerate(x):
# coding=utf-8
from __future__ import annotations
import logging
import ssl
from http import HTTPStatus
from http.client import HTTPResponse
from json import loads
from pathlib import Path
from platform import uname, uname_result