Skip to content

Instantly share code, notes, and snippets.

@Nachasic
Nachasic / init.vim
Created Aug 5, 2020
Neovim configuratiob
View init.vim
call plug#begin(stdpath('data') . './plugged')
" Plugin Section
Plug 'dracula/vim'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'preservim/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', {'dir': '~/.fzf','do': './install --all'}
Plug 'junegunn/fzf.vim' " needed for previews
@Nachasic
Nachasic / tough.kt
Created Apr 14, 2020
Zhavoronok tough problems
View tough.kt
fun <T> assert (exerciseName: String, fnResult: T, expectedResult: T) {
if (fnResult == expectedResult) {
println(exerciseName + "| checks out, GOOD JOB\n\n");
} else {
println(exerciseName + "| something's wrong: result \n (" + fnResult + ") is not equal to expected result \n (" + expectedResult + ")\n\n" )
};
};
/** Problem #1 - List Basics
* 1) Function is provided with a list of numbers;
@Nachasic
Nachasic / macro.rs
Created Jan 24, 2020
Color macro for raylib in Rust
View macro.rs
use raylib::prelude::*;
#[allow(unused_macros)]
macro_rules! color {
(# $color_hex:expr) => {{
let color = i32::from_str_radix(stringify!($color_hex), 16).unwrap();
let b = color % 0x100;
let g = (color - b) / 0x100 % 0x100;
let r = (color - g) / 0x10000;
@Nachasic
Nachasic / frac.spec.ts
Created Jul 18, 2019
Alternative to `Math.frac()` in Javascript
View frac.spec.ts
// testing using Jest
import { frac } from './frac';
describe('Math frac tests', () => {
it('should be defined', () => {
expect(frac).toBeDefined();
});
it('should accurately calculate fraction of a number', () => {
expect( frac(-3.1234) ).toEqual( -0.1234 );
@Nachasic
Nachasic / generics.ts
Last active Feb 10, 2019
Exemplary explanation of interfaces and generics
View generics.ts
interface BarkAndWiggle {
bark: () => void;
wiggle: () => void;
};
class Pitbull implements BarkAndWiggle {
public bark() {
console.log('bark');
}
@Nachasic
Nachasic / Decorator.tsx
Created Oct 19, 2018
DraftJS — get decorator's own selection range
View Decorator.tsx
/**
* This is a workaround for the following issue:
* https://github.com/facebook/draft-js/issues/1394
**/
type DecoratorProps = {
// draft-js provides decorators with detoratedText property
decoratedText: string;
}
@Nachasic
Nachasic / react-serialize.spec.tsx
Last active May 14, 2022
Serialize react to JSON and de-serialize it back with TypeScript
View react-serialize.spec.tsx
import * as React from 'react';
import { mount } from 'enzyme';
import { serialize, deserialize } from './react-seritalize';
class CustomComponent extends React.Component<any, any> {
render () {
return <div className="CustomComponent" >{this.props.children}</div>
}
}
View EPISTLE-Spec.md

Hey

testGistEditor(‘How is it doing?)