Skip to content

Instantly share code, notes, and snippets.

View qRoC's full-sized avatar
🇺🇦
Defending my home

Andrii Savytskyi qRoC

🇺🇦
Defending my home
View GitHub Profile
@qRoC
qRoC / lsp_on_init.lua
Last active February 10, 2023 08:27
semantic tokens nvim 0.9
-- https://github.com/neovim/neovim/pull/21100/files#diff-f11809d8946cebd21b6bec568546afe4589930ac9c6e89f49e7f398adc574c90R39
local function binary_search(tokens, line)
local lo = 1
local hi = #tokens
while lo < hi do
local mid = math.floor((lo + hi) / 2)
if tokens[mid].line < line then
lo = mid + 1
else
hi = mid
From 26641de736600618efbb99ee31c4ffec522433d2 Mon Sep 17 00:00:00 2001
From: Andrii Savytskyi <contact@qroc.pro>
Date: Wed, 2 Nov 2022 20:58:03 +0200
Subject: [PATCH] 20130
---
src/nvim/api/extmark.c | 4 ++++
src/nvim/decoration.h | 3 ++-
src/nvim/drawline.c | 48 +++++++++++++++++++++++++++++++++++++-----
src/nvim/plines.c | 27 ++++++++++++++++++++++--
@qRoC
qRoC / main.rs
Created April 27, 2021 22:22
Division By constants
// https://stackoverflow.com/questions/28003334/modulus-optimization-in-c
pub struct MU128 {
pub magic: u128,
pub do_add: bool,
pub shift: i32,
}
fn magic_u128(d: u128) -> MU128 {
debug_assert!(d > 1);
@qRoC
qRoC / Singleton.swift
Created July 8, 2020 17:38
Swift Singleton
#if canImport(Darwin)
import Darwin
#else
import Glibc
#endif
class Singleton {
static var shared: Singleton! = Singleton()
private init() {
@qRoC
qRoC / gist:d8bbc01f53ed4cdf0323969da45a6f71
Created April 25, 2020 15:18
ASRock X570 sensors linux
ASRock X570 has NCT6683D
According to the https://www.kernel.org/doc/Documentation/hwmon/nct6683.rst This driver is disabled by default on non-Intel platforms.
So:
$ sudo echo "options nct6683 force=1" >> /etc/modprobe.d/sensors.conf
$ sudo shutdown -r now
$ sudo modprobe nct6683
$ sudo echo "nct6683" >> /etc/modules-load.d/modules.conf
<?php
function test(): array {
return [
[1],
[1]
[0]
];
}
print_r(test());
@qRoC
qRoC / test.php
Created May 16, 2018 11:28
typehint parent bug PHP 7.2
<?php
interface ITest {
public function test(self $test): void;
}
class TestBase implements ITest {
// all ok
public function test(parent $test): void {
}
}
@qRoC
qRoC / test.php
Last active May 16, 2018 11:19
Generic PHP interface (version < 5.4.1)
<?php
/// Work in PHP < 5.4.1
interface ITest {
public function testSelf(self $test);
}
class Test implements ITest {
private $a = 10;
@qRoC
qRoC / Results
Last active January 25, 2018 21:00
Swift simd matrix init bench Raw
Build flags: --configuration release
swiftc: -Ounchecked -gnone -whole-module-optimization -static-stdlib
Time elapsed for inverse: 2.64717900753021 s.
Time elapsed for inverse2: 1.35483705997467 s.
Time elapsed for inverse3: 11.727156996727 s.
Time elapsed for inverse4: 1.38384604454041 s.
Time elapsed for inverse5: 11.8544869422913 s.
Time elapsed for inverse6: 1.38975405693054 s.
Time elapsed for inverse7: 1.37177407939121 s.
@qRoC
qRoC / ClampSupport.swift
Last active January 13, 2018 00:20
Swift clamp protocol
///
public protocol ClampSupport {
func clamped(from lowerBound: Self, to upperBound: Self) -> Self
func clamped(from lowerBound: Self) -> Self
func clamped(to lowerBound: Self) -> Self
}
public extension ClampSupport where Self: Comparable {