Skip to content

Instantly share code, notes, and snippets.

function stop()
for f, _ in boundless.eventListeners(boundless.events.onEnterFrame) do
print(boundless.removeEventListener(boundless.events.onEnterFrame, f))
end
for id, _ in os.intervals() do
print(os.clearInterval(id))
end
for id, _ in os.timeouts() do
print(os.clearTimeout(id))
end
function stop()
for f, _ in boundless.eventListeners(boundless.events.onEnterFrame) do
print(boundless.removeEventListener(boundless.events.onEnterFrame, f))
end
for id, _ in os.intervals() do
print(os.clearInterval(id))
end
for id, _ in os.timeouts() do
print(os.clearTimeout(id))
end
-- requires a maze.txt file
function readAll(file)
local f = assert(io.open(file, "rb"))
local content = f:read("*all")
f:close()
return content
end
function setBlock(x, y, z, blockType, color)
function getBlockType(p)
local c = boundless.ChunkCoord(p)
local blockType
boundless.loadChunkAnd8Neighbours(c, function (chunks)
local v = boundless.getBlockValues(boundless.BlockCoord(p))
blockType = v.blockType
end)
return blockType
end
@davidfooks
davidfooks / a.out-gdb.py
Created January 12, 2017 17:19
Example gdb command in python
print("Loaded python script!")
import gdb
class HelloWorldCommand (gdb.Command):
"MyCommand! yay."
def __init__ (self):
super(HelloWorldCommand, self).__init__("helloworld", gdb.COMMAND_USER, gdb.COMPLETE_NONE, True)
def invoke(self, arg, from_tty):
@davidfooks
davidfooks / gist:2499700
Created April 26, 2012 13:41
Testing replicaset
var mongodb = require('mongodb');
var ReplSetServers = mongodb.ReplSetServers;
var Server = mongodb.Server;
var Db = mongodb.Db;
var replSet = new ReplSetServers([
new Server('127.0.0.1', 27019, { auto_reconnect: true }),
new Server('127.0.0.1', 27020, { auto_reconnect: true }) ,
new Server('127.0.0.1', 27021, { auto_reconnect: true })
],
{
<script src="socket.io/socket.io.js"></script>
<script>
var heartbeatInterval;
var heartbeatCount = 0;
var socket = io.connect('http://192.168.0.110:8088');
socket.on('connect', function connectFn(data) {
console.log('connected');
var heartbeat = function heartbeatFn()
var express = require('express');
var io = require('socket.io');
var http = require('http');
var fs = require('fs');
http.createServer(function (request, response) {
console.log('request ' + request.url);