Skip to content

Instantly share code, notes, and snippets.

View OleksiyRudenko's full-sized avatar
💻
Delivering

Oleksiy Rudenko OleksiyRudenko

💻
Delivering
View GitHub Profile

Images

Lazy loading

<img src="image.png" loading="lazy" alt="…" width="200" height="200">

Adaptive image set

<picture>
  <source media="(min-width:768px)" srcset="med_flag.jpg">
  <source media="(min-width:495px)" srcset="small_flower.jpg">
  <img src="high_flag.jpg" alt="Flags" style="width:auto;">
@OleksiyRudenko
OleksiyRudenko / install-py.md
Last active August 10, 2020 17:12
Python for JS dev
@OleksiyRudenko
OleksiyRudenko / latency.md
Last active July 6, 2020 13:44 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know

Latency Comparison Numbers (~2012)

L1 cache reference                           0.5 ns
Branch mispredict                            5   ns
L2 cache reference                           7   ns                      14x L1 cache
Mutex lock/unlock                           25   ns
Main memory reference                      100   ns                      20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy             3,000   ns        3 us
Send 1K bytes over 1 Gbps network       10,000   ns       10 us
/*
I came up with a single pass O(n) sort algorithm I call StalinSort.
You iterate down the list of elements checking if they're in order.
Any element which is out of order is eliminated.
At the end you have a sorted list.
© 2018-10-25, @[email protected]
*/
const stalinSortReduce = arr => arr.reduce((acc,v) => acc.length ? acc[acc.length-1] < v ? [...acc, v] : acc : [v], [])
@OleksiyRudenko
OleksiyRudenko / github-UI-tips-n-tricks.md
Last active December 11, 2021 13:29
GitHub tips and tricks

Fuzzy file finder

On any repo press t to start fuzzy file finder

Code snippet:

  • Open a file
  • Select a code line
  • SHIFT+LeftClick to select multiple
  • RightClick for context menu + Copy permalink or press y It renders nicely when in an issue comment
@OleksiyRudenko
OleksiyRudenko / count-entries-in-an-array.md
Last active November 3, 2020 11:13
Counting entries in an array

Classics:

Count number of each entry in an array. I.e. someFunc(['a', 'b', 5, 'a', 2, 5]) should result in

{
  2: 1,
  5: 2,
  'a': 2,
  'b': 1
@OleksiyRudenko
OleksiyRudenko / instructions.rst
Created January 5, 2020 13:31 — forked from Nachtalb/telegram-desktop-multiple-accounts.rst
Add multiple accounts in Telegram Desktop [Linux | MacOSX | Windows]

How to add multiple accounts to Telegram Desktop

Table of Contents

ATM of writing this, there is no way inside the Telegram Client to switch accounts (event though this feature exists in the offical mobile clients and there is a long running issue here: telegramdesktop/tdesktop#4261).

@OleksiyRudenko
OleksiyRudenko / why-newline.md
Last active October 7, 2025 15:29
Why should text files end with a newline?

Why should text files end with a newline?

Reasons:

  • UNIX standard
  • If the last line in a file doesn't end with a newline then addition of next line affects two lines instead of one. This also pollutes diff on multiple files, so reader may wonder what has changed in a line whereas no significant change has occured.

Multiple newlines at the file end are also redundant as well as spaces at the end of line.

WORK IN PROGRESS

Unintended submodule issue

One of the problems developers new to git may face is a mysterious sub-modules they didn't expect to have.

These are seen as a Submodule <pull request title> at <commit-hash> under Files changed tab in a pull request.

// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var domStyle = document.createElement("style");
domStyle.append(
'* { color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\
* * { background-color: rgba(0,255,0,.2) !important; }\
* * * { background-color: rgba(0,0,255,.2) !important; }\
* * * * { background-color: rgba(255,0,255,.2) !important; }\
* * * * * { background-color: rgba(0,255,255,.2) !important; }\