Skip to content

Instantly share code, notes, and snippets.

View stokito's full-sized avatar
Self-hosting become easier 🤗

Sergey Ponomarev stokito

Self-hosting become easier 🤗
View GitHub Profile
@stokito
stokito / date_utils.go
Created July 1, 2022 14:36
Start-End date parsing
func handleRequest(w http.ResponseWriter, r *http.Request) {
args := r.URL.Query()
startDateStr := args.Get("start") // &start=2021-10-15
endDateStr := args.Get("end") // &end=2021-10-15
startDate := parseDate(startDateStr, "today")
endDate := parseDate(endDateStr, "tomorrow")
}
func atMidnight(startDate time.Time) time.Time {
return startDate.Truncate(24 * time.Hour).In(time.UTC)
@stokito
stokito / onion-gen.js
Created June 28, 2022 17:21 — forked from ttaubert/onion-gen.js
Generating custom .onion names with the WebCrypto API
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/*
* thirty-two
* https://github.com/chrisumbel/thirty-two
*
@stokito
stokito / torrc
Last active June 27, 2022 16:13
Single Onion Service
# https://riseup.net/ru/security/network-security/tor/onionservices-best-practices
# https://www.kicksecure.com/wiki/Non_Anonymous_Onion_Encryption_and_NAT_Traversal
# https://tor.stackexchange.com/questions/14674/problems-setting-up-a-single-onion-service
# https://medium.com/hackernoon/how-does-tor-really-work-c3242844e11f
# https://www.youtube.com/watch?v=VmsFxBEN3fc
# https://www.youtube.com/watch?v=HQXRURfrf8w
# Edit /etc/tor/torrc
SOCKSPort 0
@stokito
stokito / app_emojis.txt
Created May 21, 2022 21:56
Emojis that may be used instead of an icon for applications
⚙️ settings
🔧 settings config
🛡️ security privacy
📁 folder
📂 open folder/file
📄 empty file
🗒️ text file
📝 memo/logs
🚪 exit
🔗 link
@stokito
stokito / mail.html
Last active May 22, 2022 14:54
Parse EMail message in JavaScript sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EMail message parse in JavaScript sample</title>
<script>
function addHeader(header, headers) {
if (header === "") {
return
}
@stokito
stokito / edit_file.sh
Last active March 25, 2024 15:39
quickly select a file and then edit it. If needed ask for a root password
FILE=$(zenity --file-selection);
if [ -z "$FILE" ]; then
exit
fi
if [ ! -f "$FILE" ]; then
dir=$(dirname "$FILE")
if [ -w "$dir" ]; then
if [ -x /usr/bin/gedit ]; then
gedit "$FILE"
else
@stokito
stokito / onion-svc-v3-client-auth.sh
Last active April 22, 2024 07:26 — forked from mtigas/onion-svc-v3-client-auth.sh
experiments with using v3 onions with client auth (as of tor 0.3.5.X)
#!/bin/sh
# needs openssl 1.1+
# needs base64 and base32 utilities.
# On OpenWrt you may install coreutils-base64 and coreutils-base32.
# BusyBox can be compiled with them.
# On other systems try basenc or basez https://manpages.debian.org/testing/basez/base32hex.1.en.html
##### generate a key
@stokito
stokito / README.md
Last active May 11, 2023 17:26
CGI script to echo a request

Put the script into /www/cgi-bin/echo.sh and make executable:

chmod +x /www/cgi-bin/echo.sh

Then you can start a webserver e.g.:

busybox httpd -f -vv -p 8080 -h /www

Now you can send requests e.g. with curl or wget:

@stokito
stokito / countries.html
Created March 22, 2022 12:06
HTML country codes
<select class="form-select" id="country" name="country">
<option value="" selected>Any</option>
<option value="USA">🇺🇸 United States of America</option>
<option value="AFG">🇦🇫 Afghanistan</option>
<option value="ALB">🇦🇱 Albania</option>
<option value="DZA">🇩🇿 Algeria</option>
<option value="ASM">🇦🇸 American Samoa</option>
<option value="AND">🇦🇩 Andorra</option>
<option value="AGO">🇦🇴 Angola</option>
<option value="AIA">🇦🇮 Anguilla</option>
@stokito
stokito / java.md
Created February 4, 2022 12:26
alternatives to JDK