Skip to content

Instantly share code, notes, and snippets.

View titovanton's full-sized avatar

Anton Titov titovanton

View GitHub Profile
var ptn = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]+\.[a-zA-Z]+$/;
var email = 'mail@example.com';
ptn.test(email); // true
/**
* Recursive listing of all files inside path
* and all files inside of all folders and so on...
* But using stack algorithm instead recursion, which uses less RAM.
* About fs.Stats:
* https://nodejs.org/api/fs.html#fs_class_fs_stats
* @param path - path to root folder
* @param fn - callback function
* @return nothing.
* Expected parameters of the callback functin:
// TODO: needs to be done
const renameExists = () => {
/** Auto rename a file if the same name exists in a destination folder
* example: file.txt, file(1).txt, file(2).txt
*/
while (exists) {
let filename = exists.title;
let copyNumber = 1;
let ext = '';
# Atom sync-settings
import sys
import os
import random
sys.path.append('/webapps/django/spitekrepko3/')
from django.apps import apps
from django.core.wsgi import get_wsgi_application
#!/bin/bash
IPT='/sbin/iptables'
IPSET='/sbin/ipset'
IP=$(ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1)
ipset_trust=$(cat /root/ipset_trust.txt)
ipset_blacklist=$(cat /root/ipset_blacklist.txt)
$IPT -F
$IPT -t raw -F
[global]
netbios name = Apps
security = USER
#======================= Networking =======================
socket options = TCP_NODELAY IPTOS_LOWDELAY
local master = yes
time server = yes
read size - 4096
os level = 65
port_range = 40890-40890
port_random = no
check_hash = yes
directory = /usb_hdd/rtorrent-tmp
session = /usb_hdd/rtorrent-session
encoding_list = UTF-8
encryption = allow_incoming,enable_retry,prefer_plaintext
schedule = watch_directory,5,5,load_start=/home/titovanton/shared/*.torrent
schedule = low_diskspace,5,60,close_low_diskspace=100M
upload_rate = 0
@titovanton
titovanton / gl
Last active September 24, 2019 15:41
#! /bin/bash
# Put that script in to the /usr/local/bin/gl - without .sh
# Then give +x permissions
if [ -z $1 ]
then
PARAM=-10
else
PARAM=$1
fi
@titovanton
titovanton / dnr
Last active September 24, 2019 15:40
Docker: to remove all <none> images
#! /bin/bash
# Put that script in to the /usr/local/bin/dnr - without .sh
# Then give +x permissions
docker rmi -f $(docker images -f dangling=true -q)