Skip to content

Instantly share code, notes, and snippets.

View Youka's full-sized avatar

Youka Youka

  • Germany
  • 09:56 (UTC +02:00)
View GitHub Profile
@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);
@Youka
Youka / deque.ts
Created July 15, 2018 11:24
Double-ended queue (typescript)
// Linked data structure part
interface Node<T> {
previous: Node<T>,
value: T,
next: Node<T>
}
// Double-ended queue structure
class Deque<T> {
private first: Node<T> = null;
private last: Node<T> = null;
@Youka
Youka / scrollbarTop.js
Created December 12, 2017 10:38
Move scrollbar from default bottom to top
function createTopScrollbar(frame) {
// Target even scrollable?
var scrollWidth = frame.get(0).scrollWidth;
if(scrollWidth > frame.width())
// Add new top scrollbar and hide default (/bottom) scrollbar
frame.before(
jQuery('<div />', {
css: {'overflow-x': 'scroll'},
height: getScrollbarSize()
})