I hereby claim:
- I am cheald on github.
- I am cheald (https://keybase.io/cheald) on keybase.
- I have a public key whose fingerprint is 02D7 B41C 99BE 4988 5408 6A7A A59B 4A01 51B4 4EA7
To claim this, I am signing this object:
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 123.123.123.123 password" | |
echo "Specify your host's LAN IP and the desired Pihole password" | |
exit 1 | |
fi | |
IP=$1 | |
PASSWORD=$2 |
module Enumerable | |
class MaximumRuntimeExceeded < StandardError; end | |
class ManuallyInterrupted < StandardError; end | |
def with_timeout(timeout) | |
return to_enum(:with_timeout, timeout) unless block_given? | |
max_time = Time.now + timeout | |
each do |elem| | |
raise MaximumRuntimeExceeded if Time.now > max_time | |
raise ManuallyInterrupted if Enumerable.interrupt_enumerables? |
require "irb" | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
IRB.conf[:USE_READLINE] = true | |
IRB.setup(nil) | |
workspace = IRB::WorkSpace.new(binding) | |
irb = IRB::Irb.new(workspace) | |
IRB.conf[:IRB_RC].call irb.context if IRB.conf[:IRB_RC] | |
IRB.conf[:MAIN_CONTEXT] = irb.context | |
trap("SIGINT") { irb.signal_handle } |
require 'java' | |
class Task | |
include Java::JavaUtilConcurrent::Callable | |
def initialize(num) | |
@num = num | |
end | |
def call |
foo = Class.new # You now have an anonymous class, which is just an instance of the Class class. | |
# instance_exec sets `self` to the given instance (<foo>, in this case, our anonymous class) | |
# for the duration of the block | |
foo.instance_exec do | |
define_method :bar do | |
"Hello from an instance of foo! I am #{self.inspect}" | |
end | |
# Here, we're going to step into <foo>'s metaclass, which is the class which defines singleton instance methods for <foo> |
I hereby claim:
To claim this, I am signing this object:
function secure_compare($a, $b) { | |
if(strlen($a) == strlen($b)) { | |
$result = 0; | |
for($i = 0; $i < strlen($a); $i++) { | |
$result = $result | (ord($a[$i]) ^ ord($b[$i])); | |
} | |
return $result === 0; | |
} else { | |
return false; | |
} |
require 'manticore' | |
require 'awesome_print' | |
class MyRedirectHandler < org.apache.http.impl.client::DefaultRedirectStrategy | |
def getRedirect(request, response, context) | |
super.tap do |next_request| | |
logRedirect context, response.getStatusLine.getStatusCode, next_request.getURI.to_s | |
end | |
end |
module MongoMapper | |
module Plugins | |
module Sci | |
module ClassMethods | |
def inherited(subclass) | |
super | |
if @collection_name == subclass.instance_variable_get("@collection_name") | |
key :_type, String unless key?(:_type) | |
subclass.single_collection_parent = self | |
subclass.instance_variable_set("@single_collection_inherited", true) |
# Receive a message from the Mailbox | |
def receive(timeout = nil, &block) | |
puts "[#{Thread.current.object_id}] Receiving on evented mailbox with timeout of #{timeout}" | |
message = next_message(block) | |
until message | |
puts "[#{Thread.current.object_id}] Got nothing from next_message, looping on the reactor..." | |
if timeout | |
# TODO: use hitimes/timers instead of Time.now | |
now = Time.now |