Skip to content

Instantly share code, notes, and snippets.

@rothomp3
rothomp3 / swift-buffer-example.swift
Last active January 1, 2020 17:09
Swift example of writing to memory buffer
let bitmapBuffer = UnsafePointer<UInt8>.alloc(Int(height * width * 4))
let pixelNumber = (x * 4) + (y * width * 4)
bitmapBuffer[pixelNumber + 3] = 255 // Alpha
bitmapBuffer[pixelNumber + 2] = redValue
bitmapBuffer[pixelNumber + 1] = greenValue
bitmapBuffer[pixelNumber + 0] = blueValue
@vhyza
vhyza / catch_exception.rb
Created November 10, 2011 10:53
Removed require 'cgi' to avoid segmentation fault
# encoding: utf-8
STDOUT.sync = true
STDERR.sync = true
require 'pathname'
at_exit do
if (e = $!) && !e.instance_of?(SystemExit)
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"