Skip to content

Instantly share code, notes, and snippets.

@iamarkdev
iamarkdev / minecraft-mca-parser.js
Created September 16, 2021 06:55
A node.js implementation to parse minecraft .mca region files and count total blocks, structures and biomes.
const fs = require('fs')
const path = require('path');
const { AnvilParser, NBTParser } = require('mc-anvil');
const minecraftIds = require('./minecraft-ids.js');
// iterate biomes for biomes
// determine mountains / caverns / ocean floor from heightmaps
// iterate sections for block info
function getWorldAttributes(worldRegionDirectoryPath) {
const fs = require('fs');
//const CircularJSON = require('circular-json');
var Heap = require('heap');
module.exports = BitsyDictionary;
function BitsyDictionary() {
this._dictionary = { // trie of symbols, with root to a given node representing a possible symbol.
symbolPointers: [],
huffmanTree: {} // Huffman tree for generating the binary code.
const fs = require('fs');
const os = require('os');
const path = require('path');
const BloomFilter = require('bloomfilter').BloomFilter;
const BitsyDictionary = require('../libs/dictionary');
module.exports = function(commander) {
commander
.command('dictionary <directoryPath> <outputFilePath>')
.description('Generate a bitsy dictionary from files within a directory.')
//
var fs = require('fs');
var matches = {};
var input = fs.readFileSync('/Users/braydonbatungbacal/Desktop/big.txt').toString();
var validIndexes = [];
var length = 2; // the start length
for (var i = 0; i < input.length; i++) {
This file has been truncated, but you can view the full file.
console.clear();
const test_string = 'The Project Gutenberg EBook of The Adventures of Sherlock Holmesby Sir Arthur Conan Doyle(#15 in our series by Sir Arthur Conan Doyle)Copyright laws are changing all over the world Be sure to check thecopyright laws for your country before downloading or redistributingthis or any other Project Gutenberg eBookThis header should be the first thing seen when viewing this ProjectGutenberg file Please do not remove it Do not change or edit theheader without written permissionPlease read the "legal small print," and other information about theeBook and Project Gutenberg at the bottom of this file Included isimportant information about your specific rights and restrictions inhow the file may be used You can also find out about how to make adonation to Project Gutenberg, and how to get involved**Welcome To The World of Free Plain Vanilla Electronic Texts****eBooks Readable By Both Humans and By Computers, Since 1971*******These eBooks Were Prepared By Thousands of Volunteers!
/*
Preface:
I'm issuing this challenge as I've hit a major roadblock in the development process
of one of my personal side projects. I've spent the last 2 weeks exhaustively exploring
solutions to the following problem and I'm at my wits end. I've taken a number of approaches
using various tree data structures and clever algorithms with no success.
function VehicleConstructor(name) {
var vehicle = {};
//Properties
vehicle.name = name;
vehicle.milesTravelled = 0;
vehicle.maxPassengers = 0;
vehicle.currentPassengers = 0;
// Default Assignments
@iamarkdev
iamarkdev / dictgen.c
Last active December 11, 2016 08:35
Being ran with: cc main.c -ldictgen_c; ./a.out ~/Desktop
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <dirent.h>
#include <dictionary_c.h>
#define DICT_MAX_SIZE_BYTES 1024 * 1024 * 32
#define DICT_MIN_PATTERN_SIZE_BYTES 2
#define DICT_STOP_SYMBOL '\0'
#define DICT_MAX_AUTOMATON_SIZE_BYTES 2 << 30
@iamarkdev
iamarkdev / strend.c
Last active December 8, 2016 02:10
Returns 1 if string c occurs at the end of string s
#include <stdio.h>
int mystrend(char *s, char *c) {
int sLen = 0;
int cLen = 0;
while (*s != '\0') {
s++, sLen++;
}
#include <stdio.h>
int main() {
int test[100];
int *testP = test;
while (1) {
printf("%c, %p\n", testP);
//*testP = 0; // This will segfault, however reading does not?..
testP++;