Skip to content

Instantly share code, notes, and snippets.

View dima74's full-sized avatar

Dmitry Murzin dima74

  • Saint Petersburg
View GitHub Profile
Sub InsertPivotTable()
'Macro By ExcelChamps
'Add header to first column, because PivotTable doesn't work with empty columns
[A1].Value = "Id"
'Declare Variables
Dim PSheet As Worksheet
Dim DSheet As Worksheet
Dim PCache As PivotCache
@dima74
dima74 / yota-ttl-65.sh
Created December 28, 2017 19:25
set ttl to 65
echo 65 >/proc/sys/net/ipv4/ip_default_ttl
@dima74
dima74 / recovery-archlinux-after-device-not-found-error.md
Last active July 10, 2023 08:17
arch linux `modules.devname not found` after update during boot

TL;DR: rebuild kernel with mkinitcpio -p linux, possible with preceding update via pacman -Syu

If you don't have arch linux bootable usb:

  1. Assume you have ubuntu bootable usb
  2. Download arch linux iso image
  3. Make bootable usb using dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx && sync
  4. Reboot into arch linux bootable usb

In arch linux bootable usb:

@dima74
dima74 / train_test_split.py
Created December 9, 2017 20:51
train_test_split для двух массивов, на случай если семинарист не разрешает использовать sklearn.cross_validation.train_test_split
def train_test_split(xs, ys, test_size=0.25, random_state=0):
n = len(xs)
n_test = math.ceil(n * test_size)
n_train = n - n_test
random_state = np.random.RandomState(random_state)
# random partition
permutation = random_state.permutation(n)
indexes_test = permutation[:n_test]
indexes_train = permutation[n_test:n_test + n_train]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Размещение:
|ч|е|т|ы|
|д|о|е|р|
|и|н|д|в|
|и|р|т|а|
Пояснение:
|4|4|4|4|
@dima74
dima74 / replace-all.cpp
Last active May 30, 2017 20:15
Функция, заменяющая все подстроки в строке. Понравилась? Поставь звёздочку!
void replaceAll(string &source, string search, string replace) {
size_t position = 0;
while ((position = source.find(search, position)) != string::npos) {
source.replace(position, search.length(), replace);
position += replace.length();
}
}
@dima74
dima74 / yoficate-google-chrome.sh
Last active May 23, 2017 22:56
Скрипт для ёфикации некоторых слов в Chrome
#!/bin/sh -e
sudo sed -i 's/Надежный/Надёжный/g; s/надежный/надёжный/g; s/Ненадежный/Ненадёжный/g; s/ненадежный/ненадёжный/g;' /opt/google/chrome/locales/ru.pak
@dima74
dima74 / cummedian.py
Created May 7, 2017 18:23
Python cummedian function
def cummedian_line(a):
"""
По строке (a_i) строит последовательность медиан
result_i == a[:i+1].median()
http://stackoverflow.com/a/10657732
Аж O(nlog(n))!!!
"""
class minheap(list):
from flask import Flask
app = Flask(__name__)
@app.route('/привет')
def hello_world():
return 'Hello World!'