Skip to content

Instantly share code, notes, and snippets.

View nilz3ro's full-sized avatar
🧃

nil nilz3ro

🧃
View GitHub Profile
@nilz3ro
nilz3ro / sublist.rs
Created January 21, 2022 21:45
Trait example
#[derive(Debug, PartialEq)]
pub enum Comparison {
Equal,
Sublist,
Superlist,
Unequal,
}
trait IncludedIn {
fn included_in(&self, rhs: Self) -> bool;
@nilz3ro
nilz3ro / ownership.md
Last active April 30, 2021 17:26
Rust's Ownership principles.

Rust's Ownership Principles

Ownership

Ownership is is a core concept in Rust and it provides a way for Rust and its programmers to deal with memory management and reference validation. Each value in Rust has an Owner which is basically the scope that the value belongs to. This could be a function or block scope or a struct etc.

Move

When you pass a value to a function (and in other scenarios that I will skip over for brevity)

Keybase proof

I hereby claim:

  • I am nilz3ro on github.
  • I am nilz3ro (https://keybase.io/nilz3ro) on keybase.
  • I have a public key ASDkhNqKgtaGgI5RxhmNLg9QPj5RxJPPObkfsxPUXBP7ywo

To claim this, I am signing this object:

@nilz3ro
nilz3ro / darken-by-percentage.js
Last active November 8, 2017 16:52
Darken Hex Colors by percentage as a JS one-liner 😎
import { chunk } from 'lodash';
const darkenByPercentage = (hexString, percent) =>
chunk(hexString.substr(1).split(''), 2)
.reduce((memo, pair) => [...memo, `0x${pair.join('')}`], '')
.map(Number)
.map(digit => digit - Math.ceil(digit * (percent / 100)))
.reduce((memo, digit) => `${memo}${digit.toString(16)}`, '#');
// darkenByPercentage('#ffffff', 20);

Keybase proof

I hereby claim:

  • I am nilz3ro on github.
  • I am nilz3ro (https://keybase.io/nilz3ro) on keybase.
  • I have a public key ASCVf434N2WZYWMe6-LVI79LBo6zu5LjyajFOnuSYiwLdAo

To claim this, I am signing this object:

@nilz3ro
nilz3ro / init.vim
Last active August 21, 2017 15:05
(n)Vim Configuration
call plug#begin()
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-sensible'
Plug 'scrooloose/nerdtree'
call plug#end()
@nilz3ro
nilz3ro / string-reverse.js
Created February 15, 2017 15:27
Recursion Example
// One liner.
const reverseIt = (string, memo='') => string.length ? reverseIt(string.substr(1), string.substr(0,1) + memo) : memo
// same as:
function reverseIt2 (string, memo='') {
if (string.length) {
return reverseIt2(string.substr(1), string.substr(0,1) + memo);
} else {
return memo;
@nilz3ro
nilz3ro / map.purs
Created November 22, 2016 17:51
PureScript's Infix Operator Aliases are aaaaawwwwweeeeessssooooooooommmmmmeeeeeeee.
(\n -> n * n) <$> [1, 2, 3, 4, 5]
@nilz3ro
nilz3ro / guard.md
Last active November 21, 2016 16:34
Intro to guard clauses.

Guard Clause

What is it?

A guard clause is a line of code that prevents the following block of code from running unless a certain condition is met.

Why use guard clauses?

Guard clauses are preferrable to nested conditionals because they are faster and simpler than nesting conditional statements.

@nilz3ro
nilz3ro / agile.md
Created October 10, 2016 16:56
Agile / Scrum As presented as Roger H.

Agile (As presented by Roger H.)

We should always be delivering The Thing that has the most Business Value.

Terms

Agile

The ability to create and respond to change in order to succeed in an uncertain and turbulent environment.

Scrum