Skip to content

Instantly share code, notes, and snippets.

@sevkin
sevkin / vcf2csv.py
Created Sep 13, 2020
конвертер контактов из яндекс почты в список для "рассылки"
View vcf2csv.py
import vobject
import csv
with open('abook.vcf', 'r') as abook:
with open('contacts.csv', 'w') as out:
writer = csv.writer(out)
writer.writerow(['Имя', 'Почта'])
for card in vobject.readComponents(abook):
if not hasattr(card, 'fn'):
continue
@sevkin
sevkin / bootstrap.yml
Last active Dec 24, 2019
ansible bootstrap python on deb based distros
View bootstrap.yml
- hosts: all
any_errors_fatal: True
gather_facts: no
become: True
tasks:
- name: test python-apt
raw: "which python && python -c \"import apt\""
ignore_errors: True
changed_when: False
failed_when: False
@sevkin
sevkin / Makefile
Created May 21, 2019
SSL generate without questions
View Makefile
CN := example.com
gen_key:
openssl req -nodes -newkey rsa:4096 -keyout $(CN).key.new -noout -subj \
"/C=RU/CN=www.$(CN)"
gen_csr:
openssl req -new -key $(CN).key -out $(CN).csr -subj \
"/C=RU/CN=www.$(CN)"
@sevkin
sevkin / getfreeport.go
Last active Jan 29, 2020
get free port in golang
View getfreeport.go
// GetFreePort asks the kernel for a free open port that is ready to use.
func GetFreePort() (port int, err error) {
var a *net.TCPAddr
if a, err = net.ResolveTCPAddr("tcp", "localhost:0"); err == nil {
var l *net.TCPListener
if l, err = net.ListenTCP("tcp", a); err == nil {
defer l.Close()
return l.Addr().(*net.TCPAddr).Port, nil
}
}
@sevkin
sevkin / ulimit.conf
Last active Mar 11, 2019
nginx php-fpm bitrix pcre.recursion_limit
View ulimit.conf
[Service]
LimitSTACK=infinity
# mkdir /etc/systemd/system/php-fpm.service.d
# cd /etc/systemd/system/php-fpm.service.d
# vi ulimit.conf
# systemctl daemon-reload
# systemctl restart php-fpm
@sevkin
sevkin / firewall_custom_rules.sh
Last active Dec 8, 2018
openwrt router + usb_ether modem
View firewall_custom_rules.sh
# luci > net > firewall > custom_rules
#
# add modem (eth1) to lan bridge
#
# drop modem dhcp (modem is static 192.168.1.2)
iptables -A input_lan_rule -p udp --src 192.168.1.2 --destination-port 68 -j DROP
iptables -A forwarding_lan_rule -p udp --src 192.168.1.2 --destination-port 68 -j DROP
@sevkin
sevkin / loader.html
Created Aug 21, 2017 — forked from bellbind/loader.html
[threejs][html5]STL File Viewer with HTML5 File API
View loader.html
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>STL File Viewer</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"
></script>
<script src="https://rawgit.com/mrdoob/three.js/master/examples/js/controls/TrackballControls.js"
></script>
<script src="loader.js"></script>
@sevkin
sevkin / mongo-docker.bash
Created Jul 27, 2017 — forked from davideicardi/mongo-docker.bash
Running mongodb inside a docker container (with mongodb authentication)
View mongo-docker.bash
# Create a container from the mongo image,
# run is as a daemon (-d), expose the port 27017 (-p),
# set it to auto start (--restart)
# and with mongo authentication (--auth)
# Image used is https://hub.docker.com/_/mongo/
docker pull mongo
docker run --name YOURCONTAINERNAME --restart=always -d -p 27017:27017 mongo mongod --auth
# Using the mongo "localhost exception" (https://docs.mongodb.org/v3.0/core/security-users/#localhost-exception)
# add a root user
@sevkin
sevkin / url_open.go
Created Jul 27, 2017
open url in default browser
View url_open.go
// https://stackoverflow.com/questions/39320371/how-start-web-server-to-open-page-in-browser-in-golang
// open opens the specified URL in the default browser of the user.
func open(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
@sevkin
sevkin / dnsmasq.yml
Last active Feb 13, 2017
Install standalone dnsmasq instead of NetworkManager controlled - ansible playbook - ubuntu 16.04
View dnsmasq.yml
---
- hosts: localhost
connection: local
# gather_facts: no
become: yes
vars:
- interfaces: ["lo", "docker0"]
tasks:
- name: install dnsmasq