Skip to content

Instantly share code, notes, and snippets.

View vanadium23's full-sized avatar

Ivan Chernov vanadium23

View GitHub Profile
module.exports = async function (file, folder, tp) {
if (file.path(true) == "Untitled.md") {
let filename = await tp.system.prompt("Как назвать файл?", null, true);
filename = tp.user.sanitaze_filename(filename);
await tp.file.move(`${folder}/${filename}`);
return filename;
}
return file.title;
}
var illegalRe = /[\/\?<>\\:\*\|"]/g;
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
var reservedRe = /^\.+$/;
var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
var windowsTrailingRe = /[\. ]+$/;
function truncate(str, num) {
if (str.length > num) {
return str.slice(0, num) + "...";
} else {
@vanadium23
vanadium23 / slack_second_time.js
Created April 12, 2023 05:34
Tampermonkey script to view "office" time
// ==UserScript==
// @name Second timezone for Slack web client
// @namespace http://vanadium23.me/
// @version 0.1
// @description Add second time on element hover
// @author vanadium23
// @match https://app.slack.com/client/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
@vanadium23
vanadium23 / remove-twitter-social-actions.js
Created December 3, 2019 17:54
Tampermonkey script for twitter social activity
// ==UserScript==
// @name Remove twitter social actions
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove likes and retweets from twitter
// @author @vanadium23
// @match https://twitter.com/*
// @ran-at document-idle
// @grant none
// ==/UserScript==
@vanadium23
vanadium23 / pocket-counters.js
Last active July 12, 2022 14:48
Script for tampermonkey to add articles count in selection list (My list, archive, favorites)
// ==UserScript==
// @name Pocket Counters
// @namespace http://vanadium23.me/
// @version 0.5
// @description Add counters to pocket list
// @author vanadium23
// @match https://app.getpocket.com/*
// @ran-at document-idle
// @grant none
// ==/UserScript==
@vanadium23
vanadium23 / emulate_3g.sh
Created January 17, 2018 08:33
Emulate 3g with tc
# change some_device_name to according linux network device, e.g.: eth0
# tc requires sudo for non-root user!
tc qdisc add dev some_device_name root handle 1: htb default 12
tc class add dev some_device_name parent 1:1 classid 1:12 htb rate 1.6mbit ceil 1.6mbit
tc qdisc add dev some_device_name parent 1:12 netem delay 150ms
# debug all requests
import requests
import logging
import http.client
http.client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
from babel import Locale, UnknownLocaleError
def guess_lang_by_country(country):
try:
locale_string = 'und_{}'.format(country.upper())
locale = Locale.parse(locale_string)
return locale.language
except (UnknownLocaleError, ValueError):
return None
@vanadium23
vanadium23 / .gitconfig
Created February 10, 2016 16:04
My .gitconfig
[alias]
# Shortening aliases
co = checkout
cob = checkout -b
f = fetch -p
c = commit
p = push
ba = branch -a
bd = branch -d
bD = branch -D
Авторизация прошла успешно)
Теперь нажмите Enter в своём терминале, чтобы получить я мог сохранить Ваш access token.