Skip to content

Instantly share code, notes, and snippets.

@Dmitri-Sintsov
Dmitri-Sintsov / load_script.js
Created December 6, 2024 10:53
Load global javascript
function loadScript(url, onload) {
fetch(url)
.then(function(response) {
if (!response.ok) {
throw new Error(`HTTP error. Status: ${response.status}`);
}
return response.blob();
})
.then(function(blob) {
let objectUrl = URL.createObjectURL(blob),
@Dmitri-Sintsov
Dmitri-Sintsov / table_sum_rows.js
Created August 4, 2024 10:57
Sum of table rows in Javascript and format cell numbers.
function prettify (num, separator) {
var n = (typeof num === "string") ? num : num.toString();
var sep = typeof separator === "undefined" ? " " : separator;
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + sep);
}
// SUMM TABLE ROWS
function sumTableRows() {
var table = document.getElementById("mainTab");
let lastRow = table.rows[table.rows.length - 1];
@Dmitri-Sintsov
Dmitri-Sintsov / flake8.xml
Last active December 29, 2016 09:09 — forked from jsmits/flake8.xml
PyCharm Flake8 Configuration XML that uses current virtualenv interpreter.
<toolSet name="Code Checking">
<tool name="Flake8" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="$PyInterpreterDirectory$/python" />
<option name="PARAMETERS" value="-m flake8 --max-complexity 10 --ignore E501 $FilePath$" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
<filter>
<option name="NAME" value="Filter 1" />
<option name="DESCRIPTION" />
@Dmitri-Sintsov
Dmitri-Sintsov / main.py
Created August 16, 2015 19:37
Simple proxy server in Python with HTML text substitution.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import lxml.html
from lxml.etree import tostring as etree_tostring
import re
import SocketServer
import SimpleHTTPServer
import shutil
import StringIO
import urllib2