Skip to content

Instantly share code, notes, and snippets.

jkeroes / perl-memory-modules
Created September 21, 2012 20:28
Perl memory leaks resources
Tracking memory leaks:
Devel::Arena - sv_stats() returns arena structures used for SV allocation
* Devel::Cycle - find_cycle($ref) returns all cycles found in $ref and the perl variables they point to
Devel::Gladiator - walk Perl variable arena
Devel::Leak - deprecated by Devel::LeakTrace::Fast
Devel::LeakTrace - deprecated by Devel::LeakTrace::Fast
* Devel::LeakTrace::Fast - prints leaked SV's and line numbers at END.
Data::Structure::Util - has_circular_ref($ref) returns ref to link in $ref that is circular or false.
Test::LeakTrace - no_leaks_ok(), etc.
use strict;
use warnings FATAL => 'all';
use feature 'say';
use utf8;
use open qw(:std :utf8);
use Carp;
use HTTP::Tiny;
Ryan-rsm-McKenzie / MyClass.psc
Last active January 15, 2022 02:16
Native SKSE64 Papyrus Interface Implementation
ScriptName MyClass
String Function HelloWorld() Global Native
Int Function Sum(Int a_num1, Int a_num2) Global Native
krupitskas / gist:034c196eb1eca48e741a
Created January 13, 2015 21:11
Havok Hello world
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2014 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
// Math and base include
#include <Common/Base/hkBase.h>
clayne /
Created March 19, 2022 17:45 — forked from joeytwiddle/
Add all forks of the current repo as remotes
#!/usr/bin/env bash
set -e
# See also: (same thing but in python)
origin_url="$(git remote show origin | grep 'Fetch URL:' | sed 's+.*: ++')"
full_repo_name="$(echo "$origin_url" | sed 's+.* ; s+\.git$++')"
keebus /
Last active March 25, 2022 21:32
Exception-like code in C (gcc/clang)

Lightweight exceptions in C (with gcc/clang)

For fun I implemented a lightweight exception mechanism for C that allows writing transactional code. This is what it looks like:

int device_create(device_t **odevice)
	throwbase(-1); // makes this function "throwing" with a default return value of -1.

	device_t *device = malloc(sizeof *device);
keebus / local_opaque_object.c
Last active March 25, 2022 21:33
Local opaque object in C
// library.h -------------------------------------------------------------------
#define opaque(Type) Type; int $sizeof_##Type(void);
#define opaque_impl(Type) int $sizeof_##Type(void) { return sizeof(Type); }
#define local(Type) ((Type *)alloca($sizeof_##Type()))
// foo.h -----------------------------------------------------------------------
import idaapi
import ida_hexrays
import ida_lines
class MyChoose(idaapi.Choose):
def __init__(self, items, title, cols, icon=-1):
idaapi.Choose.__init__(self, title, cols, flags=idaapi.Choose.CH_MODAL, icon=icon)
self.items = items
def OnClose(self):
arnauldvm / .gitconfig
Last active January 27, 2024 10:00
Git sync all local tracking branches with remotes
tracking = "!f() { git for-each-ref --format '%(refname:short):%(upstream:short)' 'refs/heads' | egrep -v ':$'; }; f"
is-clean-workdir = "!f() { git diff --stat --exit-code || { echo \"Workdir dirty\"; exit 1; }; }; f"
is-clean-index = "!f() { git diff --stat --cached --exit-code || { echo \"Index dirty\"; exit 2; }; }; f"
is-clean = "!f() { git is-clean-workdir && git is-clean-index; }; f"
co-merge = "!f() { local=\"$1\"; remote=\"$2\"; git checkout \"$local\"; git merge --ff-only \"$remote\"; }; f"
current-branch = rev-parse --abbrev-ref HEAD
sync = "!f() { git is-clean || { echo Aborting sync.; exit 1; }; current=$(git current-branch); git fetch --all; git tracking | while IFS=: read local remote; do echo \"Merging $local with $remote\"; git co-merge \"$local\" \"$remote\"; done 3>&1 1>&2 2>&3 | egrep -i --color 'fatal|$' 3>&1 1>&2 2>&3; git checkout \"$current\"; }; f"