Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / gist:ae83d888ba16afc4f4dd41714f419ada
Created January 9, 2018 11:40 — forked from sonnyt/gist:8585696
JavaScript Check If Element Has Class
function hasClass(element, className) {
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className);
}
var myDiv = document.getElementById('MyDiv');
hasClass(myDiv, 'active');
// OR
@alekssamos
alekssamos / TEST.BAS
Last active April 21, 2018 11:40
Школа Информатика Тест 1 V2
CLS
locate 1, 30 : PRINT "Тест про компьютеры."
10 locate 2, 20 : PRINT "Начать? 1 да, 0 нет"
INPUT "", x
IF x = 0 THEN : END
IF x <> 1 THEN : GOTO 10
y = 0
PRINT "При ответе используйте соответствующую варианту цифру"
PRINT "без лишних символов и знаков"
@alekssamos
alekssamos / edit_f.php
Created June 20, 2019 21:03
Beget bug file update (touch)
<?php
// Любой скрипт любым скриптом.
/* я нашёл, из за touch. Ну почему так происходит, если данные уже обновлены? Сервер хранит старые копии для возможного отката? Хотя нет. Возможно, это просто кэш, основанный на дате изменения файла. Но все равно, где же тогда хранятся данные после уже изменение скрипта? */
$f = "f.php";
$time = @filemtime($f);
file_put_contents($f, "\n echo '".rand(111, 9999)."';", FILE_APPEND) or exit("error!");
echo 'file updated. Changes will be applied in ~ 40 minutes. Check <a href="'.$f.'?'.uniqid().'">here</a>';
@touch($f,$time,$time);
@alekssamos
alekssamos / cookiefunctions.js
Created June 25, 2019 02:30
convenient functions for working with cookies in js. I found on the site javascript ru, I have been using for more than 5 years. I like.
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
))
return matches ? decodeURIComponent(matches[1]) : undefined
}
function setCookie(name, value, props) {
props = props || {}
var exp = props.expires
if (typeof exp == "number" && exp) {
@alekssamos
alekssamos / 1px.md
Created July 12, 2019 11:34 — forked from hughker/1px.md
base64 1px Gray GIF
<!-- 1px Transparent -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">

<!-- 1px Gray -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==">

<!-- 1px Black -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">
@alekssamos
alekssamos / ng.html
Last active November 24, 2019 22:06
NVDA REMOTE LINK GENERATOR
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Генератор ссылок NVDAREMOTE</title>
<style>
// http://pauljadam.com/demos/title-keyboard.html
// edited
input[title]:focus:after { content:attr(title);
background-color: black;
@alekssamos
alekssamos / clipboard_image_post_js.html
Created March 13, 2020 20:38 — forked from kidatti/clipboard_image_post_js.html
Upload clipboard image to server (HTML5 / JavaScript / AJAX)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<script>
@alekssamos
alekssamos / deleteConversations_vk_execute.js
Last active May 23, 2020 10:48
Удаление всех диалогов кроме бесед и сообществ. Вставить в https://vk.com/dev/execute и выполнить несколько раз.
var messages = API.messages.getConversations({"count":200});
var i=-1;
var d=0;
var ids=[];
var peer_id=0;
while(i<200) {
i=i+1;
peer_id = messages.items[i].conversation.peer.id;
if(peer_id > 0 && peer_id < 2000000000) {
if(d<=23) {
@alekssamos
alekssamos / arrayBufferToBase64.js
Created June 5, 2020 06:33 — forked from Deliaz/arrayBufferToBase64.js
Convert array buffer to base64 string
function arrayBufferToBase64(buffer) {
let binary = '';
let bytes = new Uint8Array(buffer);
let len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
def smartsplit(t, s, e):
"""
smartsplit(text, start_position, end_position)
Splits a string into parts according to the number of characters.
If there is a space between the start and end positions, split before a space, the word will not end in the middle.
If there are no spaces in the specified range, divide as is, by the finite number of characters.
"""
t = t.replace("\r\n", "\n").replace("\r", "\n")
if(e >= len(t)): return [t]
l = []