Skip to content

Instantly share code, notes, and snippets.

View virae's full-sized avatar

Michal Šimonfy virae

View GitHub Profile
@virae
virae / plain_chatgpt_client.rb
Created June 9, 2023 11:37 — forked from lingceng/plain_chatgpt_client.rb
Ruby chatgpt chat api when stream mode, deal with error handle and chunk break.
class Chatgpt::PlainChatgptClient
def self.chat(parameters)
@client ||= generate_client
res = @client.post("/v1/chat/completions") do |req|
if parameters[:stream].is_a?(Proc)
req.options.on_data = to_json_stream(user_proc: parameters[:stream])
parameters[:stream] = true
end
@virae
virae / gist:2318002
Created April 6, 2012 07:53 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}