Skip to content

Instantly share code, notes, and snippets.

@nicoster
nicoster / beam.md
Created February 26, 2016 04:24 — forked from studzien/beam.md
An example analysis of a BEAM process core dump

This post shows an example of a BEAM process' core dump analysis to backtrack what was the root cause of its crash.

Start gdb by pointing out the BEAM executable that generated the core dump and the core dump file. Optionally, you can provide a directory with the VM's source code:

gdb erts-6.3/bin/beam.smp -core core.14747 -d /home/azureuser/otp_src_17.4/erts/emulator

gdb should tell you what caused the crash and where in code this happened:

@nicoster
nicoster / otp-commands.gdb
Last active January 19, 2017 13:32
erts/etc/unix/etp-commands.in. print LP64 correctly. show HeapBinary directly
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 2005-2014. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@nicoster
nicoster / gitlabcli
Last active January 3, 2018 14:04
to make gitlab admin life easier.
#!/usr/bin/env python3
import requests as httpc
import sys
import json
'''
API reference:
. https://docs.gitlab.com/ee/api/members.html#edit-a-member-of-a-group-or-project
. https://docs.gitlab.com/ce/api/projects.html#list-all-projects
local ins = require 'inspect'
local function insert_prioq(prioq, el, freq, insert_after)
for i, v in ipairs(prioq) do
-- print('i:', i, ' v:', ins(v))
if insert_after then
if freq < v[2] then
table.insert(prioq, i, {el, freq})
-- print(ins(prioq))
@nicoster
nicoster / screenres.swift
Last active November 28, 2022 02:41 — forked from jminor/screenres.swift
Change your Mac's screen resolution from the command line.
#!/usr/bin/swift
// fix build errors with Swift 5.
// Known issues: some resolution is not HiDPI
import Foundation
var shouldPrintUsage = true
var shouldPrintModes = true
var shouldSwitchMode = false
@nicoster
nicoster / onwificonnect.mm
Last active April 13, 2023 02:59
invoke a script when wifi connection changes. it will hold the notification for 5 seconds and coalesce repeating notifications.
#import <Foundation/Foundation.h>
#include <CoreFoundation/CoreFoundation.h>
void onNotifyCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSString* notifyName = (NSString*)name;
if ([notifyName isEqualToString:@"com.apple.system.config.network_change"]) {
// Get the path to the shell script from the command line
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
if (arguments.count > 1) {
NSString *shellScriptPath = [arguments objectAtIndex:1];