This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
struct node { | |
node *l, *r, *p; | |
int key, s; | |
node() : l(nullptr), r(nullptr), p(nullptr), s(0) { } | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Usage: | |
-- Start a console instance, holds its own environment | |
local console = InteractiveConsole { | |
sum = function(a, b) | |
return a + b | |
end | |
} | |
-- First call: define output and error functions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Reasoning: | |
If your program uses (and stops using) a lot of tables, you will be dealing with the memory allocation and deallocation overhead, | |
Roberto Ierusalimschy suggests "recycling" tables as a way of optimizing code that uses a lot of them. This small module uses the | |
__gc metamethod (enabled for tables in version 5.2) to know whenever a table isn't being used anymore and stores it for future use, | |
avoiding an extra deallocation and future allocation of a new table. If you aren't sure that this module will help your code's | |
performance, do not use it because it might backfire on your goals. Even then you should customize the table clean up (or not clean | |
them at all) depending on what your are going to use them for. | |
Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local vstruct = require 'vstruct' | |
function Items(path) | |
local buffer = io.open(path, 'rb') | |
local signature = vstruct.readvals('u4', buffer) | |
local itemCount, creatureCount, effectCount, distanceCount = vstruct.readvals('4 * u2', buffer) | |
local items = {} |