Skip to content

Instantly share code, notes, and snippets.

View jdelStrother's full-sized avatar
👋

Jonathan del Strother jdelStrother

👋
View GitHub Profile
DrawInfo* info = malloc(sizeof(*info));
GetDrawInfo(NULL, info);
DestroyDrawInfo(info);
$ gcc -I/ec/include/ImageMagick-6/ -L/ec/lib -lMagickCore-6.Q16 ./magick.c
$ UMEM_DEBUG=default,audit,verbose ./a.out
umem allocator: redzone violation: write past end of buffer
buffer=8103bc0 bufctl=8106a58 cache: umem_alloc_640
previous transaction on buffer 8103bc0:
thread=1 time=T-0.000636133 slab=8105f98 cache: umem_alloc_640
libumem.so.1'umem_cache_alloc_debug+0x1fe
libumem.so.1'umem_cache_alloc+0x18f
libumem.so.1'umem_alloc+0x50
libumem.so.1'malloc+0x36
int main(int argc, char * argv[])
{
DrawInfo* info = AcquireMagickMemory(sizeof(*info));
GetDrawInfo(NULL, info);
DestroyDrawInfo(info);
return 0;
}
@jdelStrother
jdelStrother / gist:0a80ba4b0c928d00eb2b
Created January 30, 2015 10:08
Gems lost while migrating to jruby
# Stuff with obvious replacements:
image_science, rmagick => mini_magick (not a drop-in replacement)
mysql2 => activerecord-jdbc-adapter, jdbc-mysql
unicorn => puma
# Stuff that we only use because they're optimized:
hiredis
yajl-ruby => json
var Promise = require('bluebird')
var a = Promise.reject(new Error('load failed')).delay(100)
var b = Promise.resolve(123).delay(50)
var queue = [a,b]
function processQueue() {
var next = queue.shift()
if (next) {
return next.catch(processQueue)
} else {
function secondsToHoursMinutesSeconds(totalSec) {
totalSec = Math.round(totalSec)
var hours = Math.floor(totalSec / 3600) % 24
totalSec -= hours * 3600
var minutes = Math.floor(totalSec / 60) % 60
totalSec -= minutes * 60
return padToTwo(hours) + ':' + padToTwo(minutes) + ':' + padToTwo(totalSec)
}
// 3000 -> "50:00"
describe '#instances' do
it 'should return all instances of a class currently present in the Ruby ObjectSpace' do
klass = Class.new
some_instances = [klass.new, klass.new, klass.new]
some_instances.each {|instance| klass.instances.should include(instance) }
end
end
#!/bin/sh
# ------------------------------------------------------------------------
# colorwrap
#
# This script wraps a command in a different background and foreground
# color. Depending on what the command is, it sets the color, runs the
# command, then sets the color back to what it was before
#
# To display the current colors being used:
precmd() {
local branch_ref branchless_ref
psvar=()
branch_ref=$(git symbolic-ref -q HEAD 2>/dev/null)
cleanliness=""
if [[ ! -z $(git diff-index --name-only HEAD 2>/dev/null) ]]; then
cleanliness="*"
fi
# We might be on a checked out branch:
{
"status":"200 OK",
"code":"/api/status/ok",
"qname":{
"code":"/api/status/error",
"messages":[
{
"info":{
"count":2,
"result":[