Skip to content

Instantly share code, notes, and snippets.

View ruslux's full-sized avatar

Ruslan Roskoshny ruslux

  • Saint-Petersburg
View GitHub Profile
@ruslux
ruslux / flat_parsed.sql
Last active October 14, 2022 05:57
Example for materialized view from raw data store
CREATE MATERIALIZED VIEW example.parsed
(
`event_uuid` String,
`datetime` DateTime,
`a` Int32,
`b` Int32,
`c` Int32,
`d` Float64,
`e` Float64,
`f` Float64,
class ExampleButtonMapper: TeseBehaviour {
[Inject] public NetworkManager NetworkManager;
[Inject] public ProfileManager ProfileManager;
[Inject] public SoundManager SoundManager;
[Inject] public WindowManager WindowManager;
public async void _OnButton()
{
if (ProfileManager.HasResourcesToUpgrade()) {
SoundManager.PlayButtonSound();
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Reflection;
using Cysharp.Threading.Tasks;
using Oneman.DI;
using Object = UnityEngine.Object;
using System;
namespace Oneman.DI
{
[AttributeUsage(AttributeTargets.Field)]
public class Inject: Attribute {}
}
@ruslux
ruslux / ws_app.py
Last active September 19, 2024 12:30
aioredis fastapi websocket pubsub
import uvicorn
from aioredis import create_pool
from fastapi import FastAPI
from starlette.websockets import WebSocket
app = FastAPI()
REDIS_URL = 'redis://redis:6379'
REDIS_DB = 0
@ruslux
ruslux / google_api.py
Created July 24, 2019 05:31
google_api.py
bundle_id = 'gogoyuedu.book.job.news.learn.read'
api_key = 'Alkene-608a20735120.json'
validator = GooglePlayVerifier(bundle_id, api_key)
try:
validation_result = validator.verify(purchase_json['token'], sub_code, is_subscription=True)
except errors.GoogleError as exc:
logging.error('Purchase validation failed {}'.format(exc))
@ruslux
ruslux / old_qtile_config.py
Last active January 22, 2019 12:29
old_qtile_config.py
#! coding:utf-8
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget
mod = "mod4"
keys = [
Key(
[mod], "k",
from random import randint
def find_components(raw_array, value):
"""
~O(n) find first combination in `new_array` which sum equal `value`.
"""
# remove from array all values grand then needed value
array = list(filter(lambda x: x <= value, raw_array))