Skip to content

Instantly share code, notes, and snippets.

View niksaak's full-sized avatar
⛑️
I CAN'T REPAIR THIS M3 TACTICAL HELMET, SIR

Mikola Samardak niksaak

⛑️
I CAN'T REPAIR THIS M3 TACTICAL HELMET, SIR
View GitHub Profile
set nocompatible
set background=dark
set encoding=utf-8
scriptencoding utf-8
call plug#begin('~/.vim/plugged')
Plug 'mileszs/ack.vim'
Plug 'sjl/badwolf'
Plug 'vim-scripts/camelcasemotion'
Plug 'ctrlpvim/ctrlp.vim'
@niksaak
niksaak / README.txt
Created September 13, 2021 12:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=true&runs=200&gist=
REMIX EXAMPLE PROJECT
Remix example project is present when Remix loads very first time or there are no files existing in the File Explorer.
It contains 3 directories:
1. 'contracts': Holds three contracts with different complexity level, denoted with number prefix in file name.
2. 'scripts': Holds two scripts to deploy a contract. It is explained below.
3. 'tests': Contains one test file for 'Ballot' contract with unit tests in Solidity.
SCRIPTS
@niksaak
niksaak / hecs_particles.rs
Last active December 11, 2020 09:50
Comparison of using different ECS frameworks for implementing non-trivial but simple logic. Legion version courtesy of @lain-dono .
#[derive(Default)]
pub struct ParticleSystem {
to_spawn: Vec<(Particle, Transform, LocalToWorld, Velocity, Render, Flags)>,
to_despawn: Vec<Entity>,
}
impl ParticleSystem {
pub fn run(&mut self, world: &mut World, resources: &mut Resources) {
let dt = resources.frame_time;
pub fn encode(data: &[u8]) -> Vec<u8> {
Encoder::new(data).encode()
}
pub fn decode(data: &[u8]) -> Vec<u8> {
Decoder::new(data).decode()
}
const ILLEGALS: [u8; 6] = [0, 10, 13, 34, 38, 92];
const SHORT_MARK: u8 = 0b111;
@niksaak
niksaak / playground.rs
Created December 12, 2017 10:32 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::str;
fn main() {
let b = "67e5504410b1426f9247bb680e5fe0c8";
let mut bytes = [0u8; 16];
for (dest, chunk) in bytes.iter_mut().zip(b.as_bytes().chunks(2)) {
let s = match str::from_utf8(chunk) {
Ok(v) => v,
Err(e) => panic!("Invalid UTF-8 sequence: {}", e),
set nocompatible
set background=dark
call plug#begin('~/.vim/plugged')
Plug 'mileszs/ack.vim'
Plug 'sjl/badwolf'
Plug 'vim-scripts/camelcasemotion'
Plug 'JazzCore/ctrlp-cmatcher'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'beyondmarc/hlsl.vim'
eNqzf37MYCa3sbH990P9BgwMDPYfGMDA/pKV3jHJmTPtz29fvePmzBn2D21WSR0NDbV/cb4+a29omAOrU3HF9PJy+ze1W6fzvXtvv3MmCMyyv+FzYYICUP8x7prVE4/42L+20uLfKChof6b4xcz7sRr2hwU+FYuXV9h/M8ht3b17N9AqRvsPMqFRK9fssX96zcL77917/4HA/oMqe7Hc7J32N6ZPbHZxcQGqY7Z/tuRtrKGan/2tmE86WatWg935YfqqvsWZM+y/djn3nejoBOl14O89yVMyKdj+6acjQRkdXUBlLA6Sir9DXHQl7A+WiS6qy5wDFGN1EHp3wfrHhk32F7r06zcbGwPF2BwkVm0Lt3iqbf90bmSLMFDsyjtWhlv/hBhkDSsYJq3yZvg+SYZBeckEhqgFDxk05FgZMhacZ8jyrGAoD9Fj+PVNiGFauCiDVstzhtN5fxnerd8OsgcAyxWXLA==
@niksaak
niksaak / rust-safety-dance.rs
Created February 6, 2017 22:49
Well, it's the safety dance.
unsafe fn as_undead<'a, T>(t: &T) -> &'static T {
// I say, we can dance, we can dance
// Everybody look at your hands
&*(t as *const T)
}
unsafe fn as_undead_mut<'a, T>(t: &'mut T) -> &'static mut T {
// We can dance, we can dance
// Everybody's taking the chance
&mut *(t as *mut T)
impl Core {
fn pull_fresh(&self) -> Option<Fiber> {
self.scheduler.consume_fresh()
}
fn pull_waiting(&self) -> Result<Fiber, WakeError> {
self.scheduler.wake_fiber()
}
fn work(&self) {
function! s:get_visual_selection()
" Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][col1 - 1:]
return join(lines, "\n")
endfunction