Skip to content

Instantly share code, notes, and snippets.

View 73nko's full-sized avatar
💭
👨‍💻

73NKo 73nko

💭
👨‍💻
View GitHub Profile
const reEscapeChar = /\\(\\)?/g;
const rePropName = RegExp(
// Match anything that isn't a dot or bracket.
'[^.[\\]]+' +
'|' +
// Or match strings (supports escaping characters).
'(["\'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2',
'g'
);
@73nko
73nko / example.js
Last active December 26, 2021 09:48
const array = [1, 2, 3, 4, 5];
function copyAndMultiplyBy2(array) {
var newArray = [];
for (var i = 0; i < array.length; i++) {
newArray.push(array[i] * 2);
}
return newArray;
}
@73nko
73nko / read-lines.rs
Created November 28, 2021 11:04
Read Lines in a File Rust
let mut items: Vec<usize> = include_str!("../input.txt")
.lines()
.map(|i| i.parse().unwrap())
.collect();
// Or
fn read_ints(path: &str) -> Vec<i32> {
let mut out: Vec<i32> = Vec::new();
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@73nko
73nko / starship.toml
Created October 4, 2020 18:20
Starship toml configuration
[battery]
full_symbol = "🔋"
charging_symbol = "⚡️"
discharging_symbol = "💀"
[[battery.display]]
threshold = 10
style = "bold red"
[username]
@73nko
73nko / gist:ad0e27d3b691c2c44304e5460f385f63
Created August 9, 2020 13:56 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@73nko
73nko / reac-eternal-list.js
Created July 12, 2020 12:58
This package can render infinite list items without memory issues as it is using binary tree algorithm to remove and display elements while scrolling. check the demo and see how it works!
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import styles from './styles.css'
let containerRef= React.createRef();
let dummyELRef= React.createRef();
export default class ReactEternalList extends Component {
static propTypes = {
list: PropTypes.array,
@73nko
73nko / remove_nodemodules.js
Created July 11, 2020 16:45
Remove all node_modules in your computer
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
/**
* @param {number} maxNumber
* @return {number[]}
*/
export default function sieveOfEratosthenes(
maxNumber
) {
const isPrime = new Array(maxNumber + 1)
.fill(true);
isPrime[0] = false;
function getHighestZ() {
let highestZ = 0;
const elements = document.querySelectorAll('*');
elements.forEach(element => {
const style = getComputedStyle(element);
const zIndex = (style.zIndex) ? parseInt(style.zIndex) : 0;
if (zIndex > highestZ) {
highestZ = zIndex;