Skip to content

Instantly share code, notes, and snippets.

Avatar

Roger Pack rdp

View GitHub Profile
View gist:2ebd7fbed16dd5e2bb0ff5151b3b644b
require "socket"
struct Socket::Addrinfo
class DnsRequestCbArg
getter value : Int32 | Pointer(LibC::Addrinfo) | Nil
@fiber : Fiber
def initialize
@fiber = Fiber.current
View gist:918af45b0ad68cd9bf2e0dc54cad5638
diff --git a/src/debug/dwarf/line_numbers.cr b/src/debug/dwarf/line_numbers.cr
index b4a11139b..790748d88 100644
--- a/src/debug/dwarf/line_numbers.cr
+++ b/src/debug/dwarf/line_numbers.cr
@@ -284,7 +284,9 @@ module Debug
operation_advance = adjusted_opcode // sequence.line_range
increment_address_and_op_index(operation_advance)
registers.line &+= sequence.line_base + (adjusted_opcode % sequence.line_range)
- register_to_matrix(sequence, registers)
+ if (registers.is_stmt || (registers.line.to_i > 0 && registers.column.to_i > 0))
View gist:9e954c12905ed5a16bfae78a200894cb
diff --git a/src/debug/dwarf/line_numbers.cr b/src/debug/dwarf/line_numbers.cr
index b4a11139b..ebbfebbaa 100644
--- a/src/debug/dwarf/line_numbers.cr
+++ b/src/debug/dwarf/line_numbers.cr
@@ -284,7 +284,9 @@ module Debug
operation_advance = adjusted_opcode // sequence.line_range
increment_address_and_op_index(operation_advance)
registers.line &+= sequence.line_base + (adjusted_opcode % sequence.line_range)
- register_to_matrix(sequence, registers)
+ if (registers.is_stmt)
View gist:cde091f6eeb6d1d5daf9384c457d5113
Linux:
Using compiled compiler at `.build/crystal'
["src/crystal/main.cr:47:14 in 'main'",
"src/unicode/data.cr:1554:7 in 'casefold_ranges'",
"_start",
"???"]
View spork_crystal
~/kemal_server$ cat wait_file.sh
#!/bin/bash
echo "waiting for $1" >> spork.log
date +"%T.%3N" >> spork.log
rm -f $1 # in case leftover
while [ ! -f "$1" ]; do sleep 0.1; done
echo "found $1" >> spork.log
date +"%T.%3N" >> spork.log
joshua@joshua-Latitude-E6230:~/kemal_server$ cat kemal_spork.cr
View try_openssl_rand.diff
diff --git a/src/crystal/system/random.cr b/src/crystal/system/random.cr
index e03cc6ca6..745d0300d 100644
--- a/src/crystal/system/random.cr
+++ b/src/crystal/system/random.cr
@@ -11,7 +11,7 @@ module Crystal::System::Random
end
{% if flag?(:linux) %}
- require "./unix/getrandom"
+ require "./unix/urandom"
@rdp
rdp / addrinfo.diff
Created Nov 16, 2019
crystal lang #8263
View addrinfo.diff
diff --git a/src/socket/addrinfo.cr b/src/socket/addrinfo.cr
index 25e046cda..0ac8867ae 100644
--- a/src/socket/addrinfo.cr
+++ b/src/socket/addrinfo.cr
@@ -82,12 +82,12 @@ class Socket
class Error < Socket::Error
getter error_code : Int32
- def self.new(error_code)
- new error_code, "getaddrinfo: #{String.new(LibC.gai_strerror(error_code))}"
View gist:a16ddbd5750cbf75d5b4de8ddbc3ccbb
crystal make Makefile:68: *** Could not locate llvm-config, make sure it is installed and in your PATH, or set LLVM_CONFIG. Stop.
this meant "llvm isn't linked in after it's installed" "it's "keg only" or whatever homebrew calls it" so you have to link it or manually use it, this:
$ find /usr -name llvm-config
/usr/local/Cellar/llvm@8/8.0.1/bin/llvm-config
$ PATH=/usr/local/Cellar/llvm@8/8.0.1_1/bin/:$PATH make
View webby.rb
require 'webrick'
server = WEBrick::HTTPServer.new :Port => 8000
server.mount_proc '/' do |req, res|
if req.path != "/"
address = "taobao.com"
else
address = "facebook.com"
end
View crystal_c_call_timeout.cr
require "socket"
lib C
# In C: double cos(double x)
fun sleep(value : UInt32) : UInt32
end
spawn {
loop {
TCPSocket.new("facebook.com",80,0.1,0.1).close
STDOUT.print "."
You can’t perform that action at this time.