Skip to content

Instantly share code, notes, and snippets.

View DimaCrafter's full-sized avatar
🌱
Low-Level Factory Adventures

Dmitriy Shiryaev DimaCrafter

🌱
Low-Level Factory Adventures
View GitHub Profile

A metatable can be defined like

local t = setmetatable({}, {
  __tostring = function() return 'custom tostring behavior!' end
})

Here are the metamethods that you can define, and their behavior

Operators

"start
set number "set relativenumber
nmap <c-x> :wq<CR>
imap <c-x> <Esc>:wq<CR>a
set whichwrap+=<,>,h,l,[,]
syntax on
map <C-n> :NERDTreeToggle<CR>
"
@dmitrythaler
dmitrythaler / JSON.replacer.js
Created March 27, 2017 12:49
replacer function for the JSON.stringify() with depth and duplicates control
const replacer = function( depth = Number.MAX_SAFE_INTEGER ) {
let objects, stack, keys;
return function(key, value) {
// very first iteration
if (key === '') {
keys = ['root'];
objects = [{keys: 'root', value: value}];
stack = [];
return value;
}
@Senorsen
Senorsen / csr-caps-lock-osd-mute.reg
Last active June 16, 2024 05:24
CSR Bluetooth 'Caps Lock' OSD notification mute
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Cambridge Silicon Radio\Harmony\Default]
"OSD"=dword:00000000
@umidjons
umidjons / aes-256-cbc-nodejs-crypto.md
Last active March 13, 2022 07:12
AES-256-CBC example in Node.js using crypto module

AES-256-CBC example in Node.js using crypto module

'use strict';
const crypto = require('crypto');

// get password's md5 hash
let password = 'test';
let password_hash = crypto.createHash('md5').update(password, 'utf-8').digest('hex').toUpperCase();
console.log('key=', password_hash); // 098F6BCD4621D373CADE4E832627B4F6
@darsain
darsain / svg_sprites.md
Last active April 10, 2024 11:15
How to use SVG sprites in img[src] and css backgrounds

To make this work in CSS:

background: url('images.svg#chart');

or img:

<img src="images.svg#chart">
@gre
gre / easing.js
Last active June 27, 2024 15:37
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@betawax
betawax / gist:1063274
Created July 4, 2011 12:13
Recursively remove Mac OS X tar "dot underscore" files
find . -name '._*' -exec rm -f {} \;