Skip to content

Instantly share code, notes, and snippets.

View sergiks's full-sized avatar

Sergei Sokolov sergiks

  • Russia | Europe | Thailand
View GitHub Profile
@sergiks
sergiks / TensorController.php
Last active February 21, 2020 19:38
Lumen controller "talking" to TensorFlow Serving REST API
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class TensorController extends Controller
{
/**
* Create a new controller instance.
@sergiks
sergiks / README.md
Last active April 27, 2024 08:50
Let's Encrypt wildcard certificates in docker

NGINX and Certbot example with CloudFlare API in Docker

Sample config files to demonstrate seup that creates and updates free SSL certificates from Let's Encrypt given that the domains are maintained at CloudFlare service.

How it works

Certbot verifies domains ownership by accessing CloudFlare API that adds temporary TXT DNS records. To enable it You must provide your CloudFlare API token. More details in documentation for dns-cloudflare Certbot plugin.

Certbot saves created certificates in Docker volume certbot_etc. Pay attention to output of the certbot run - it mentions path to the created certificates.

@sergiks
sergiks / vk-image-subst.md
Created September 19, 2019 11:54 — forked from bedefaced/vk-image-subst.md
Подмена картинок в посте ВКонтакте

По мотивам https://vk.com/id232967147 / https://vk.com/mgnoveniag

  1. Создаём пост с любой картинкой.
  2. Ждём полгода/год. Открываем газету, выбираем важные события современности.
  3. Редактируем у себя на комплюктере исходную картинку, описывая важные события современности.
  4. Открываем ту старую фотографию из поста ВКонтакте, нажимаем "Редактировать".
  5. Открываем инструменты разработчика в своём браузере и узнаём значение переменной cur.filterSaveOptions.upload_url.
  6. Пишем программу на HTML. Создаём файлик upload.html:
/**
* Parses SMS message text from Yandex.Money
* extracts three numbers:
* confirmation code, transaction amount and account number.
*
* @param string $text message text
*
* @throws Exception on parse failure
*
* @return array
@sergiks
sergiks / hash-crypt.js
Created July 1, 2019 09:56
XOR encrypt-decrypt location hash
((w) => {
function superpooper(secret) {
const pass = encodeURIComponent(secret);
return function onHashChange(){
var hash = w.location.hash.replace(/^#/,"");
if (!hash.length) return;
const xor = s => s.split('').map((c,i)=>String.fromCharCode(c.charCodeAt(0)^pass.charCodeAt(i%pass.length))).join('');
@sergiks
sergiks / diff.js
Created June 20, 2019 19:51
WhatsApp two groups members intersect
(() => {
const B = '+7 901 555-55-55, +7 903 777-77-77'
.split(', ').sort();
const A = '+7 901 555-55-55, +7 926 222-22-22'
.split(', ').sort();
const both = [], onlyA = [], onlyB = [], lA = A.length, lB = B.length;
@sergiks
sergiks / compile-ffmpeg.sh
Last active April 10, 2019 17:18
Compile ffmpeg and ffprobe for AWS Lambda
#!/bin/bash
############################################
#
# Compile ffmpeg and ffprobe for AWS Lambda
#
# Run this on a fresh AWS EC2 instance
# running same AMI as AWS Lambda:
# https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
# AMI: amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
@sergiks
sergiks / getEndOfWeek.js
Created February 11, 2019 11:53
JS function to get nearest end of week date time as a YYY/MM/DD HH:ii:ss string
/**
* returns date-time of the nearest week end
* as a string "YYYY/MM/DD HH:ii:ss"
*/
function getEndOfWeek() {
const D = new Date();
D.setDate(D.getDate() - D.getDay() + (D.getDay() ? 7 : 0));
D.setHours(23, 59 - D.getTimezoneOffset(), 59, 0);
return D.toISOString().slice(0, 19).replace('T', ' ').replace(/-/g,'/');
}
@sergiks
sergiks / table.js
Last active January 26, 2019 17:21
Table generation for Alexandra
AmCharts.loadFile( "data.csv", {}, function( response ) {
/**
* Parse CSV
*/
var data = AmCharts.parseCSV( response, {
"useColumnNames": true
} );
@sergiks
sergiks / browser.py
Created October 17, 2018 06:08
Python QT web browser webview component example
# src: https://python.su/forum/topic/33143/?page=1#post-181129
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWebEngineWidgets import QWebEngineView
class Browser(QWebEngineView):
def __init__(self):
super().__init__()