Skip to content

Instantly share code, notes, and snippets.

View abesmon's full-sized avatar
🎱
SHIT ==> GOLD

Alexey Lysenko abesmon

🎱
SHIT ==> GOLD
View GitHub Profile
@abesmon
abesmon / UIColorHexString.swift
Created May 18, 2022 17:40
property wrapper for codable color hex string
import UIKit
@propertyWrapper
struct UIColorHexString: Codable {
private var stringValue: String
var wrappedValue: UIColor {
get { UIColor(hexString: stringValue) }
set { stringValue = newValue.hexString }
}
@abesmon
abesmon / CodableEnum.swift
Last active May 18, 2022 17:39
codable property wrapper
import UIKit
@propertyWrapper
struct CodableEnum<T: RawRepresentable>: Codable where T.RawValue: Codable {
private var value: T.RawValue
var wrappedValue: T {
get { T(rawValue: value)! }
set { value = newValue.rawValue }
}
@abesmon
abesmon / now.py
Last active September 21, 2021 13:33
for epoch in range(num_epochs):
for n, (real_samples, _) in enumerate(train_loader):
# Обучение дискриминатора
optimizer_discriminator.zero_grad()
# Данные для тренировки дискриминатора
real_samples = real_samples.to(device=device)
real_samples_labels = torch.ones((batch_size, 1)).to(device=device)
real_outp = discriminator(real_samples)
#Created by: Adobe Photoshop Export Color Lookup Plugin
#Copyright: (C) Copyright 2017 RocketStock
TITLE "Sepia"
#LUT size
LUT_3D_SIZE 32
#data domain
DOMAIN_MIN 0.0 0.0 0.0
DOMAIN_MAX 1.0 1.0 1.0
@abesmon
abesmon / FakeLiquid.frag
Last active April 28, 2021 08:10
Fake Liquid shader made in GLSL to run in TouchDesigner. Though, can be ported painlessly to any other engines/languages :) It also supports shaking, but some external script should provide wobble angles :)
uniform vec3 uLine;
uniform vec4 uLiquidColor;
uniform float uLineHeight;
uniform float uFrenelPow;
in Vert {
vec3 objectPoint;
vec3 normalForCam;
} iVert;
@abesmon
abesmon / interiorMapping.frag
Created February 22, 2021 17:09
Interior mapping made for TouchDesigner in GLSL
// Example Vertex Shader
out v2f {
flat int cameraIndex;
vec3 p;
vec4 pos;
vec2 uv;
mat3 tbn;
} oVert;
@abesmon
abesmon / virtualSDF.frag
Created February 21, 2021 21:37
SDF but that is calculated to the origin of mesh. It can be used to create virtual space with different sdf shaped inside of any mesh
uniform float uTime;
uniform sampler2D frontTex;
in v2f {
flat int cameraIndex;
vec4 pos;
vec3 originalP;
vec2 uv;
mat3 tbn;
@abesmon
abesmon / parallax.frag
Last active May 21, 2021 20:16
Пример того, как с помощью шейдера можно создать ощущение объема. Шейдер написан для работы с TouchDesigner, но в нем нет ничего такого, что было-бы невозможно адаптировать под другое окружение :) пример: https://www.instagram.com/p/CLh7OsCiSPc/
uniform vec3 heights;
uniform sampler2D texLayerOne;
uniform sampler2D texLayerTwo;
uniform sampler2D texLayerThree;
uniform sampler2D frontTex;
in v2f {
flat int cameraIndex;
vec4 pos;
func randomString(length: Int) -> String {
return (0..<length).map { _ in String(Int.random(in: 0...9)) }.joined()
}
func randomStringBuffer(length: Int) -> String {
var buffer = ""
(0..<length).forEach { _ in buffer += String(Int.random(in: 0...9)) }
return buffer
}
@abesmon
abesmon / PluralForm.swift
Created January 16, 2020 14:20 — forked from youmee/PluralForm.swift
Swift Russian Plural Form Function
//
// Orig created by youmee https://gist.github.com/youmee/bc23dd6088e59609609f
// Modified by Лысенко Алексей Димитриевич on 09/09/2019.
// Copyright © 2019 SMG All rights reserved.
//
import Foundation
@objc class Pluralizer: NSObject {
@objc class PluralForms: NSObject {