Skip to content

Instantly share code, notes, and snippets.

@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
Title: ПО СЦЕНАРИЮ
Authors: Михаил Морозов, Лев Калимуллин, Константин Тупицын, Владимир Бабин
Draft date: 04/12/2019
Contact: [email protected]
.ИНТ. ОФИС. ЗАЛ С ТЕХНИКОЙ – НОЧЬ
ЭКРАН НОУТБУКА включается. Название фильма. Печатается сценарий.
@chiliec
chiliec / example.go
Created November 30, 2017 08:53
Склонение числительных в golang
func declOfNum(number int, titles []string) string {
cases := []int{2, 0, 1, 1, 1, 2}
var currentCase int
if number % 100 > 4 && number % 100 < 20 {
currentCase = 2
} else if number % 10 < 5 {
currentCase = cases[number%10]
} else {
currentCase = cases[5]
}
<SearchkitAutosuggest
placeholder=" "
highlightFirst={true}
autofocus={true}
queryHandler={
new QueryAccessor("q", {
queryFields: ["full_address"],
queryOptions: {}
})
}