Skip to content

Instantly share code, notes, and snippets.

View elcodabra's full-sized avatar
🎯
Focusing

Aleksandr Konovalov elcodabra

🎯
Focusing
View GitHub Profile

The article humorously explores the concept of compressing any file to 32 bytes using a hypothetical algorithm that essentially hashes the file content with SHA-256 and appends it with metadata, producing a fixed-size output. It plays on theoretical impossibilities in data compression, suggesting an absurdly efficient method that, while mathematically sound, is impractical for actual data retrieval, especially highlighting the impracticability of decompressing data in a reasonable timeframe. The article concludes with a tongue-in-cheek assessment of its "efficiency," hinting at its publication date's significance (April 1st), suggesting the entire piece is an elaborate April Fools' joke.

For more detailed insights, you can read the full article on Habr.

@elcodabra
elcodabra / events.spec.ts
Created January 31, 2022 12:38
Reactor Extended
import Reactor from './events'
describe('Reactor: Events Management System', () => {
const eventName = 'onError'
const reactor = new (Reactor as any)()
it(`registers window.${eventName} with callbacks`, () => {
// reactor.registerEvent(eventName)
const callback1 = jest.fn(() => console.log('callback 1'))
const callback2 = jest.fn(() => console.log('callback 2'))
@elcodabra
elcodabra / README.md
Created April 23, 2021 11:19 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@elcodabra
elcodabra / PeriodTypeKeyboard.jsx
Created June 18, 2020 13:20
Custom MUI KeyboardDatePicker with suggestions
import React, { useEffect, useRef, useState } from 'react'
import moment from 'moment'
import InputAdornment from '@material-ui/core/InputAdornment'
import FormControl from '@material-ui/core/FormControl'
import TextField from '@material-ui/core/TextField'
import MenuItem from '@material-ui/core/MenuItem'
import Select from '@material-ui/core/Select'
import Paper from '@material-ui/core/Paper'
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
@elcodabra
elcodabra / [...slug].js
Created June 15, 2020 10:45
Next JS 9: Proxy middleware with api and next-connect
// [...slug].js
import nc from 'next-connect'
const dev = process.env.NODE_ENV !== 'production'
const handler = nc()
if (dev) {
const { createProxyMiddleware } = require('http-proxy-middleware')
handler.use(createProxyMiddleware({
@elcodabra
elcodabra / local-server.js
Last active June 22, 2020 06:19
Next JS 9: Proxy middleware with Express
// local-server.js
const express = require('express');
const next = require('next');
const { createProxyMiddleware } = require('http-proxy-middleware');
const conf = require('./next.config');
const dev = process.env.NODE_ENV !== 'production';
const port = parseInt(process.env.PORT, 10) || 3000;
@elcodabra
elcodabra / utils__tests__objects.js
Created May 25, 2020 11:00
Function clearObject
import { clearObject } from 'utils_objects'
describe('clearObject()', () => {
test('clearObject({ x: 1, y: 2, z: 0, r: null }) should return { x: 1, y: 2, z: 0 }', () => {
expect(clearObject({ x: 1, y: 2, z: 0, r: null })).toEqual({ x: 1, y: 2, z: 0 })
})
test('clearObject({ reciever: { id: 1, comment: null } }) should return { reciever: { id: 1 } }', () => {
expect(clearObject({ reciever: { id: 1, comment: null } })).toEqual({ reciever: { id: 1 } })
export default class Animal {
constructor(name) {
this.name = name
}
getName() {
return this.name
}
}
@elcodabra
elcodabra / app.component.html
Created September 20, 2017 12:51
@angular/router
<div class="container">
<div class="starter-template">
<!-- ... -->
<router-outlet></router-outlet>
</div>
</div>
@elcodabra
elcodabra / app.jsx
Created September 20, 2017 12:46
React Router v4
// ...
import Routes from './routes';
const App = () => {
return (
<div className="container">
<div className="starter-template">
{/* ... */}
<Routes />
</div>