Skip to content

Instantly share code, notes, and snippets.

Long answer:

Can be done. The code that I have below should not be used in production. It's just a demo. There might be many ways to achieve similar functionality but this is one – albeit, buggy – way.

let's say the settings in the DB are:

---------------------------+----------------

// Q sample by Jeff Cogswell
/*===========
We want to call these three functions in sequence, one after the other:
First we want to call one, which initiates an ajax call. Once that ajax call
is complete, we want to call two. Once two's ajax call is complete, we want
to call three.
BUT, we don't want to just call our three functions in sequence, as this
@kgrz
kgrz / README.md
Created March 14, 2014 12:05 — forked from domenic/README.md

The scenario:

  • We are writing a digital textbook-reading app.
  • Most of the time you have a "basic" license for your textbook, but one (and only one) of your computers can request an "enhanced" license.
  • You can only print from the computer with the enhanced license.

The problem statement:

@kgrz
kgrz / rb_trace_func.rb
Created March 25, 2014 19:37
Ruby, trace, set_trace_func
RubyVM::InstructionSequence.compile_option = {
trace_instruction: false
# This disables the `trace` VM instruction
}
count = lambda do
@count ||= 0
@count += 1
end
@kgrz
kgrz / app.rb
Last active August 29, 2015 13:58
Haven't tested this, but should work
require "./calculation_helpers"
helpers do
def calcpage(number)
CalculationHelpers.calcpage(number)
end
end
get '/' do
erb :index
@kgrz
kgrz / no_trace.rb
Last active August 29, 2015 13:58
TracePoint example won't trace events. set_trace_func example records some events
RubyVM::InstructionSequence.compile_option = {
trace_instruction: false
}
method = <<-EOF
count = lambda do
@count ||= 0
@count += 1
end
I wasn't first to get the key. Nor was I second, third, or even fourth. I'm probably not even the
10th to get it. But I'm happy that I was able to prove to myself that I too could do it.
The sleepless adventure began yesterday afternoon, 2014-04-12 15:19:04.827516279 -0700.
First, I have to admit I was a skeptic. Like the handful of other dissenters, I had initially
believed that it would be highly improbable under normal conditions to obtain the private key
through exploiting Heartbleed. So this was my motivation for participating in Cloudflare's
challenge. I had extracted a lot of other things with Heartbleed, but I hadn't actually set out to
extract private keys. So I wanted to see first-hand if it was possible or not.
@kgrz
kgrz / ermwhat.rb
Created April 27, 2014 15:18
Oh! Rubie.
pry:1> ObjectSpace.reachable_objects_from_root.class # => Hash
pry:2> ObjectSpace.reachable_objects_from_root.keys # => ["vm", "machine_context", "symbols", "global_list", "global_tbl"]
pry:3> ObjectSpace.reachable_objects_from_root.first # => => ["vm", [#<RubyVM:0x007f9b3a85b6a0>]]
pry:4> ObjectSpace.reachable_objects_from_root["vm"] # => nil
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@kgrz
kgrz / invoker.ini
Last active August 29, 2015 14:02
Zeus + Invoker + Rails http://rails.dev
[zeus]
directory = .
command = zeus start
[next_secret_project]
directory = .
command = zeus server -p $PORT