Skip to content

Instantly share code, notes, and snippets.

View chiliec's full-sized avatar

Vladimir Babin chiliec

View GitHub Profile
@chiliec
chiliec / convert-video.sh
Created April 24, 2026 19:42
Convert video to MP4 with optional quality presets
#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
convert-video — convert video to MP4 with optional quality presets
Usage:
convert-video [--quality small|tiny] [--force] <input>
convert-video --help
@chiliec
chiliec / scrolling.scpt
Created June 17, 2025 17:22
Scrolling to any webpage in Safari with Shortcuts
tell application "Safari"
tell front document
do JavaScript "
(function() {
// Настройки скорости - меняй здесь
const SCROLL_SPEED = 1; // пиксели за шаг
const SCROLL_DELAY = 80; // миллисекунды между шагами
// Удаляем старые элементы
document.querySelectorAll('#__scrollTriggerBtn, #__speedControls').forEach(el => el.remove());
@chiliec
chiliec / trade.py
Last active April 29, 2026 14:00
Dead simple XRocket trading bot
import asyncio
import requests
from xrocket import TradeAPI
API_KEY = "XROCKET_API_KEY"
PAIR = "WOOF-TONCOIN"
MIN_VALUE = 1e-7 # 0.0000001
DEVIATION = 1e-1 # 0.1 or 10%
POOL_ADDR = "EQBLj-WT9pKhDCBx9EQHLZyPbq2flKspXDl6BPc9GzfIU4Jh"
@chiliec
chiliec / generate.ts
Created April 19, 2024 08:19
Stable Diffusion 3.0 (SD3) image-to-image code example
import FormData from "form-data";
import fs from "node:fs";
import axios from "axios";
export async function generate(
originalImagePath: string,
resultImageName: string,
prompt: string,
negativePrompt: string,
strength: number,
@chiliec
chiliec / Roman.swift
Created February 20, 2024 08:49
12. Integer to Roman
/**
* Question Link: https://leetcode.com/problems/integer-to-roman/
*/
class Solution {
enum Roman: Int, CaseIterable {
case I = 1
case IV = 4
case V = 5
case IX = 9
case X = 10
@chiliec
chiliec / App.java
Created September 30, 2020 19:23
Find all transport tickets with "lucky" numbers
public class App {
public static void main(String[] args) {
for (int i = 0; i <= 999999; i++) {
if (isLuckyTicket(i)) {
System.out.println(i);
}
}
}
private static boolean isLuckyTicket(int ticketNumbers) {
@chiliec
chiliec / randomEmoji.go
Created July 9, 2020 18:04
Get random emoji in GoLang
// (c) 2020 Vladimir Babin
// This code is licensed under MIT license.
func randomEmoji() string {
rand.Seed(time.Now().UnixNano())
// http://apps.timwhitlock.info/emoji/tables/unicode
emoji := [][]int{
// Emoticons icons
{128513, 128591},
// Transport and map symbols
{128640, 128704},
@chiliec
chiliec / feed.js
Last active July 2, 2020 09:01
Lambda function to get average VIZ price feed from bts.quotes.bank.viz.plus account https://eiy5lsown5.execute-api.us-east-2.amazonaws.com
exports.handler = async function (event) {
return new Promise(function (resolve, reject) {
let viz = require("viz-js-lib");
viz.config.set("websocket", "https://node.viz.cx/");
viz.api.getAccounts(["bts.quotes.bank.viz.plus"], function (err, result) {
if (err) {
reject(Error(err));
}
let blockNum = result[0]["custom_sequence_block_num"];
viz.api.getBlock(blockNum, function (err, res) {
@chiliec
chiliec / VIZ_PUBLIC_NODE_SETUP.md
Last active January 27, 2021 18:03
VIZ blockchain public node configuration

// See article How to setup VIZ blockchain public node // https://control.viz.world/media/@lex/apinode/

server {
    server_name node.viz.cx;

    # uncomment when node under maintenance 
    # location / { proxy_pass http://api.viz.world/; }
    
@chiliec
chiliec / CustomKeyDecodingStrategy.swift
Last active April 11, 2019 07:32
Example of using custom JSONDecoder().keyDecodingStrategy
import Foundation
// What if we wait lowercased key, but suddenly has come uppercased? JSONDecoder().keyDecodingStrategy!
let json = """
{"NAME": "Vova"}
"""
struct Model: Decodable {
let name: String