Skip to content

Instantly share code, notes, and snippets.

@ilyaigpetrov
ilyaigpetrov / pure-css-bootstrap-modal.html
Last active August 11, 2023 12:43
Pure CSS Bootstap Modal, requires only bootstap.css, no JavaScript.
<label for="modal-switch" class="btn btn-default btn-primary" role="button" data-toggle="modal" data-target="#myModal">Launch demo modal</label>
<!-- Modal -->
<div class="pure-css-bootstrap-modal">
<style>
.pure-css-bootstrap-modal {
position: absolute; /* Don't take any space. */
}
.pure-css-bootstrap-modal label.close {
/* Reset */
padding: 0;

Comparison of ASP.NET and Node.js for Backend Programming

We will compare ASP.NET and Node.js for backend programming.
Source codes from examples.

Updates

This document was published on 21.09.2015 for a freelance employer. Some changes since then (14.02.2016):

  1. Koa.js no longer uses co-routines, it has switched to Babel's async/await. yield and await are used almost in the same way, so I see no point to rewrite the examples.
@ilyaigpetrov
ilyaigpetrov / retrieve-.pyc-grammar-from-marshal.c.md
Last active January 26, 2020 14:58
Retrieve .pyc Grammar from Python's Sources | by https://git.io/ilyaigpetrov

Retrieve .pyc Grammar from Python's Sources

About my endeavor to automatically retrieve grammar of CPython .pyc-files bytecode from Python's sources itself (success) and build parser on them (failed).
Most recent version of this article is always on GitHub

The problem story

In 2011 as part of my diploma thesis I came up with an assembler language for .pyc files and wrote a simple proof-of-concept assembler for it based on ANTLR3 parser generator. Back then I stumble upon the issue that CPython bytecode is somewhat not stable and differs from version to version. I.e., as of Python from 3.0 to 3.4 there are 28 incompatible bytecode versions (you may find all bytecode versions with their descriptions in Python34/Lib/importlib/_bootstrap.py).

So, if we aim to devise an assembler or disassembler not for one bytecode version but for many, we face a routine of retrieving out these bytecode differences. This task strikingly

Comparison of Java and C for Graph Traversal Implementation

We will consider C and Java implementations for DFS and BFS graph traversal algorithms (4 programs) and compare their source codes and binaries to figure languages shortcomings and fortes in application to the given task.

Published around 22.09.2015 as a test task for a freelance employer.
Source codes

BFS and DFS Algorithms in Psuedo Code

dfs(from vertex v)
@ilyaigpetrov
ilyaigpetrov / client-server-data-sync.markdown
Last active January 26, 2020 14:58
Client/Server Data Synchronization Solutions | by https://git.io/ilyaigpetrov

Client/Server Data Synchronization

Open Source

  • Redis
    In-memory db with notifications, may be used alongside other DB.
  • Meteor
    • MongoDB | Livequery | server DDP | DDP client | minimongo
    • Livequery for DB updates subscriptions (MongoDB)
    • Minimongo is MongoDB imitation, used for latency compenstion.
  • Opinionated, heavy, not very modular.

Meteor Alternatives Per Feature

This table was created in 2015 so may be quite outdated today.

Feature Meteor Solution Alternative Solutions Description
Live DB Sync [livequery][lq] ([mongo-oplog]), [ddp] RethinkDB, Redis, ShareDB, [npm:mongo-oplog], [firebase], etc. Push DB updates to client/server.
Latency Compensation, Optimistic UI [minimongo][mm] [RethinkDB][lcr], [mWater/minimongo] (fork, not ws but http, browserify) Imitate successful db query on client before it is done.
Isomorphic Code [isobuild] & isopacks browserify Write one code for server/client/mobile.
Isomorphic Packaging [isobuild], atmosphere No more separate packages for server & client. Get bower + npm + mobile.
@ilyaigpetrov
ilyaigpetrov / Аргументы против цензуры.md
Last active January 26, 2020 14:57
Аргументы против цензуры | by https://git.io/ilyaigpetrov

Tuning Windows 10 for Slow Machines

Windows 10 on slow netbook

This guide is for those who dares to install Windows 10 on slow netbooks (1GB of RAM).
Though Windows update program is over, you still may use old Windows product keys from license stickers to install Windows 10 on old machines.

UPD Jan 2019
This article is quite old, some instructions may be obsolete.

$ time node --expose-gc --trace-gc --trace-gc-verbose for-nodejs.js 13231
[1776:0x3153a50] Heap growing factor 4.0 based on mu=0.970, speed_ratio=-nan (gc=0, mutator=0)
[1776:0x3153a50] Grow: old size: 3897 KB, new limit: 16598 KB (4.0)
[1776:0x3153a50] 145 ms: Mark-sweep 4.7 (10.8) -> 4.3 (11.8) MB, 11.6 / 0.0 ms Isolate::RequestGarbageCollection GC in old space requested
[1776:0x3153a50] Memory allocator, used: 12068 KB, available: 1454300 KB
[1776:0x3153a50] New space, used: 534 KB, available: 473 KB, committed: 2048 KB
[1776:0x3153a50] Old space, used: 1219 KB, available: 0 KB, committed: 1944 KB
[1776:0x3153a50] Code space, used: 738 KB, available: 0 KB, committed: 2048 KB
[1776:0x3153a50] Map space, used: 131 KB, available: 0 KB, committed: 1108 KB
[1776:0x3153a50] Large object space, used: 1807 KB, available: 1453259 KB, committed: 1848 KB