Skip to content

Instantly share code, notes, and snippets.

View Youka's full-sized avatar

Youka Youka

  • Germany
  • 22:52 (UTC +02:00)
View GitHub Profile
@Youka
Youka / create_users_table.sql
Created December 27, 2024 20:02
Simple postgres script to create a users table
CREATE TABLE IF NOT EXISTS users (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name varchar(32) UNIQUE NOT NULL CHECK (length(name) >= 3),
avatar_file bytea STORAGE EXTERNAL CHECK (avatar_file IS NULL OR length(avatar_file) < 50000),
about_me varchar(2048),
date_time_creation timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'utc'),
date_time_last_login timestamp CHECK (date_time_last_login IS NULL OR date_time_last_login >= date_time_creation)
);
@Youka
Youka / self-signed-certificate.md
Created November 30, 2024 02:24
Description for self-signed-certificate creation & inspection.

Self signed certificate

Encrypted connections require a certificate + private key.
This little guide shows how to create & inspect those files.

Requirements

Encryption tool OpenSSL is all we need.

Creation

Run command:

@Youka
Youka / InfoCollapsePlugin.js
Created January 28, 2023 11:55
Swagger-UI plugin: InfoCollapsePlugin
const InfoCollapsePlugin = (system) => {
const React = system.React;
return {
wrapComponents: {
info: (Original) => (props) => React.createElement(
"details",
{
open: true
},
React.createElement(
@Youka
Youka / index.js
Last active November 30, 2021 19:44
Websocket echo server
new (require('ws').Server)({port:8080}).on('connection',sock=>sock.on('message',data=>sock.send(String(data))))
@Youka
Youka / ocl_test.rs
Last active February 23, 2021 22:57
Rust OCL crate usage example
#[cfg(feature = "gpgpu")]
mod gpgpu {
// Imports
use ocl::{
Platform,
Device,
enums::{
PlatformInfo,
DeviceInfo
},
@Youka
Youka / install_lr7_env.sh
Created December 31, 2020 20:09
Liferay 7 RHEL development server installation
#! /bin/bash
# HELPERS
# Variables
pkg_install="yum -y install"
pkg_installed="yum list installed"
pkg_clean="yum clean all"
pkg_update="yum -y update"
service_enable="systemctl enable"
service_start="systemctl start"
@Youka
Youka / map.rs
Created December 30, 2019 18:46
Map `get_key_value` implementation before Rust v1.40.0
// On stable: <https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.get_key_value>
pub fn get_key_value<'a,K,V,Q: ?Sized>(map: &'a HashMap<K,V>, k: &Q) -> Option<(&'a K, &'a V)>
where K: std::borrow::Borrow<Q> + std::hash::Hash + std::cmp::Eq,
Q: std::hash::Hash + Eq {
let key = map.keys().find(|key| key.borrow() == k)?;
Some((key, map.get(key.borrow())?))
}
@Youka
Youka / config.rs
Created March 18, 2019 00:39
Rust OpenGL Backup - Given up because of slow download speed
use std::env;
fn main() {
// Multisampling not supported on CI machine, else 8 samples are absolutely enough
println!("cargo:rustc-env=SAMPLES={}", if env::var("TRAVIS_RUST_VERSION").is_ok() {1} else {8});
}
@Youka
Youka / sysinfo.bat
Last active December 4, 2023 03:22
Simple batch file for system information on windows
@echo off
rem Resize window for following masses of content
mode 200,50
rem Get CPU information
echo # CPU
wmic CPU GET AddressWidth,CurrentClockSpeed,CurrentVoltage,L2CacheSize,L3CacheSize,LoadPercentage,Manufacturer,Name,NumberOfCores,NumberOfLogicalProcessors
echo.
rem Get graphics card information
@Youka
Youka / hex2RGBA.ts
Last active October 1, 2019 06:43
Color as hexadecimal string to RGBA array
function hex2RGBA(hex: string) {
if(hex !== null && hex.charAt(0) === '#') {
const pattern = /[0-9a-f]{1,2}/ig,
rgba = [0, 0, 0, 255];
for(
let i = 0, match;
i < 4 && (match = pattern.exec(hex)) !== null;
i++
)
rgba[i] = parseInt(match.toString(), 16);