Skip to content

Instantly share code, notes, and snippets.

@VaskillerDev
VaskillerDev / quad_tree.rs
Created October 21, 2022 23:16
immutable quadtree implementation
use std::fmt::Debug;
use std::mem;
use crate::quad_tree::shape::{Point, Rectangle};
pub struct QuadTree<TValue: Debug> {
root: HeapQuadTreeNode<TValue>,
}
impl<TValue: Debug + Copy + Clone> QuadTree<TValue> {
pub fn new() -> Self {
@VaskillerDev
VaskillerDev / sql92_reserved_words.rs
Last active September 22, 2021 20:41
SQL-92 reserved words.rs
// Database Language SQL (SQL-92)
// A
pub const ABSOLUTE : &str = "ABSOLUTE";
pub const ACTION : &str = "ACTION";
pub const ADD : &str = "ADD";
pub const ALL : &str = "ALL";
pub const ALLOCATE : &str = "ALLOCATE";
pub const ALTER : &str = "ALTER";
pub const AND : &str = "AND";
@VaskillerDev
VaskillerDev / toFormUrlencodedParams.js
Created May 12, 2021 11:06
toFormUrlencodedParams(obj) on js
function toFormUrlencodedParams(obj) {
return Object.keys(obj)
.map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
}
export default toFormUrlencodedParams
@VaskillerDev
VaskillerDev / genRandomString.js
Created May 12, 2021 11:02
genRandomString(length) on js
function genRandomString (length) {
let text = ''
let possible =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
for (let i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length))
}
return text
}
@VaskillerDev
VaskillerDev / groupBy.ts
Last active April 28, 2021 12:56
groupBy(arr, func) on typescript
type FunctionTypeAsKey = number | string;
type ClusterFuncSignature<T> = (e: T) => FunctionTypeAsKey;
type Group<T> = {
[k in FunctionTypeAsKey] : Array<T>
}
function groupBy<T> (arr : Array<T>, func : ClusterFuncSignature<T>) {
const result = Object.create(null) as Group<T>;
arr.forEach(elem => {