Skip to content

Instantly share code, notes, and snippets.

Avatar
😋
Working from home

Vladimir Babin chiliec

😋
Working from home
View GitHub Profile
@chiliec
chiliec / App.java
Created Sep 30, 2020
Find all transport tickets with "lucky" numbers
View App.java
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 Jul 9, 2020
Get random emoji in GoLang
View randomEmoji.go
// (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 Jul 2, 2020
Lambda function to get average VIZ price feed from bts.quotes.bank.viz.plus account https://eiy5lsown5.execute-api.us-east-2.amazonaws.com
View feed.js
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 Jan 27, 2021
VIZ blockchain public node configuration
View VIZ_PUBLIC_NODE_SETUP.md

// 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 Apr 11, 2019
Example of using custom JSONDecoder().keyDecodingStrategy
View CustomKeyDecodingStrategy.swift
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
View STATYA.fountain
Title: ПО СЦЕНАРИЮ
Authors: Михаил Морозов, Лев Калимуллин, Константин Тупицын, Владимир Бабин
Draft date: 04/12/2019
Contact: citiescontact@yandex.ru
.ИНТ. ОФИС. ЗАЛ С ТЕХНИКОЙ – НОЧЬ
ЭКРАН НОУТБУКА включается. Название фильма. Печатается сценарий.
@chiliec
chiliec / example.go
Created Nov 30, 2017
Склонение числительных в golang
View example.go
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]
}
View SearchkitAutosuggest.js
<SearchkitAutosuggest
placeholder=" "
highlightFirst={true}
autofocus={true}
queryHandler={
new QueryAccessor("q", {
queryFields: ["full_address"],
queryOptions: {}
})
}
View Addresses.js
import React, { Component } from 'react';
import extend from 'lodash/extend';
import { SearchkitManager,SearchkitProvider,
SearchBox, Pagination, HitsStats, NoHits, ViewSwitcherHits,
Layout, TopBar, LayoutBody, LayoutResults,
ActionBar, ActionBarRow, QueryAccessor} from 'searchkit';
import './index.css';
import {
SearchkitAutosuggest, HierarchicalRefinementDatasource,
@chiliec
chiliec / wordpress_import.php
Last active May 28, 2017
export posts to wordpress
View wordpress_import.php
<?php
date_default_timezone_set('America/Los_Angeles');
$mysqli = new mysqli("localhost:8889", "root", "root", "kripipastacom");
if ($mysqli->connect_errno) {
echo "Не удалось подключиться к MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$file = fopen('export.xml', "w+");
$header = '<?xml version="1.0" encoding="UTF-8" ?>