Skip to content

Instantly share code, notes, and snippets.

View lloyd's full-sized avatar

Lloyd Hilaiel lloyd

View GitHub Profile
Title
[Please provide a descriptive (but short) title for your session.]
???: Embedding Ruby for Fun and Profit
???: Write native code so you don't have to.
Description
[Provide a short summary description of your session topic. This will
be posted publicly if your proposal is accepted.]
#
# A simple BrowserPlus service implemented in Ruby that will calculate the
# MD5 sum of a file that a user has selected
#
# (c) Yahoo! Inc. 2008
#
class FileChecksumInstance
# args contains 'url', 'data_dir', 'temp_dir'
def initialize(args)
Title
[Please provide a descriptive (but short) title for your session.]
Embedding Ruby for Fun and Profit
Description
[Provide a short summary description of your session topic. This will
be posted publicly if your proposal is accepted.]
Life is too short to write native code. It takes too long, it works
[lth@lappro breakToDebugger] $ gcc -g -o foo foo.c
[lth@lappro breakToDebugger] $ ./foo
stopping process, to attach - gdb <path_to_binary> 74611
[2]+ Stopped ./foo
[lth@lappro breakToDebugger] $ gdb ./foo 74611
GNU gdb 6.3.50-20050815 (Apple version gdb-1339) (Sat May 23 05:39:07 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
#include <signal.h>
#include <stdio.h>
int
main(void)
{
pid_t p = getpid();
printf("stopping process, to attach - gdb <path_to_binary> %d\n", p);
kill(getpid(), SIGSTOP);
return 0;
[lth@lappro Safari.app] $ gdb --arch i386 Contents/MacOS/Safari 76514
GNU gdb 6.3.50-20050815 (Apple version gdb-1339) (Sat May 23 05:39:07 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .......................... done
/Applications/Safari.app/76514: No such file or directory
==23624== Invalid read of size 8
==23624== at 0x411C13: bp::service::Description::freeDef() (bpservicedescription.cpp:932)
==23624== by 0x40E8C4: bp::service::Description::~Description() (bpservicedescription.cpp:353)
==23624== by 0x402BA4: serviceDescSample() (sample.cpp:124)
==23624== by 0x402F56: main (sample.cpp:181)
==23624== Address 0x5920a18 is 40 bytes inside a block of size 48 free'd
==23624== at 0x4C2260D: free (in /usr/lib/valgrind/amd64-linux/vgpreload_memcheck.so)
==23624== by 0x411C3F: bp::service::Description::freeDef() (bpservicedescription.cpp:933)
==23624== by 0x411C66: bp::service::Description::toBPCoreletDefinition() (bpservicedescription.cpp:941)
==23624== by 0x402AF0: serviceDescSample() (sample.cpp:119)
require 'digest/md5'
class FileChecksum
bp_version "1.0.10"
bp_doc "Allows client side MD5 of user selected files."
def md5(bp, args)
begin
contents = File.open(args[:file].realpath, "rb") { |f| f.read }
bp.complete(Digest::MD5.hexdigest(contents))
bridges.pdf: bridges.html
htmldoc -t pdf14 --webpage bridges.html > bridges.pdf
bridges.html: bridges.textile
redcloth < bridges.textile > bridges.html
.PHONY: view
view: bridges.pdf
xpdf bridges.pdf
var ttsService = {
service: "TextToSpeech",
version: "1",
minversion: "1.0.2"
};
BrowserPlus.init(function(res) {
BrowserPlus.require(
{services: [ ttsService ]},
function(r) {