const arrayValues = ["blue", 1, "red", 4, "yellow", 2, "green", 7]
const arrayObjects = []
for (let i = 0; i < arrayValues.length; i += 2) {
const newObject = {}
const key = arrayValues[i]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local MyClass = {} | |
MyClass.__index = MyClass | |
setmetatable(MyClass, { | |
__call = function (cls, ...) | |
return cls.new(...) | |
end, | |
}) | |
function MyClass.new(init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Override<Original, Override> = Pick< | |
Original, | |
Exclude<keyof Original, keyof Override> | |
> & | |
Override; | |
type PartialEntity<T, K = Entity<T>> = Override<T, Partial<K>>; | |
abstract class Entity<EntityType> { | |
public readonly id: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomDate(start: Date, end: Date) { | |
return new Date( | |
start.getTime() + Math.random() * (end.getTime() - start.getTime()) | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shuffle(array, amount = undefined) { | |
var m = array.length, t, i; | |
// While there remain elements to shuffle… | |
while (m) { | |
// Pick a remaining element… | |
i = Math.floor(Math.random() * m--); | |
// And swap it with the current element. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Or use the command for create and write in file | |
cat >/etc/wsl.conf <<EOL | |
# Enable extra metadata options by default | |
[automount] | |
enabled = true | |
root = ~/ | |
options = "metadata,umask=22,fmask=11" | |
mountFsTab = false | |
# Enable DNS – even though these are turned on by default, we'll specify here just to be explicit. |
Move commit "on top"
# main: A--B--X--Y
# feature: A--B--$--C--D
# new feature: A--B--C--D--$
# example to use command:
# git rebase -i {commitHash}~{moveToPosition}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* @param a int {Amount to be divided} | |
* @param b int {Number of times the @ param1 value will be divided} | |
*/ | |
function recursive_division (a, b){ | |
if (b == 0) | |
throw new Error('Cannot divide by zero') | |
else if (a < b) | |
return [0, a] | |
else |