Skip to content

Instantly share code, notes, and snippets.

View Youka's full-sized avatar

Youka Youka

  • Germany
  • 01:46 (UTC +02:00)
View GitHub Profile
@Youka
Youka / windows_nanosleep.c
Created November 22, 2014 13:44
Windows nanosleep
#include <windows.h> /* WinAPI */
/* Windows sleep in 100ns units */
BOOLEAN nanosleep(LONGLONG ns){
/* Declarations */
HANDLE timer; /* Timer handle */
LARGE_INTEGER li; /* Time defintion */
/* Create timer */
if(!(timer = CreateWaitableTimer(NULL, TRUE, NULL)))
return FALSE;
@Youka
Youka / lua_myobject.cpp
Last active December 4, 2023 18:41
Example of Lua in C++ and userdata objects
// Lua C API
#include <lua.hpp>
// C++ input/output streams
#include <iostream>
// MyObject as C++ class
class MyObject{
private:
double x;
public:
@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 / mem2func.lua
Last active January 30, 2023 07:33
Run machine code with LuaJIT (Windows x86)
-- Load foreign-function-interface handle
local ffi = require("ffi")
-- Shortcut FFI C namespace
local C = ffi.C
-- Load Windows kernel32 DLL
local kernel32 = ffi.load("kernel32")
-- Add C definitions to FFI for usage descriptions of components
ffi.cdef([[
// Redefinitions for WinAPI conventions
typedef void VOID;
@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 / color_picker.lua
Last active July 15, 2022 03:36
Picking colors at mouse position with LuaJIT
-- Load FFI
local ffi = require("ffi")
-- Define FFI functions & structures by OS
local x11
if ffi.os == "Windows" then
ffi.cdef([[
typedef int BOOL;
typedef long LONG;
typedef struct{
@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 / 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;