This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For code syntax highlight | |
pin "highlight.js/lib/core", to: "https://ga.jspm.io/npm:[email protected]/lib/core.js" | |
common_langs = ['xml', 'bash', 'c', 'cpp', 'csharp', 'css', 'markdown', 'diff', 'ruby', | |
'go', 'graphql', 'ini', 'java', 'javascript', 'json', 'kotlin', 'less', | |
'lua', 'makefile', 'perl', 'objectivec', 'php', 'php-template', 'plaintext', | |
'python', 'python-repl', 'r', 'rust', 'scss', 'shell', 'sql', 'swift', 'yaml', | |
'typescript', 'vbnet', 'wasm'] | |
common_langs.each do |lang| | |
pin "highlight.js/lib/languages/#{lang}", to: "https://ga.jspm.io/npm:[email protected]/lib/languages/#{lang}.js" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove (arr, item) { | |
if (arr.length) { | |
let index = arr.indexOf(item); | |
if (index > -1) { | |
return arr.splice(index, 1) | |
} | |
} | |
} | |
function pruneCacheEntry (cache, key, keys, current) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/concerns/convert_time_zone.rb | |
module ConvertTimeZone | |
extend ActiveSupport::Concern | |
included do | |
date_columns = columns.select { |column| column.sql_type == 'datetime' }.map(&:name) | |
convert_time_zone date_columns | |
def timestamp_attributes_for_update | |
[:last_updated] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
template = ARGV[0] | |
File.open(template, "a") do |file| | |
logs = `git log -n 10 --oneline` | |
logs = logs.each_line.map { |line| '# ' + line }.join() | |
file.puts logs | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Plugin 'benmills/vimux' | |
function! VimuxSlime() | |
call VimuxOpenRunner() | |
let lines = split(@v, '\n') | |
let text = '' | |
let index = 0 | |
while index < len(lines) | |
let line = lines[index] | |
let l:text = l:text . line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Require SyntaxRange vim plugin | |
call SyntaxRange#IncludeEx('matchgroup=NonText keepend start="^sass" end="^\S"he=e-1,re=e-1 containedin=ALL', 'sass') | |
call SyntaxRange#IncludeEx('matchgroup=NonText keepend start="^coffee" end="^\S"he=e-1,re=e-1 containedin=ALL', 'coffee') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/rails/rails/pull/15106 | |
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'sqlite3' | |
GEMFILE | |
system 'bundle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= search_form_for @q, url: production_status_changes_path, class: 'form-inline' do |f| %> | |
<%= f.label 'Create At' %> | |
<%= f.search_field :created_at_end_of_day_lteq, class: 'form-control input-sm', 'datepicker' => true %> | |
<% end %> |
NewerOlder