Skip to content

Instantly share code, notes, and snippets.

View maxp's full-sized avatar

Maxim Penzin maxp

View GitHub Profile
@maxp
maxp / linux-tcp.txt
Created December 2, 2010 09:56
Tuning the Linux Kernel for many tcp connections
Put these in /etc/sysctl.conf then run sysctl -p to apply them.
# General gigabit tuning:
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_syncookies = 1
# this gives the kernel more memory for tcp
@maxp
maxp / NMEA_checksum
Created September 4, 2011 17:44
Calculating an NMEA Checksum (C#)
// Calculates the checksum for a sentence
// Calculates the checksum for a sentence
static string getChecksum(string sentence) {
//Start with first Item
int checksum= Convert.ToByte(sentence[sentence.IndexOf('$')+1]);
// Loop through all chars to get a checksum
for (int i=sentence.IndexOf('$')+2 ; i<sentence.IndexOf('*') ; i++){
// No. XOR the checksum with this character's value
checksum^=Convert.ToByte(sentence[i]);

Recommendations

Repository

В репозитории содержится программный код, ресурсные файлы, сопутствующая документация и другие файлы, необходимые для разработки/сборки/тестирования приложения.

README.md

Основные секции:

@maxp
maxp / gitignore
Last active April 21, 2023 01:44
generic gitignore
#
# generic .gitignore
#
## no hiddens in scm
.*
## editor backups
*~
*.bak
import jinja2
import markdown
def safe_markdown(text):
return jinja2.Markup(markdown.markdown(text, ...))
env = jinja2.Environment(...)
env.filters['markdown'] = safe_markdown
@maxp
maxp / block-tor.sh
Created June 5, 2012 00:09
iptables Tor filter
ipset -N tor iphash
wget -q https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$MY_IP -O - | sed '/^#/d' |while read IP
do
ipset -q -A tor $IP
done
iptables -A INPUT -m set --match-set tor src -j DROP
(def translit-table-ru-en
(apply array-map [\a "a"
\b "b"
\c "c"
\d "d"
\e "e"
\f "f"
\g "g"
\h "h"
\i "i"
@maxp
maxp / grouped-dec.clj
Created February 8, 2022 18:12
grouped decimal number formatter
(defn grouped-dec [decimal-number]
;; NOTE: handle sign separately
(when decimal-number
(let [s (str decimal-number)
[deci fract] (str/split s #"\.")
grouped
(->> deci
(reverse)
(partition 3 3 nil)
(map #(apply str %))
import jinja2
import scrubber # http://pypi.python.org/pypi/scrubber
def sanitize_html(text):
return jinja2.Markup(scrubber.Scrubber().scrub(text))
jinja_env.filters['sanitize_html'] = sanitize_html
@maxp
maxp / .gitignore
Last active November 18, 2021 07:57
Generic .gitignore
#
# maxp.dev: generic .gitignore
#
## no hiddens in scm
.*
## editor backups
*~
*.bak