Skip to content

Instantly share code, notes, and snippets.

@pnc
pnc / debugging.md
Last active August 12, 2024 17:03
Debugging exit status 127 of custom binaries on AWS Lambda

AWS Lambda allows you to run custom binaries as child processes.

However, if the packaged binary you're running on AWS Lambda uses shared libraries, they may not be available in the Lambda environment. If this is the case, your binary will terminate without any output. In my case, the exit status code was 127, which wasn't very helpful (typically this is "command not found.")

2015-11-18T00:50:10.731Z	521db901-8d8e-11e5-b9df-cd31cc90ece2	Calling phantom:  /var/task/phantomjs [ '/var/task/phantomjs-script.js' ]
2015-11-18T00:50:10.809Z	521db901-8d8e-11e5-b9df-cd31cc90ece2	child process exited with code 127

Linux's loader, ld.so, allows you (see manpage) to set an environment variable called LD_DEBUG that will output verbose information while the shared libraries are loaded.

Since Lambda doesn't let you set arbitrary environment variables, you need to set the environment

@pnc
pnc / generate.rb
Last active August 29, 2015 14:24
Declare Xcode project files
require 'xcodeproj'
# Avoid spaces, otherwise automatic crash symbolication breaks.
# To change how it appears to the user, set Bundle Display Name in the Info plist.
TARGET_NAME = "ExampleApp"
CONFIG = {"APP_BUNDLE_ID" => "com.example.example-app",
"ASSETCATALOG_COMPILER_APPICON_NAME" => {debug: "AppIconDevelopment",
release: "AppIcon"},
"ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME" => "LaunchImage"}

Here is a link

Bacon::Error: File comparison error `execution_output.txt` for install_custom_workspace:
--- DIFF -----------------------------------------------------------------------
Attempting to activate Reachability (3.1.0)
Activated Reachability at Reachability (3.1.0)
Requiring nested dependencies ()
- Creating possibility state for Reachability (3 remaining)
- Attempting to activate Reachability (3.1.1)
+ Creating possibility state for Reachability (4 remaining)
+ Attempting to activate Reachability (3.2)
Found existing spec (Reachability (3.1.0))
@pnc
pnc / gist:d6f84f65ea1dbc73367d
Created December 2, 2014 20:29
Build failures on 76c22f4959ff12ecef3c43c11af2394d31bfc8d4,
$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
$ bundle exec rake
rm -rf banana-lib && tar zxf banana-lib.tar.gz
Using ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
@pnc
pnc / observer.md
Last active April 1, 2025 21:38
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@pnc
pnc / NSInputStreamRead.m
Created March 12, 2014 15:33
Read NSInputStream and generate SHA of contents
#import <CommonCrypto/CommonDigest.h>
// From the people who brought you goto fail;
// http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/LocalTests/XTSTest/hexString.c
static char PIHexbyteMap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
static int PIHexbyteMapLen = sizeof(PIHexbyteMap);
/* Utility function to convert nibbles (4 bit values) into a hex character representation */
static char
[2014-03-06T21:15:52+00:00] INFO: Forking chef instance to converge...
[2014-03-06T21:15:52+00:00] INFO: *** Chef 11.10.4 ***
[2014-03-06T21:15:52+00:00] INFO: Chef-client pid: 1478
[2014-03-06T21:15:53+00:00] INFO: Setting the run_list to ["recipe[dashboard::default]"] from JSON
[2014-03-06T21:15:53+00:00] INFO: Run List is [recipe[dashboard::default]]
[2014-03-06T21:15:53+00:00] INFO: Run List expands to [dashboard::default]
[2014-03-06T21:15:53+00:00] INFO: Starting Chef Run for saucy
[2014-03-06T21:15:53+00:00] INFO: Running start handlers
[2014-03-06T21:15:53+00:00] INFO: Start handlers complete.
[2014-03-06T21:15:53+00:00] INFO: directory[/var/spool/rsyslog] owner changed to 0
@pnc
pnc / section.m
Created February 1, 2013 14:51
Example of using ATV.
ATVManagedTableSection *inboxSection = [[ATVManagedTableSection alloc] initWithIdentifier:@"inbox"];
[inboxSection setManagedObjectContext:context andFetchRequest:fetchRequest];
[inboxSection registerNib:@"PIMessageCell" forIdentifier:@"PIMessageCell"];
[inboxSection setCellSource:^UITableViewCell *(ATVTableSection *section, NSUInteger index, id object) {
UITableViewCell *cell = [section dequeueReusableCellWithIdentifier:@"PIMessageCell"];
return cell;
}];
[inboxSection setConfigureCell:^(ATVTableSection *section, UITableViewCell *cell, NSUInteger index, id object) {
PIMessageCell *messageCell = (PIMessageCell *)cell;
[messageCell setMessage:object];
@pnc
pnc / install_resources.sh
Created November 8, 2012 12:39
Get CocoaPods (almost) to compile xcdatamodel resources as it copies them, like it does XIBs
*.xcdatamodel)
echo "`basename $1 .xcdatamodel`.mom"
echo "`basename ${1} .xcdatamodel`.mom"
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename ${1} .xcdatamodel`.mom"
;;