Skip to content

Instantly share code, notes, and snippets.

View DanielBaulig's full-sized avatar

Daniel Baulig DanielBaulig

View GitHub Profile
drawUnits: function( dirtyRect ) {
var ressources = this.ressources;
var zones = ressources.game.zones;
var sprites = ressources.sprites;
var bufferContext = this.bufferContext;
bufferContext.save();
if (dirtyRect) {
this.setClipping( dirtyRect );
@DanielBaulig
DanielBaulig / gist:1028939
Created June 16, 2011 09:24
node pcap fix issue 31
decode.ip6_header = function(raw_packet, next_header, ip, offset) {
switch (next_header) {
case 1:
ip.protocol_name = "ICMP";
ip.icmp = decode.icmp(raw_packet, offset);
break;
case 2:
ip.protocol_name = "IGMP";
ip.igmp = decode.igmp(raw_packet, offset);
break;
@DanielBaulig
DanielBaulig / manager.js
Created July 12, 2011 18:36
Change for Issue #296
/*!
* socket.io-node
* Copyright(c) 2011 LearnBoost <dev@learnboost.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
@DanielBaulig
DanielBaulig / gist:1078645
Created July 12, 2011 18:40
Fix for Issue Issue #296
Manager.prototype.onClientDisconnect = function (id, reason) {
for (var name in this.namespaces) {
if (this.roomClients[id][name]) {
this.namespaces[name].handleDisconnect(id, reason);
}
}
this.onDisconnect(id);
};
@DanielBaulig
DanielBaulig / gist:1101446
Created July 23, 2011 13:48
zombie crash
23 Jul 15:46:36 - The onerror handler
on target
{ frames: [ [Circular] ],
contentWindow: [Circular],
window: [Circular],
self: [Circular],
location: [Getter/Setter],
addEventListener: [Function],
WEBVTT FILE
1
00:00:00.500 --> 00:00:02.000 D:vertical A:start
The Web is always changing
2
00:00:02.500 --> 00:00:04.300
and the way we access it is changing
@DanielBaulig
DanielBaulig / TotalDuration.py
Created March 8, 2023 21:22
Davinci Resolve Script to calculate the total duration of all clips on a track, filterable by clip color
# Configuration
# Track to be used to calculate duration
videoTrack = 1
# Clip color to filter for; empty is default
filterColor = ""
# Frames per second used
fps = 60
from datetime import timedelta
@DanielBaulig
DanielBaulig / vite-hot-reload-virtual-module-plugin.js
Last active February 11, 2024 01:34
How to hot reload a virtual module in a Vite plugin
function vitePlugin() {
const virtualModuleDependency = 'virtual-module-conf.json';
const virtualModuleId = 'virtual:module';
const resolveVirtualId = (id) => '\0' + id;
let virtualModuleContent;
async function refreshVirtualModuleContent(reader) {
const json = JSON.parse(await reader());
virtualModuleContent = `export default ${JSON.stringify(json.value)};`;
}
@DanielBaulig
DanielBaulig / zod-form-data.ts
Last active May 12, 2024 00:24
Simple, stupid zod FormData validation
import { z } from 'zod';
// If you feel zod-form-data is too bulky for what
// you're trying to do, try this:
export const zfd = <T extends z.ZodRawShape>(shape: T) => {
return z.custom<FormData>().transform(
(fd) => Object.fromEntries(
fd.entries() as IterableIterator<[string, string]>
)
).pipe(z.object(shape));
@DanielBaulig
DanielBaulig / grab.ts
Last active May 10, 2024 21:09
grab utility function
// Grabs a given list of properties from an
// object and returns a new "shrunk" object
// with just those properties while preserving
// correct typing.
function grab<
O extends { [x in A[number]]: unknown },
const A extends string[]
>(o: O, properties: A): {
[x in A[number]]: typeof o[x]
} {