Skip to content

Instantly share code, notes, and snippets.

View ghaiklor's full-sized avatar

Eugene Obrezkov ghaiklor

View GitHub Profile
@ghaiklor
ghaiklor / Module_compile.js
Created February 3, 2017 16:33
Module.prototype._compile() sources
// Run the file contents in the correct scope or sandbox. Expose
// the correct helper variables (require, module, exports) to
// the file.
// Returns exception, if any.
Module.prototype._compile = function(content, filename) {
// Remove shebang
var contLen = content.length;
if (contLen >= 2) {
if (content.charCodeAt(0) === 35/*#*/ &&
content.charCodeAt(1) === 33/*!*/) {
@ghaiklor
ghaiklor / build.sh
Last active December 20, 2022 05:51
Script for getting all the sources and building second stage boot loader
# Install pre-requisites
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y build-essential
sudo apt-get install -y nasm
sudo apt-get install -y qemu
# Download the sources
curl https://gist.githubusercontent.com/ghaiklor/3ef5a07b3de1beb964555183dee18621/raw/59cb9ba42fd71631b0bc0c55e2a27c38f0e8ffaf/boot.asm > boot.asm
curl https://gist.githubusercontent.com/ghaiklor/d63e5183773770e07854b5d799ef3a44/raw/fcdc0652fa1c39c5e76379e1bd58ac49922feeeb/loader.asm > loader.asm
@ghaiklor
ghaiklor / boot.asm
Created October 30, 2017 17:30
Full implementation of boot.asm
[org 0x7C00]
[bits 16]
KERNEL_OFFSET equ 0x1000
mov [BOOT_DRIVE], dl
call load_boot
call execute_boot
load_boot:
@ghaiklor
ghaiklor / iterm-fish-fisherman-meslo-osx.md
Last active December 5, 2022 11:14
iTerm 2 + fish + fisherman + Material Design + Meslo
@ghaiklor
ghaiklor / sw-multiplex.js
Created September 29, 2016 13:37
Multiplexing downloads via Service Workers
/**
* Size of one chunk when requesting with Range
* @type {Number}
* @private
*/
const CHUNK_SIZE = 204800;
/**
* Concat two ArrayBuffers
* @param {ArrayBuffer} ab1
@ghaiklor
ghaiklor / tsconfig.json
Created February 26, 2021 11:19
TypeScript Strict Configuration
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowUnreachableCode": false,
"alwaysStrict": true,
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
@ghaiklor
ghaiklor / v8-compile-javascript-example.cc
Last active February 1, 2022 13:25
Simple example how V8 can compile JavaScript source and run it
// Create a new context.
Local<Context> context = Context::New(isolate);
// Enter the context for compiling and running the hello world script.
Context::Scope context_scope(context);
// Create a string containing the JavaScript source code.
Local<String> source = String::NewFromUtf8(isolate, "'Hello' + ', World!'");
// Compile the source code.
@ghaiklor
ghaiklor / .eslintrc.js
Created February 26, 2021 12:15
ESLint Strict Configuration
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": [
"eslint:all",
"plugin:@typescript-eslint/all",
@ghaiklor
ghaiklor / node-event-loop-demo.js
Created March 25, 2016 18:44
This example shows how you can block event loop in NodeJS
'use strict';
// The purpose of this example is to show
// how you can block the event loop with JavaScript.
// There is 3 routes
// / respond with Hello, World text
// /block uses JavaScript while for 5 seconds
// /non-block uses setTimeout for 5 seconds
// Do the following