Skip to content

Instantly share code, notes, and snippets.

View pointofpresence's full-sized avatar
🏠
Working from home

ReSampled pointofpresence

🏠
Working from home
View GitHub Profile
javascript:void function(){function truncateString(e,t){return e.length>t?e.slice(0,t):e}const title=document.title,href=location.href,host=new URL(href).host,cleanHost=host.replace(/[^a-zA-Z0-9]/g,"-");let finalHost=cleanHost.replace(/--/g,"-");finalHost.length||(finalHost="local");let sel=window.getSelection().toString();0===sel.length&&(sel=prompt("Description"));let text=`## ${title}\n\n${href}${sel&&sel.length>0?`\n\n${sel}`:""}`;const textarea=document.createElement("textarea");textarea.value=text,document.body.appendChild(textarea),textarea.select(),document.execCommand("copy");let command=`obsidian://advanced-uri?filepath=__INBOX/${finalHost}&mode=new`;if(document.queryCommandSupported("copy")){const e=document.execCommand("copy");document.body.removeChild(textarea),e?(console.log("Текст успешно скопирован в буфер обмена"),command=`obsidian://advanced-uri?filepath=__INBOX/${finalHost}&clipboard=true&mode=new`):(console.error("Перенос через URL"),command=truncateString(`${command}&data=${text=encodeURI
@pointofpresence
pointofpresence / set data attribute.js
Last active March 31, 2024 14:13
JS: Установить значение data-атрибута DOM-элемента
script.dataset.ednaWidget = null;
// установит значение data-edna-widget="null" у элемента script
@pointofpresence
pointofpresence / find-unused-css.js
Last active December 21, 2023 20:00 — forked from michaelnordmeyer/find-unused-css.js
Find unused CSS rules on a page
(function() {
for (var ssi = 0; ssi < document.styleSheets.length; ssi++) {
let rules;
try {
rules = document.styleSheets[ssi].cssRules || [];
} catch (e) {
rules = []
}
var sheetHref = document.styleSheets[ssi].href || 'inline';
@pointofpresence
pointofpresence / midi.py
Created August 16, 2023 13:16
Python midi to system
"""
pip install rtmidi
http://zabaykin.ru/?p=200
"""
import time
import rtmidi
import win32api
#import win32clipboard
@pointofpresence
pointofpresence / what_is_1e3.js
Last active May 5, 2023 22:05
From pointofpresence.ru
> parseInt(1000)
1000
> parseInt(1000.0)
1000
> parseInt("1000.0")
1000
> parseInt(1e3)
@pointofpresence
pointofpresence / helpers.js
Created April 26, 2023 17:50
Array to number array
const prev = oldVersion.split('.').map(Number);
const next = newVersion.split('.').map(Number);
@pointofpresence
pointofpresence / get length of biggest nested array.js
Last active March 31, 2024 14:08
JS: Получить размер самого большого вложенного массива
// get length of biggest nested array
const maxLength = Math.max(...sheetsArray.map(subArr => subArr.length));
@pointofpresence
pointofpresence / quoteOfTheDay.js
Created February 21, 2023 08:38
Quote of the day
const dtNow = new Date();
const intTZOffset = dtNow.getTimezoneOffset() * 60000; // automatically adjust for user timezone
const intNow = dtNow.getTime() - intTZOffset;
const intDay = Math.floor(intNow / 86400000); // The number of 'local' days since Jan 1, 1970
const randomIndex = intDay % QuotesData.length;
const item = QuotesData[randomIndex];
def get_page(url):
ua = r'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36'
exe = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
args = f'"{exe}" --headless --disable-gpu --dump-dom --user-agent="{ua}" "{url}"'
sp = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = sp.communicate()
print(err, 'error') if err else None
return out.decode('utf-8') if out else ''
@pointofpresence
pointofpresence / StyledConsoleLog.js
Created January 16, 2023 06:12
Styled console.log()
console.log('%c[MESSAGES.SCHEDULE at ]', 'color: blue;font-weight:bold')