Skip to content

Instantly share code, notes, and snippets.

View asterite's full-sized avatar

Ary Borenszweig asterite

  • NoRedInk
  • Buenos Aires, Argentina
View GitHub Profile
require "base64"
require "zlib"
def read(type, bytes_or_io)
IO::ByteFormat::BigEndian.decode(type, bytes_or_io)
end
string = "HISTFAAAAEV42pNpmSzMwMCgyAABTBDKT4GBgdnNYMcCBvsPEBEJISEuATEZMQ4uASkhIR4nrxg9v2lMaxhvMekILGZkKmcCAEf2CsI"
bytes = Base64.decode(string)
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
void set(int fd) {
int flags = fcntl(fd, F_GETFL);
if (isatty(fd)) {
flags |= O_NONBLOCK;
} else {
// flags &= ~O_NONBLOCK;

Ruby lookup quiz

Please fill the output of every # => ... in the code below

Exercise 1

module Target1
end
module IO
# An IO that wraps another IO, and only reads up to the beginning of a
# specified delimiter.
#
# This is useful for exposing part of an underlying stream to a client.
#
# ```
# io = MemoryIO.new "abc||123"
# delimited = IO::Delimited.new(io, read_delimiter: "||")
#
class IO::Delimited
include IO
def self.new(io : IO, delimiter : String)
new(io, delimiter.to_slice)
end
def initialize(@io : IO, @delimiter : Slice(UInt8))
raise ArgumentError.new("empty delimiter") if @delimiter.size == 0
@reached_end = false
class IO::Delimited
include IO
def self.new(io : IO, delimiter : String)
new(io, delimiter.to_slice)
end
def initialize(@io : IO, @delimiter : Slice(UInt8))
raise ArgumentError.new("empty delimiter") if @delimiter.size == 0
@reached_end = false
module Enumerable(*T)
def select
{% if T.size == 1 %}
ary = Array(*T).new
each { |e| ary.push(e) if yield e }
ary
{% else %}
ary = Array(T).new
each { |*e| ary.push(e) if yield *e }
ary
diff --git a/framework/src/framework/bot.cr b/framework/src/framework/bot.cr
index 70dec75..aa574cb 100644
--- a/framework/src/framework/bot.cr
+++ b/framework/src/framework/bot.cr
@@ -14,11 +14,11 @@ require "./plugin"
module Framework
class Bot
- getter config
- getter! connection
require "json"
dummy_json = {
"config": {
"add": {
"headers": [
"x-kong-prefix:localhost",
],
},
},
; ModuleID = 'main_module'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx"
@"$foo" = global i32 0
define i32 @main(i32 %argc, i8** %argv) {
entry:
%0 = call i32* @"*foo_ptr"()
store i32 1, i32* %0