Skip to content

Instantly share code, notes, and snippets.

View v1vendi's full-sized avatar

Ilya Komsa v1vendi

View GitHub Profile
@v1vendi
v1vendi / template.js
Last active June 28, 2016 21:53
A tiny js template engine using Template Strings and template tag (manually minified is 432 bytes long without gzip)
function compileTemplate(templateElement, data){
//hack to get unencoded symbols from HTML node
var textarea = document.createElement('textarea');
textarea.innerHTML = templateElement.innerHTML;
var text = eval("with(data){html`" + textarea.value + "`}");
var tmpElement = document.createElement('div');
tmpElement.innerHTML = text;
@v1vendi
v1vendi / gist:96c98641d2f36c09ed094c56aba4857d
Created November 3, 2017 12:52
Extract tar.bz2 to psql
tar -xOf FILE.tar.bz2 | psql -h HOST -U USER -d DATABASE
@v1vendi
v1vendi / index.html
Last active October 21, 2018 21:27
React components for a page that does http request itself without redux
<title>Parcel demo</title>
<!-- <link rel=stylesheet href=./style.css /> -->
<style>
body {
max-width: 500px;
margin: auto;
}
#modal_holder:empty {
display: none;
}
@v1vendi
v1vendi / gist:da0a9f94a5564540b3aed38ad2798ad8
Last active August 20, 2019 19:32
How to update Node on Windows
Download new binary from nodejs.org
@v1vendi
v1vendi / button.js
Created September 5, 2019 17:19
Idea of React components composition
// i use bootstrap CSS classes for example
// class extension way:
const Button = ({ onClick, children, className }) => (
<button
class={`btn ${className}`.trim()}
onClick={onClick}
>
{children}
</button>
)
from random import randrange
from ortools.algorithms import pywrapknapsack_solver
PLAYERS_COUNT = 6
PLAYERS_IN_MATCH = 6
regions = {
'eu': 0,
'na': 1,
@v1vendi
v1vendi / hands_table.js
Created April 27, 2020 22:03
generate poker hands table
var values = Array.from('AKQJT98765432')
// values.map(j => `${values[Math.min(i,j)]}${values[Math.max(i,j)]}${i > j ? 's' : i < j ? 'o' : ''}`).join(', ')
var result = values.map(
(_,i) => values.map(
(_,j) => `${values[Math.min(i,j)]}${values[Math.max(i,j)]}${i > j ? 's' : i < j ? 'o' : ''}`.padEnd(4)
).join('')
).join('\n')
console.log(result)
/*
@v1vendi
v1vendi / case-insensitive-obj.js
Created February 13, 2020 12:09
Object wrapper for getting fields case-insensitively
const model = {
normalKey: 1,
coRRupTkey: 2,
innErKey: {
x: 3,
Y: 4
},
aRR: [
{ first: 5 }
]
@v1vendi
v1vendi / MySubsystem.h
Created September 16, 2022 13:00
Unreal Engine Subsystem with separate logic and configurable blueprints in settings
#pragma once
#include "Subsystems/LocalPlayerSubsystem.h"
#include "Engine/DeveloperSettings.h"
#include "MySubsystem.generated.h"
class ULocalPlayer;
UCLASS(Config=Game, defaultconfig)
@v1vendi
v1vendi / GameLiftGameModeExample.cpp
Created September 27, 2022 14:15
GameLiftGameServer plugin documentation
// Copyright Illia Komsa 2022. All rights reserved.
#include "GameFramework/GameModeBase.h"
#include "GameFramework/PlayerState.h"
#include "Kismet/GameplayStatics.h"
#include "GameLiftGameModeExample.generated.h"
/**
* An example PlayerSession class, that adds property to store PlayerSessionId
*/
UCLASS(Abstract)