Skip to content

Instantly share code, notes, and snippets.

View alekssamos's full-sized avatar
🎯
Focusing

alekssamos

🎯
Focusing
View GitHub Profile
@alekssamos
alekssamos / russian_linux.md
Last active July 27, 2021 09:58
translate Linux into Russian language / переводим Linux на русский язык

Переводим Linux на русский язык:

Редактируем от root файлы (хоть через nano,, хоть через gedit, хоть через mousepad, или любой другой на ваш выбор редактор, не забываем про sudo, если не из под root вошли в систему):

  1. /etc/default/locale Должна быть одна строка: LANG="ru_RU.UTF-8"
  2. /etc/locale.gen Снимаем комментарий в виде решётки # около строки ru-RU

Дальше вводим команду выбора и настройки языковых локалей системы sudo dpkg-reconfigure locales

@alekssamos
alekssamos / user-settings.conf
Created July 25, 2021 12:55
my settings for orca screen reader
{
"general": {
"magZoomerBorderSize": 1,
"magPointerFollowsZoomer": true,
"chatSpeakRoomName": false,
"largeObjectTextLength": 75,
"magEdgeMargin": 0,
"enabledSpokenTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; paragraph-style:; text-spelling:none;",
"magContrastLevel": 0,
"brailleAlignmentStyle": 0,
import wx
import urllib.request
import json
import webbrowser
API_KEY = ''
class NewsPanel1(wx.Panel):
def __init__(self, parent):
@alekssamos
alekssamos / pyinstaller_resource
Created July 23, 2020 17:53
_MEIPASS onefile
import os, sys
def resource(relative_path):
if getattr(sys, 'frozen', False):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath('.'), relative_path)
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 = []
@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);
}
@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 / 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 / telegram_callback_data_example.php
Created March 8, 2020 23:37
Telegram inlinekeyboardbutton callback_data query example
/* https://ru.stackoverflow.com/q/557656 */
/* Теперь понятно, как работает callback-data */
<?php
$access_token = 'xxx';
$api = 'https://api.telegram.org/bot' . $access_token;
$output = json_decode(file_get_contents('php://input'), TRUE);
$chat_id = $output['message']['chat']['id'];
$message = $output['message']['text'];
$callback_query = $output['callback_query'];
$data = $callback_query['data'];
@alekssamos
alekssamos / SqliteStore.php
Last active October 3, 2020 18:36 — forked from erikeldridge/SqliteStore.php
a simple key/val store using php & sqlite3
<?php
// a simple key/val store using php & sqlite3
// license: http://gist.github.com/375593
// edited by alekssamos
class SqliteStore {
protected $db;
public function __construct($tableName, $filePath = 'db.sqlite') {
$this->db = new SQLite3($filePath);
$this->tableName = $this->db->escapeString($tableName);