commit stringlengths 40 40 | old_file stringlengths 4 264 | new_file stringlengths 4 264 | old_contents stringlengths 0 4.24k | new_contents stringlengths 1 5.44k | subject stringlengths 14 778 | message stringlengths 15 9.92k | lang stringclasses 277
values | license stringclasses 13
values | repos stringlengths 5 127k |
|---|---|---|---|---|---|---|---|---|---|
68fea440f285afa5f620dda9653cd01492afa501 | src/soil/application/app.cr | src/soil/application/app.cr | require "./hooks_dsl"
require "./config_dsl"
module Soil
class App
extend HooksDSL
extend RoutingDSL
extend ConfigDSL
@@namespace = ""
@@before_hooks = [] of Http::Request, Http::Response ->
@@after_hooks = [] of Http::Request, Http::Response ->
@@router = Router.new
@@config = Confi... | require "./hooks_dsl"
require "./config_dsl"
module Soil
class App
extend HooksDSL
extend RoutingDSL
extend ConfigDSL
@@namespace = ""
@@before_hooks = [] of Http::Request, Http::Response ->
@@after_hooks = [] of Http::Request, Http::Response ->
@@router = Router.new
@@config = Confi... | Add class method to simplify boot | Add class method to simplify boot
| Crystal | mit | joaodiogocosta/soil |
4d558e5a852cb03915ed92c3f6230bb8aa5f8034 | src/web_app_skeleton/src/pages/main_layout.cr | src/web_app_skeleton/src/pages/main_layout.cr | abstract class MainLayout
include LuckyWeb::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
needs flash : LuckyWeb::Flash::Store
abstract def inner
render do
html_doctype
... | abstract class MainLayout
include LuckyWeb::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
needs flash : LuckyWeb::Flash::Store
abstract def inner
def render
html_doctype
... | Use render method instead of block in app skeleton | Use render method instead of block in app skeleton
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
c44b6e48602752cf0fa39eab4d6e2e0e0fe8fa60 | src/web_app_skeleton/src/actions/base_action.cr | src/web_app_skeleton/src/actions/base_action.cr | abstract class BaseAction < LuckyWeb::Action
include LuckyWeb::Exposeable
macro inherited
# If something should always be exposed to your pages, expose them here.
#
# Example:
#
# macro inherited
# expose :current_user
# end
#
# def current_user
# find_the_user...
... | abstract class BaseAction < LuckyWeb::Action
# If something should always be exposed to your pages, expose them here.
#
# Example:
#
# expose current_user
#
# def current_user
# find_the_user...
# end
#
# Then add an assign for it in your BasePage
end
| Make exposures work with latest LuckyWeb | Make exposures work with latest LuckyWeb
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
804b5698d86f139da76925aedd2facd928f05cbd | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
module Discordcr
module REST
def request(endpoint_key : Symbol, method : String, url: String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: method, url: url, headers: headers, body: body, tls: true)
end
end
end
| require "http/client"
module Discordcr
module REST
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: method, url: url, headers: headers, body: body, tls: true)
end
end
end
| Fix a syntax error in the request parameters | Fix a syntax error in the request parameters
| Crystal | mit | meew0/discordcr |
96197cf703d049c949c28e74fe6dbe11872359cf | src/discordcr/mappings/converters.cr | src/discordcr/mappings/converters.cr | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
str = parser.read_string_or_null
str.not_nil!.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
# Converts a valu... | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
parser.read_string.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
# Converts a value that may be a snowflake, but mi... | Remove an unnecessary not_nil! from SnowflakeConverter | Remove an unnecessary not_nil! from SnowflakeConverter
| Crystal | mit | meew0/discordcr |
6d8febf371c3995f8be8717dce3b6d871dfde588 | src/dota/api/hero.cr | src/dota/api/hero.cr | module Dota
module API
class Hero
include Utilities::Mapped
extend Utilities::Mapped
getter id : Int8 | Int32, name : String
private getter internalName : String
def self.find(id)
if mapping[id]?
new(id)
else
raise Exception.new("Hero does not ex... | module Dota
module API
class Hero
include Utilities::Mapped
extend Utilities::Mapped
getter id : Int8 | Int32, name : String
private getter internalName : String
def self.find(id)
if mapping[id]?
new(id)
else
raise Exception.new("Hero does not ex... | Fix bug with wrong variable name in Hero.cr | Fix bug with wrong variable name in Hero.cr
| Crystal | mit | azah/dotacr |
b80c75e45d682c75b8c84f16d66667739fc3b0ca | src/raven/integrations/amber.cr | src/raven/integrations/amber.cr | module Raven
# ```
# require "raven/integrations/amber"
# ```
#
# It's recommended to enable `Configuration#async` when using Amber.
#
# ```
# Raven.configure do |config|
# # ...
# config.async = true
# config.current_environment = Amber.env.to_s
# end
# ```
module Amber
# Returns ... | require "amber"
module Raven
# ```
# require "raven/integrations/amber"
# ```
#
# It's recommended to enable `Configuration#async` when using Amber.
#
# ```
# Raven.configure do |config|
# # ...
# config.async = true
# config.current_environment = Amber.env.to_s
# end
# ```
module Amb... | Add missing require in Amber integration | Add missing require in Amber integration
| Crystal | mit | Sija/raven.cr |
9f495063900515583223306446f338ecd2585876 | src/nekogirls.cr | src/nekogirls.cr | require "./nekogirls-cr/*"
require "kemal"
Kemal.config.port = 8080
Kemal.config.public_folder = "./src/public/"
Kemal.config.host_binding = "localhost"
module Nekogirls
get "/" do
"Hello World"
end
get "/upload" do
render "src/views/form.ecr"
end
post "/upload" do |env|
file = env.params.file... | require "./nekogirls-cr/*"
require "kemal"
Kemal.config.port = 8080
Kemal.config.public_folder = "./src/public/"
Kemal.config.host_binding = "localhost"
module Nekogirls
get "/" do
"Hello World"
end
get "/upload" do
render "src/views/form.ecr"
end
post "/upload" do |env|
file = env.params.file... | Fix for the 031aff... commit | Fix for the 031aff... commit
| Crystal | mit | Cyan101/nekogirls-cr |
b51dec483a782f021c36b8caf4be333eb2ed3464 | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings/*"
require "./version"
module Discord
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
USER_AGENT = "DiscordBot (https://github.com/meew0/discordcr, #{Discord::VERSION})"
API_BASE = "https://discordapp.com/api/v6"
d... | require "http/client"
require "openssl/ssl/context"
require "./mappings/*"
require "./version"
module Discord
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
USER_AGENT = "DiscordBot (https://github.com/meew0/discordcr, #{Discord::VERSION})"
API_BASE = "https://discordapp.com/api/v6"
d... | Add type requirements to all the endpoint methods | Add type requirements to all the endpoint methods
| Crystal | mit | meew0/discordcr |
ef7a298c8843d97a5c2e529e60ef9ec0d6265778 | src/scry/environment_config.cr | src/scry/environment_config.cr | module Scry
module EnvironmentConfig
private enum EnvVars
CRYSTAL_CACHE_DIR
CRYSTAL_PATH
CRYSTAL_VERSION
CRYSTAL_LIBRARY_PATH
CRYSTAL_OPTS
end
def self.run
initialize_from_crystal_env.each_with_index do |v, i|
e = EnvVars.from_value(i).to_s
ENV[e] = v
... | module Scry
module EnvironmentConfig
enum EnvVars
CRYSTAL_CACHE_DIR
CRYSTAL_PATH
CRYSTAL_VERSION
CRYSTAL_LIBRARY_PATH
CRYSTAL_OPTS
end
def self.run
initialize_from_crystal_env.each_with_index do |v, i|
e = EnvVars.from_value(i).to_s
ENV[e] = v
end... | Fix compatibility with Crystal 0.34 stdlib | Fix compatibility with Crystal 0.34 stdlib
| Crystal | mit | crystal-lang-tools/scry |
f77693c4a8b50f2169f200e25db5a0a454f2556c | src/web_app_skeleton/src/server.cr | src/web_app_skeleton/src/server.cr | require "./app"
server = HTTP::Server.new("127.0.0.1", 8080, [
LuckyWeb::HttpMethodOverrideHandler.new,
HTTP::LogHandler.new,
LuckyWeb::ErrorHandler.new(action: Errors::Show),
LuckyWeb::RouteHandler.new,
HTTP::StaticFileHandler.new("./public", false),
])
puts "Listening on http://127.0.0.1:8080..."
server.... | require "./app"
server = HTTP::Server.new("127.0.0.1", 8080, [
LuckyWeb::HttpMethodOverrideHandler.new,
HTTP::LogHandler.new,
LuckyWeb::SessionHandler.new,
LuckyWeb::Flash::Handler.new,
LuckyWeb::ErrorHandler.new(action: Errors::Show),
LuckyWeb::RouteHandler.new,
HTTP::StaticFileHandler.new("./public", f... | Add session and flash handlers | Add session and flash handlers
Closes #61
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
9a5934811dfb0836a3124438237a3b3eebf827dc | spec/spec_helper.cr | spec/spec_helper.cr | require "spec"
require "../src/kemal/*"
include Kemal
| require "spec"
require "../src/kemal/*"
include Kemal
Spec.before_each do
Kemal.config.env = "development"
end
| Set to development before_each spec | Set to development before_each spec
| Crystal | mit | sdogruyol/kemal,sdogruyol/kemal,kemalcr/kemal,MGerrior/kemal,MGerrior/kemal |
ecd2d7d0897fb113786d931ffb7dc1d9c9c800bf | src/web_app_skeleton/config/email.cr | src/web_app_skeleton/config/email.cr | BaseEmail.configure do
if Lucky::Env.production?
send_grid_key = ENV.fetch("SEND_GRID_KEY")
settings.adapter = Carbon::SendGridAdapter.new(api_key: send_grid_key)
else
settings.adapter = Carbon::DevAdapter.new
end
end
| BaseEmail.configure do
if Lucky::Env.production?
# If you don't need to send emails, set the adapter to DevAdapter instead:
#
# settings.adapter = Carbon::DevAdapter.new
#
# If you do need emails, get a key from SendGrid and set an ENV variable
send_grid_key = send_grid_key_from_env
sett... | Improve messaging when SEND_GRID_KEY is missing | Improve messaging when SEND_GRID_KEY is missing
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
7d4236d4ce4a8316308336746c6fbdd23ba13e3c | spec/spec_helper.cr | spec/spec_helper.cr | require "spec"
module GraniteExample
ADAPTERS = ["pg","mysql","sqlite"]
@@model_classes = [] of Granite::ORM::Base.class
extend self
def model_classes
@@model_classes
end
end
require "../src/granite_orm"
require "./spec_models"
GraniteExample.model_classes.each do |model|
model.drop_and_create
end
| require "spec"
module GraniteExample
ADAPTERS = ["pg","mysql","sqlite"]
@@model_classes = [] of Granite::ORM::Base.class
extend self
def model_classes
@@model_classes
end
end
require "../src/granite_orm"
require "./spec_models"
Granite::ORM.settings.logger = ::Logger.new(nil)
GraniteExample.model_cl... | Disable query logging for `crystal spec` | Disable query logging for `crystal spec`
| Crystal | mit | drujensen/kemalyst-model |
7db17d03cd4709fbee0a0dd647e8067eaa876a4a | spec/discordcr_spec.cr | spec/discordcr_spec.cr | require "./spec_helper"
struct StructWithSnowflake
JSON.mapping(
data: {type: UInt64, converter: Discord::SnowflakeConverter}
)
end
struct StructWithMaybeSnowflake
JSON.mapping(
data: {type: UInt64 | Nil, converter: Discord::MaybeSnowflakeConverter}
)
end
describe Discord do
describe Discord::Snowf... | require "./spec_helper"
struct StructWithSnowflake
JSON.mapping(
data: {type: UInt64, converter: Discord::SnowflakeConverter}
)
end
struct StructWithMaybeSnowflake
JSON.mapping(
data: {type: UInt64 | Nil, converter: Discord::MaybeSnowflakeConverter}
)
end
struct StructWithSnowflakeArray
JSON.mappin... | Write a test for SnowflakeArrayConverter | Write a test for SnowflakeArrayConverter
| Crystal | mit | meew0/discordcr |
50b82015e81ededa1dbe8f77bb14f7d4bb47c26d | crystal-csp/gc-csp.cr | crystal-csp/gc-csp.cr | ch1 = Channel(String).new(16)
gcfile = File.new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
spawn do
gcfile.each_line() do |line|
ch1.send(line)
end
ch1.close
end
at = 0
gc = 0
while line = ch1.receive?
if line.starts_with?('>')
next
end
line.each_byte() do |chr|
case chr
when 'A', ... | lines_chan = Channel(String).new(16)
# ------------------------------------------------------------------------------
# Loop over the input file in a separate fiber (and thread, if you set the
# CRYSTAL_WORKERS count to something larger than 1), and send its output on a
# channel
# ------------------------------------... | Clean up code and add comments | Clean up code and add comments
| Crystal | mit | samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark |
8a61c3c8d812cf1ab88296a80130de8bfb8ac222 | src/discordcr/rest.cr | src/discordcr/rest.cr | module Discordcr
module REST
end
end
| require "http/client"
module Discordcr
module REST
def request(endpoint_key : Symbol, method : String, url: String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: method, url: url, headers: headers, body: body, tls: true)
end
end
end
| Implement a very basic request method | Implement a very basic request method
| Crystal | mit | meew0/discordcr |
cae016cd2e1ca1777de8cd352a647ac917b4fb18 | src/generators/templates/project_src/src/server.cr | src/generators/templates/project_src/src/server.cr | require "./app"
require "colorize"
server = HTTP::Server.new("127.0.0.1", 8080, [
HTTP::ErrorHandler.new,
HTTP::LogHandler.new,
LuckyWeb::RouteHandler.new,
HTTP::StaticFileHandler.new("./public", false),
])
puts "Listening on http://127.0.0.1:8080..."
server.listen
| require "./app"
server = HTTP::Server.new("127.0.0.1", 8080, [
LuckyWeb::HttpMethodOverrideHandler.new,
HTTP::ErrorHandler.new,
HTTP::LogHandler.new,
LuckyWeb::RouteHandler.new,
HTTP::StaticFileHandler.new("./public", false),
])
puts "Listening on http://127.0.0.1:8080..."
server.listen
| Handle PUT and DELETE methods | Handle PUT and DELETE methods
Closes #29
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
c2c65727a0d9f5b55f5116cb6469daee0fc9a311 | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | Add a REST method to send a message | Add a REST method to send a message
| Crystal | mit | meew0/discordcr |
b76b636effcf88370930ccadf57fbac40edd65a5 | crystal/main.cr | crystal/main.cr | require "./sdl.cr/src/sdl"
require "./sdl.cr/src/image"
SDL.init(SDL::Init::VIDEO)
at_exit { SDL.quit }
window = SDL::Window.new("Hello, World!", 620, 387)
SDL::IMG.init(SDL::IMG::Init::PNG)
at_exit { SDL::IMG.quit }
png = SDL::IMG.load(File.join(__DIR__, "..", "img", "grumpy-cat.png"))
png = png.convert(window.surf... | require "./sdl.cr/src/sdl"
require "./sdl.cr/src/image"
SDL.init(SDL::Init::VIDEO)
at_exit { SDL.quit }
window = SDL::Window.new("Hello, World!", 620, 387)
SDL::IMG.init(SDL::IMG::Init::PNG)
at_exit { SDL::IMG.quit }
png = SDL::IMG.load(File.join(__DIR__, "..", "img", "grumpy-cat.png"))
png = png.convert(window.surf... | Update the Crystal example for Crystal 0.31.0 | Update the Crystal example for Crystal 0.31.0
| Crystal | mit | xyproto/hello_sdl2,xyproto/hello_sdl2,xyproto/hello_sdl2,xyproto/hello_sdl2,xyproto/hello_sdl2,xyproto/hello_sdl2,xyproto/hello_sdl2 |
fd6c12e5723169801a9c4a0a14b1f26b5efaf1e1 | src/crow/basic.cr | src/crow/basic.cr | module Crow
module Basic
private def transpile(content : String)
content
end
private def transpile(node : Crystal::NilLiteral)
"undefined"
end
private def transpile(node : Crystal::ASTNode)
transpile node.to_s
end
private def transpile(node : Crystal::Assign)
"#{... | module Crow
module Basic
private def transpile(node : Crystal::ASTNode | String)
node.to_s
end
private def transpile(node : Crystal::NilLiteral)
"undefined"
end
private def transpile(node : Crystal::Assign)
"#{transpile node.target} = #{transpile node.value};"
end
end
end... | Remove redundant transpile(content : String) | Remove redundant transpile(content : String)
| Crystal | mit | geppetto-apps/crow |
646edb24ca3bc4973dd44a650f214a4c7e9c65a3 | src/kemal/init_handler.cr | src/kemal/init_handler.cr | module Kemal
# Kemal::InitHandler is the first handler thus initializes the context with default values such as
# Content-Type, X-Powered-By.
class InitHandler < HTTP::Handler
INSTANCE = new
def call(context)
context.response.content_type = "text/html"
context.response.headers.add "X-Powered-... | module Kemal
# Kemal::InitHandler is the first handler thus initializes the context with default values such as
# Content-Type, X-Powered-By.
class InitHandler < HTTP::Handler
INSTANCE = new
def call(context)
context.response.headers.add "X-Powered-By", "Kemal"
call_next context
context... | Set Content-Type after call_next in Kemal::InitHandler | Set Content-Type after call_next in Kemal::InitHandler
| Crystal | mit | sdogruyol/kemal,kemalcr/kemal,sdogruyol/kemal |
90be9c0fab90362886ab671874599518a4628c2f | src/raven/integrations/kemal/exception_handler.cr | src/raven/integrations/kemal/exception_handler.cr | require "http"
module Raven
module Kemal
# Exception handler capturing all unhandled `Exception`s.
# After capturing exception is re-raised.
#
# ```
# Kemal.config.add_handler(Raven::Kemal::ExceptionHandler.new)
# # ...
# Kemal.run
# ```
class ExceptionHandler
include HTTP::... | require "http"
module Raven
module Kemal
# Exception handler capturing all unhandled `Exception`s.
# After capturing exception is re-raised.
#
# ```
# Kemal.config.add_handler(Raven::Kemal::ExceptionHandler.new)
# # ...
# Kemal.run
# ```
class ExceptionHandler
include HTTP::... | Send username provided by kemalcr/kemal-basic-auth | Send username provided by kemalcr/kemal-basic-auth
| Crystal | mit | Sija/raven.cr |
4049b3eee79868807dc8dc4ff50dbf05ca432d50 | src/generators/asset_compiler.cr | src/generators/asset_compiler.cr | class LuckyCli::Generators::AssetCompiler
include LuckyCli::GeneratorHelpers
def initialize(@project_name : String)
@project_dir = File.join(@project_name)
@template_dir = File.join(__DIR__, "templates")
end
def self.run(project_name : String)
puts "Adding brunch config and static asset directorie... | class LuckyCli::Generators::AssetCompiler
include LuckyCli::GeneratorHelpers
def initialize(@project_name : String)
@project_dir = File.join(@project_name)
@template_dir = File.join(__DIR__, "templates")
end
def self.run(project_name : String)
puts "Adding brunch config and static asset directorie... | Remove accidentally included webpack dep | Remove accidentally included webpack dep
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
6525769e427f010b1e07efab66872eada6aac09c | kernel/src/lib/pointer.cr | kernel/src/lib/pointer.cr | struct Pointer(T)
def +(other : Int)
self + other.to_i64
end
def -(other : Int)
self - other.to_i64
end
def ==(other : Int)
self == other.to_i64
end
def ==(other : Pointer(_))
self == other
end
def [](offset : Int) : T
(self + offset).value
end
def []=(offset : Int, value : T)
... | struct Pointer(T)
def +(other : Int)
self + other.to_i64
end
def -(other : Int)
self - other.to_i64
end
def <(other : Pointer(_))
self < other
end
def >(other : Pointer(_))
self > other
end
def ==(other : Int)
self == other.to_i64
end
def ==(other : Pointer(_))
self == othe... | Add <, > and to_byte_ptr functions to Pointer | Add <, > and to_byte_ptr functions to Pointer
| Crystal | mit | TheKernelCorp/NuummiteOS |
abd7376da95ceae688e1921896475166b74ed24a | src/discordcr/mappings/user.cr | src/discordcr/mappings/user.cr | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: String
)
end
struct UserGuild
JSON.mapping(
id: {type: UInt64, converter: SnowflakeConverter},
name:... | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: String,
email: String?
)
end
struct UserGuild
JSON.mapping(
id: {type: UInt64, converter: SnowflakeC... | Add a nilable email field to the User mapping (for OAuth2) | Add a nilable email field to the User mapping (for OAuth2)
| Crystal | mit | meew0/discordcr |
2925dd45827f8f9a8c8df38cb0554f1c285737b1 | src/amethyst/http/params.cr | src/amethyst/http/params.cr | class Params
getter :hash
def initialize(default="")
@params = Hash(String, String).new(default)
end
def hash
@params
end
def merge(other : Params)
merged_hash = @params.merge other.hash
merged_params = Params.new
merged_params.from_hash(merged_hash)
merged_params
end
def [](key)
@params[key.t... | class Params
getter :hash
def initialize(default="")
@params = Hash(String, String).new(default)
end
def hash
@params
end
def merge(other : Params)
merged_hash = @params.merge other.hash
merged_params = Params.new
merged_params.from_hash(merged_hash)
merged_params
end
def [](key)
@params[key.t... | Add to_s method for Params | Add to_s method for Params
| Crystal | mit | trapped/amethyst |
2092114996b4b6b53b932b2ee6829154f3ee8aef | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | Use `response.body` instead of `body_io` as the JSON source | Use `response.body` instead of `body_io` as the JSON source
Otherwise it will crash with a failed nil assertion.
| Crystal | mit | meew0/discordcr |
9c46c7197d000110b5340d67a990ac7aadc70d31 | kernel/src/lib/pointer.cr | kernel/src/lib/pointer.cr | struct Pointer(T)
def +(other : Int)
self + other.to_i64
end
def -(other : Int)
self - other.to_i64
end
def <(other : Pointer(_))
self < other
end
def >(other : Pointer(_))
self > other
end
def ==(other : Int)
self == other.to_i64
end
def ==(other : Pointer(_))
self == othe... | struct Pointer(T)
def self.null
new(0_u64)
end
def +(other : Int)
self + other.to_i64
end
def -(other : Int)
self - other.to_i64
end
def <(other : Pointer(_))
self < other
end
def >(other : Pointer(_))
self > other
end
def ==(other : Int)
self == other.to_i64
end
def ==... | Fix Pointer(T).null? and add Pointer(T).null | Fix Pointer(T).null? and add Pointer(T).null
| Crystal | mit | TheKernelCorp/NuummiteOS |
f715f31da5a4ac71ad25424234e7ed5302111bcb | src/redis2ws.cr | src/redis2ws.cr | #require "./redis2ws/*"
require "kemal"
require "redis"
module Redis2ws
SOCKETS = [] of HTTP::WebSocket
#run redis subscriber in its own fiber
spawn do
redis = Redis.new
redis.subscribe("mychannel") do |on|
on.message do |channel, message|
puts message
SOCKETS.each { |socket| soc... | #require "./redis2ws/*"
require "kemal"
require "redis"
module Redis2ws
SOCKETS = [] of HTTP::WebSocket # which type are the objects in this empty list :O
#run redis subscriber in its own fiber
spawn do
redis = Redis.new
redis.subscribe("mychannel") do |on|
on.message do |channel, message|
... | Change endpoints in the app to use the /public directory | Change endpoints in the app to use the /public directory
| Crystal | mit | WJWH/redis2ws,WJWH/redis2ws |
330e7b7e8baac751013876958de76163594cfffe | src/discordcr/mappings/user.cr | src/discordcr/mappings/user.cr | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: String,
email: String?
)
end
struct UserGuild
JSON.mapping(
id: {type: UInt64, converter: SnowflakeC... | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: String,
email: String?,
bot: Bool?
)
end
struct UserGuild
JSON.mapping(
id: {type: UInt64, con... | Add a nilable bot field to User (for bot accounts) | Add a nilable bot field to User (for bot accounts)
| Crystal | mit | meew0/discordcr |
97cd4309b9326c18723152def9e65bbb933c3317 | src/discordcr/mappings/user.cr | src/discordcr/mappings/user.cr | require "./converters"
module Discord
# :nodoc:
def initialize(partial : PartialUser)
@username = partial.username.not_nil!
@id = partial.id
@discriminator = partial.discriminator.not_nil!
@avatar = partial.avatar
@email = partial.email
@bot = partial.bot
end
struct User
JSON.mappi... | require "./converters"
module Discord
struct User
# :nodoc:
def initialize(partial : PartialUser)
@username = partial.username.not_nil!
@id = partial.id
@discriminator = partial.discriminator.not_nil!
@avatar = partial.avatar
@email = partial.email
@bot = partial.bot
e... | Make sure to put the User initializer at the correct place... | Make sure to put the User initializer at the correct place...
| Crystal | mit | meew0/discordcr |
0e5789d0d0f3df803e3c8dff62f958d34fab1806 | src/nekogirls.cr | src/nekogirls.cr | require "./nekogirls-cr/*"
require "kemal"
Kemal.config.port = 8080
Kemal.config.public_folder = "./src/public/"
module Nekogirls
get "/" do
"Hello World"
end
get "/upload" do
render "src/views/form.ecr"
end
post "/upload" do |env|
file = env.params.files["file_to_upload"]
filename = file.... | require "./nekogirls-cr/*"
require "kemal"
Kemal.config.port = 8080
Kemal.config.public_folder = "./src/public/"
module Nekogirls
get "/" do
"Hello World"
end
get "/upload" do
render "src/views/form.ecr"
end
post "/upload" do |env|
file = env.params.files["file_to_upload"]
filename = file.... | Return HTTP error 400 if the filename is broken | Return HTTP error 400 if the filename is broken
| Crystal | mit | Cyan101/nekogirls-cr |
ec05fe226aae7c2a7258d5cbb2cc08ac1c2a3986 | spec/spec_helper.cr | spec/spec_helper.cr | require "spec2"
require "../src/m3u8"
include Spec2::GlobalDSL
| require "spec2"
require "../src/m3u8"
include Spec2::GlobalDSL
Spec2.configure_reporter(Spec2::Reporters::Doc)
| Use spec2 doc reporter for specs | chore: Use spec2 doc reporter for specs
| Crystal | mit | marceloboeira/m3u8,marceloboeira/m3u8 |
af714197fdc7741d11e66818dad4b3ac7c77cb86 | src/soil/http/main_handler.cr | src/soil/http/main_handler.cr | module Soil
module Http
module Handlers
class MainHandler
include HTTP::Handler
def initialize(app_class : App.class)
@app_class = app_class
end
def call(raw_context)
context = build_context(raw_context)
@app_class
.find(context.req... | module Soil
module Http
module Handlers
class MainHandler
include HTTP::Handler
def initialize(app_class : App.class)
@app_class = app_class
end
def call(raw_context)
context = build_context(raw_context)
@app_class
.find(context.re... | Check if next handler is present before calling it or a 404 will be triggered by Crystal | Check if next handler is present before calling it or a 404 will be triggered by Crystal
| Crystal | mit | joaodiogocosta/soil |
af8ac172159d7285afea9ac5645a7ab7f78bdd93 | src/liquid/filters/strip_newlines.cr | src/liquid/filters/strip_newlines.cr | require "./base"
module Liquid::Filters
# strip_newlines
#
# Removes any newline characters (line breaks) from a string.
#
# Input
# {% capture string_with_newlines %}
# Hello
# there
# {% endcapture %}
#
# {{ string_with_newlines | newline_to_br }}
#
# Output
# Hellothere
class StripNe... | require "./base"
module Liquid::Filters
# strip_newlines
#
# Removes any newline characters (line breaks) from a string.
#
# Input
# {% capture string_with_newlines %}
# Hello
# there
# {% endcapture %}
#
# {{ string_with_newlines | strip_newlines }}
#
# Output
# Hellothere
class StripN... | Fix wrong filter name in filter documentation | Fix wrong filter name in filter documentation
| Crystal | mit | TechMagister/liquid.cr |
c67affa9de2c83de76800bc9c42abf6a0e8e08fd | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | Add a TODO to remind me of the body_io problem | Add a TODO to remind me of the body_io problem
| Crystal | mit | meew0/discordcr |
19d4b81b9f5bf9f5475e38b58a08c178380a2ce1 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | Make sure to convert the heartbeat_interval to an int | Make sure to convert the heartbeat_interval to an int
| Crystal | mit | meew0/discordcr |
4daa57786af3d80fbcc0af55416464456cd49b16 | src/web_app_skeleton/config/route_helper.cr | src/web_app_skeleton/config/route_helper.cr | # This is used when generating URLs for your application
Lucky::RouteHelper.configure do |settings|
if Lucky::Env.production?
# Example: https://my_app.com
settings.base_uri = ENV.fetch("APP_DOMAIN")
else
# Set domain to the default host/port in development/test
settings.base_uri = "http://#{Lucky::... | # This is used when generating URLs for your application
Lucky::RouteHelper.configure do |settings|
if Lucky::Env.production?
# Example: https://my_app.com
settings.base_uri = ENV.fetch("APP_DOMAIN")
else
# Set domain to the default host/port in development/test
settings.base_uri = "http://localhost... | Use localhost for the RouteHelper | Use localhost for the RouteHelper
This is what you want most of the time, especially when using for callback Urls with OAuth apps | Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
7af6f6f5a1e27fc00008a763046170ec5ab3beb4 | src/charly/visitors/DumpVisitor.cr | src/charly/visitors/DumpVisitor.cr | require "./TreeVisitor.cr"
module Charly::AST
# Dump a human-readable version of the AST
class DumpVisitor < TreeVisitor
# Catch all rule
visit ASTNode do
io.puts name node
rest children
end
visit StringLiteral do
io << name node
io << " | "
io.puts "\"#{node.value}... | require "./TreeVisitor.cr"
module Charly::AST
# Dump a human-readable version of the AST
class DumpVisitor < TreeVisitor
# Catch all rule
visit ASTNode do
io.puts name node
rest children
end
visit StringLiteral do
io << name node
io << " | "
io.puts "\"#{node.value}... | Append newline after nodes with children | Append newline after nodes with children
Signed-off-by: Leonard Schuetz <0a869347170afd1ee7c6a6a90d899177d625e0cf@me.com>
| Crystal | mit | KCreate/charly-lang,charly-lang/charly |
ea8cbf2fbdf2f5ca94c1f227eb74e3a85968dca9 | src/crustache/indent_io.cr | src/crustache/indent_io.cr | require "./parser"
# :nodoc:
class Crustache::IndentIO < IO
def initialize(@indent : String, @io : IO)
@indent_flag = 0
@eol_flag = true
end
def indent_flag_on
@indent_flag -= 1
end
def indent_flag_off
@indent_flag += 1
end
def read(s : Slice(UInt8))
raise "Unsupported"
end
d... | require "./parser"
# :nodoc:
class Crustache::IndentIO < IO
def initialize(@indent : String, @io : IO)
@indent_flag = 0
@eol_flag = true
end
def indent_flag_on
@indent_flag -= 1
end
def indent_flag_off
@indent_flag += 1
end
def read(s : Slice(UInt8))
raise "Unsupported"
end
{%... | Fix return type restriction since Crystal 0.35.0 | Fix return type restriction since Crystal 0.35.0
Fix #27
| Crystal | mit | MakeNowJust/crustache |
9d90400dfe433cdc7afec49f504b9325ce9977b6 | src/raven/breadcrumbs/logger.cr | src/raven/breadcrumbs/logger.cr | require "logger"
class Logger
private LOGGER_BREADCRUMB_LEVELS = {
Severity::DEBUG => Raven::Breadcrumb::Severity::DEBUG,
Severity::INFO => Raven::Breadcrumb::Severity::INFO,
Severity::WARN => Raven::Breadcrumb::Severity::WARNING,
Severity::ERROR => Raven::Breadcrumb::Severity::ERROR,
Severity:... | require "logger"
class Logger
private LOGGER_BREADCRUMB_LEVELS = {
Severity::DEBUG => Raven::Breadcrumb::Severity::DEBUG,
Severity::INFO => Raven::Breadcrumb::Severity::INFO,
Severity::WARN => Raven::Breadcrumb::Severity::WARNING,
Severity::ERROR => Raven::Breadcrumb::Severity::ERROR,
Severity:... | Fix `Logger.deansify` not accepting types other than String | Fix `Logger.deansify` not accepting types other than String
| Crystal | mit | Sija/raven.cr |
346a6f39b422c5cb5be93d4f4c2fe12b40bc9eed | src/discordcr/client.cr | src/discordcr/client.cr | module Discordcr
class Client
def initialize(@token : String, @client_id : UInt64)
end
def run
end
end
end
| require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
end
end
end
| Include the REST module in Client | Include the REST module in Client
| Crystal | mit | meew0/discordcr |
e6faaca1a2469054e3dc8b040f25f095454c74bd | src/discordcr/mappings.cr | src/discordcr/mappings.cr | require "json"
module Discordcr
module REST
# A response to the Get Gateway REST API call.
struct GatewayResponse
JSON.mapping (
url: String
)
end
end
end
| require "json"
module Discordcr
module REST
# A response to the Get Gateway REST API call.
struct GatewayResponse
JSON.mapping(
url: String
)
end
end
end
| Fix an errant space in the mapping definition | Fix an errant space in the mapping definition
| Crystal | mit | meew0/discordcr |
6eb069ba9acfe578c8540028449ff9c7eb81225f | src/raven/processors/remove_circular_references.cr | src/raven/processors/remove_circular_references.cr | module Raven
class Processor::RemoveCircularReferences < Processor
def process(data, visited = [] of UInt64)
return data unless data.responds_to? :object_id
return "(...)" if visited.includes? data.object_id
case data
when AnyHash::JSON
visited << data.to_h.object_id
data.... | module Raven
class Processor::RemoveCircularReferences < Processor
def process(data, visited = [] of UInt64)
return data unless data.responds_to? :object_id
return "(...)" if visited.includes? data.object_id
case data
when AnyHash::JSON
visited << data.to_h.object_id
data.... | Fix RemoveCircularReferences to play nice with types | Fix RemoveCircularReferences to play nice with types
| Crystal | mit | Sija/raven.cr |
ed9386deaa5bb1ee1aa1fdfb42f70180ec0ca8d7 | src/amethyst/exceptions/http_exceptions.cr | src/amethyst/exceptions/http_exceptions.cr | module Amethyst
module Exceptions
class HttpException < AmethystException
getter :status
getter :msg
def initialize(@status, @msg)
super()
end
end
class UnknownContentType < AmethystException
def initialize(@ext)
super("Unknown content-type for file extensi... | module Amethyst
module Exceptions
class HttpException < AmethystException
getter :status
getter :msg
def initialize(@status, @msg)
super()
end
end
class UnknownContentType < AmethystException
def initialize(@ext : String)
super("Unknown content-type for fil... | Fix wrong argument usage in HTTPExceptions | Fix wrong argument usage in HTTPExceptions
| Crystal | mit | trapped/amethyst |
04d22b6c8d56a76543b67885a6ac6ab226b7c2a6 | src/browser_app_skeleton/src/components/shared/layout_head.cr | src/browser_app_skeleton/src/components/shared/layout_head.cr | class Shared::LayoutHead < BaseComponent
needs page_title : String
needs context : HTTP::Server::Context
def render
head do
utf8_charset
title "My App - #{@page_title}"
css_link asset("css/app.css"), data_turbolinks_track: "reload"
js_link asset("js/app.js"), defer: "true", data_turbo... | class Shared::LayoutHead < BaseComponent
needs page_title : String
needs context : HTTP::Server::Context
def render
head do
utf8_charset
title "My App - #{@page_title}"
css_link asset("css/app.css"), data_turbolinks_track: "reload"
js_link asset("js/app.js"), defer: "true", data_turbo... | Disable turbolinks cache by default | Disable turbolinks cache by default
Closes #357
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
6ab52baca6246f42814b3d4b02ff19d62ff2ec77 | src/cli.cr | src/cli.cr | require "./franklin"
require "option_parser"
config_path = Franklin::Config::DEFAULT_FILE_LOCATION
filter_type = nil
parser = OptionParser.parse! { |parser|
parser.banner = "Usage: frankling [options] search_term1 search_term2..."
parser.on("-h", "--help", "Prints this help") do
puts parser
puts "Frankli... | require "./franklin"
require "option_parser"
config_path = Franklin::Config::DEFAULT_FILE_LOCATION
filter_type = nil
parser = OptionParser.parse! { |parser|
parser.banner = "Usage: frankling [options] search_term1 search_term2..."
parser.on("-h", "--help", "Prints this help") do
puts parser
puts "Frankli... | Add version information on errors | Add version information on errors
| Crystal | mit | ylansegal/franklin.cr |
1304557e3cd4f2d22a5d8881ca2039623dd71a27 | src/web_app_skeleton/src/pages/main_layout.cr | src/web_app_skeleton/src/pages/main_layout.cr | abstract class MainLayout
include Lucky::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
needs flash : Lucky::Flash::Store
abstract def inner
def render
html_doctype
html... | abstract class MainLayout
include Lucky::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
needs flash : Lucky::Flash::Store
abstract def inner
def render
html_doctype
html... | Add CSRF meta tags to layout | Add CSRF meta tags to layout
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
2b7e37ca1181433c292995b8ebfbfda278673dfb | src/discordcr/mappings.cr | src/discordcr/mappings.cr | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
str = parser.read_string_or_null
str.not_nil!.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
module REST
#... | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
str = parser.read_string_or_null
str.not_nil!.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
module REST
#... | Make the type field possibly be nil (apparently it is sometimes) | Make the type field possibly be nil (apparently it is sometimes)
| Crystal | mit | meew0/discordcr |
466151cfdf462940a76f7ef4f67fc1b5ffe241c8 | src/cl.cr | src/cl.cr | require "logger"
# Logger #######################################################################
LOG = Logger.new(STDOUT)
LOG.level = Logger::INFO
LOG.formatter = Logger::Formatter.new do |severity, _datetime, _progname, message, io|
io << case severity
when "DEBUG"
":: "
when "INFO"
">> "
when "WARN... | require "logger"
require "colorize"
# Logger #######################################################################
LOG = Logger.new(STDOUT)
LOG.level = Logger::INFO
LOG.formatter = Logger::Formatter.new do |severity, _datetime, _progname, message, io|
io << case severity
when "DEBUG"
":: ".colorize.white
... | Add colours to log messages | Add colours to log messages
| Crystal | mit | timjs/cl |
4c3357f36dc78a70391e06e17697d572cc0a6792 | src/lib/value_hash.cr | src/lib/value_hash.cr | module Optarg
# :nodoc:
abstract class ValueHash(V) < Hash(String, V)
@fallbacked = {} of String => Bool
@parser : Parser
def initialize(@parser)
super()
end
def [](key)
fallback key
super
end
def []?(key)
fallback key
super
end
def fallback(key)... | module Optarg
# :nodoc:
abstract class ValueHash(V)
@raw = {} of String => V
forward_missing_to @raw
@fallbacked = {} of String => Bool
@parser : Parser
def initialize(@parser)
end
def ==(other : Hash)
@raw == other
end
def [](key)
fallback key
@raw[key]
... | Use Hash composition over inheritance in ValueHash | Use Hash composition over inheritance in ValueHash
| Crystal | mit | mosop/optarg,mosop/optarg |
863623b4924b6aa07b4abeb3b35ed5f33a6ed5ea | src/discordcr/mappings/permissions.cr | src/discordcr/mappings/permissions.cr | module Discord
@[Flags]
enum Permissions : UInt64
CreateInstantInvite = 1
KickMembers = 1 << 1
BanMembers = 1 << 2
Administrator = 1 << 3
ManageChannels = 1 << 4
ManageGuild = 1 << 5
ReadMessages = 1 << 10
SendMessages = 1 << 11
S... | module Discord
@[Flags]
enum Permissions : UInt64
CreateInstantInvite = 1
KickMembers = 1 << 1
BanMembers = 1 << 2
Administrator = 1 << 3
ManageChannels = 1 << 4
ManageGuild = 1 << 5
AddReactions = 1 << 6
ReadMessages = 1 << 10
Se... | Add AddReactions value (1<<6) to Permissions enum | Add AddReactions value (1<<6) to Permissions enum
| Crystal | mit | meew0/discordcr |
310685385e935b42b5df231b1966d823acf7787f | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | require "http/client"
require "openssl/ssl/context"
require "./mappings"
module Discordcr
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
def request(endpoint_key : Symbol, method : String, url : String | URI, headers : HTTP::Headers | Nil, body : String | Nil)
HTTP::Client.exec(method: m... | Use the correct method for the request | Use the correct method for the request
| Crystal | mit | meew0/discordcr |
56e260ac7d044ea43c121d789e6ab02b26d07b4a | src/raven/context.cr | src/raven/context.cr | module Raven
class Context
# FIXME
# @[ThreadLocal]
@@current : self?
def self.current
@@current ||= new
end
def self.clear!
@@current = nil
end
class_getter os_context : AnyHash::JSON do
{
name: Raven.sys_command("uname -s"),
version: ... | module Raven
class Context
# FIXME
# @[ThreadLocal]
@@current : self?
def self.current
@@current ||= new
end
def self.clear!
@@current = nil
end
class_getter os_context : AnyHash::JSON do
{
name: Raven.sys_command("uname -s"),
version: ... | Use `Crystal::DESCRIPTION` instead of spawning `crystal -v` | Use `Crystal::DESCRIPTION` instead of spawning `crystal -v`
Moar efficient, yo
| Crystal | mit | Sija/raven.cr |
f53fe0e190b604fdde345aa36432b2a4f4bf1e1f | src/discordcr/mappings/gateway.cr | src/discordcr/mappings/gateway.cr | require "./converters"
require "./user"
require "./channel"
require "./guild"
module Discord
module Gateway
struct ReadyPayload
JSON.mapping(
v: UInt8,
user: User,
private_channels: Array(PrivateChannel),
guilds: Array(UnavailableGuild),
session_id: String
)
... | require "./converters"
require "./user"
require "./channel"
require "./guild"
module Discord
module Gateway
struct ReadyPayload
JSON.mapping(
v: UInt8,
user: User,
private_channels: Array(PrivateChannel),
guilds: Array(UnavailableGuild),
session_id: String
)
... | Add a mapping for the GUILD_INTEGRATIONS_UPDATE dispatch payload | Add a mapping for the GUILD_INTEGRATIONS_UPDATE dispatch payload
| Crystal | mit | meew0/discordcr |
5591f45de1ec71ef83d0455763614335ea7792ea | crystal-csp/gc-csp.cr | crystal-csp/gc-csp.cr | ch1 = Channel(String).new(16)
gcfile = File.new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
spawn do
gcfile.each_line() do |line|
ch1.send(line)
end
ch1.close
end
at = 0
gc = 0
while line = ch1.receive
if line.starts_with?('>')
next
end
line.each_byte() do |chr|
case chr
when 'A', '... | ch1 = Channel(String).new(16)
gcfile = File.new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
spawn do
gcfile.each_line() do |line|
ch1.send(line)
end
ch1.close
end
at = 0
gc = 0
while line = ch1.receive?
if line.starts_with?('>')
next
end
line.each_byte() do |chr|
case chr
when 'A', ... | Fix receive on closed chan error | Fix receive on closed chan error
| Crystal | mit | samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark |
ff4c74363dbfdf81a124034b5eb30324fe52c1bd | src/raven.cr | src/raven.cr | require "any_hash"
require "./raven/ext/*"
require "./raven/mixins/*"
require "./raven/*"
module Raven
# `Raven.instance` delegators.
module Delegators
delegate :context, :configuration, :client,
:report_status, :configure, :send_feedback, :send_event,
:capture, :last_event_id, :annotate_exception... | require "any_hash"
require "./raven/ext/*"
require "./raven/mixins/*"
require "./raven/*"
module Raven
# `Raven.instance` delegators.
module Delegators
delegate :context, :configuration, :client,
:report_status, :configure, :send_feedback, :send_event,
:capture, :last_event_id, :annotate_exception... | Simplify logic just a bit | Simplify logic just a bit
| Crystal | mit | Sija/raven.cr |
0e6c091c252691a08c54de598b78787c4841166d | src/lucky_cli/task.cr | src/lucky_cli/task.cr | abstract class LuckyCli::Task
macro inherited
LuckyCli::Runner.tasks << self.new
def name
"{{@type.name.gsub(/::/, ".").underscore}}"
end
end
macro banner(banner_text)
def banner
{{banner_text}}
end
end
# Set a custom title for the task
#
# By default the name is derived... | abstract class LuckyCli::Task
macro inherited
LuckyCli::Runner.tasks << self.new
def name
"{{@type.name.gsub(/::/, ".").underscore}}"
end
end
macro banner(banner_text)
def banner
{{banner_text}}
end
end
# Sets a custom title for the task
#
# By default the name is derive... | Add a newline to separate text from example code | Add a newline to separate text from example code | Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
d4f285e12e99a6fa46e71c80f1ea8b2193ef7169 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = websocket = HTTP::WebSocket.new(URI.parse(url))
websocket.on_mes... | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = websocket = HTTP::WebSocket.new(URI.parse(url))
websocket.on_mes... | Add a rudimentary close handler | Add a rudimentary close handler
| Crystal | mit | meew0/discordcr |
d8feef5204cb6409a853d533610f3c2d577092b6 | src/web_app_skeleton/config/authentic.cr | src/web_app_skeleton/config/authentic.cr | require "./server"
Authentic.configure do
settings.secret_key = Lucky::Server.settings.secret_key_base
unless Lucky::Env.production?
settings.encryption_cost = 4
end
end
| require "./server"
Authentic.configure do
settings.secret_key = Lucky::Server.settings.secret_key_base
unless Lucky::Env.production?
fastest_encryption_possible = 4
settings.encryption_cost = fastest_encryption_possible
end
end
| Clarify what '4' represents in encryption cost | Clarify what '4' represents in encryption cost | Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
a7d2ad0de9b4d0894dd33804255c869b19b8b535 | spec/discordcr_spec.cr | spec/discordcr_spec.cr | require "./spec_helper"
struct StructWithSnowflake
JSON.mapping(
data: {type: UInt64, converter: Discord::SnowflakeConverter}
)
end
describe Discord do
describe Discord::SnowflakeConverter do
it "converts a string to u64" do
json = %({"data":"10000000000"})
obj = StructWithSnowflake.from_js... | require "./spec_helper"
struct StructWithSnowflake
JSON.mapping(
data: {type: UInt64, converter: Discord::SnowflakeConverter}
)
end
struct StructWithMaybeSnowflake
JSON.mapping(
data: {type: UInt64 | Nil, converter: Discord::MaybeSnowflakeConverter}
)
end
describe Discord do
describe Discord::Snowf... | Write a test for MaybeSnowflakeConverter | Write a test for MaybeSnowflakeConverter
| Crystal | mit | meew0/discordcr |
3a34e11a028379652ce10843fbe98c0d14ad381f | src/redis2ws.cr | src/redis2ws.cr | #require "./redis2ws/*"
require "kemal"
require "redis"
module Redis2ws
SOCKETS = [] of HTTP::WebSocket
puts "now here"
get "/" do |ctx|
send_file ctx, "src/web/index.html"
end
get "/app.js" do |ctx|
send_file ctx, "src/web/app.js"
end
ws "/eventstream/" do |socket|
# Add the client to ... | #require "./redis2ws/*"
require "kemal"
require "redis"
module Redis2ws
SOCKETS = [] of HTTP::WebSocket
#run redis subscriber in its own fiber
spawn do
redis = Redis.new
redis.subscribe("mychannel") do |on|
on.message do |channel, message|
puts message
SOCKETS.each { |socket| soc... | Clean up code and comments | Clean up code and comments
| Crystal | mit | WJWH/redis2ws,WJWH/redis2ws |
812e5b0b983d40d23bc922e0ff0619cbe327175b | src/render.cr | src/render.cr | require "ecr/macros"
module Artanis
# TODO: render views in subpaths (eg: views/blog/posts/show.ecr => render_blog_posts_show_ecr)
module Render
macro ecr(name, layout = "layout")
render {{ name }}, "ecr", layout: {{ layout }}
end
macro render(name, engine, layout = "layout")
{% if layout ... | require "ecr/macros"
module Artanis
# TODO: render views in subpaths (eg: views/blog/posts/show.ecr => render_blog_posts_show_ecr)
module Render
macro ecr(name, layout = "layout")
render {{ name }}, "ecr", layout: {{ layout }}
end
macro render(name, engine, layout = "layout")
{% if layout ... | Replace cut command with Crystal code | Replace cut command with Crystal code | Crystal | mit | ysbaddaden/artanis |
ae25d0a7742c4b2fd95d0a0b1acffe59bf388e91 | src/kemal/common_log_handler.cr | src/kemal/common_log_handler.cr | require "http"
class Kemal::CommonLogHandler < Kemal::BaseLogHandler
@handler : IO::FileDescriptor
getter handler
def initialize(@env)
@handler = if @env == "production"
handler = File.new("kemal.log", "a")
handler.flush_on_newline = true
handler
... | require "http"
class Kemal::CommonLogHandler < Kemal::BaseLogHandler
@handler : IO::FileDescriptor
getter handler
def initialize(@env)
@handler = if @env == "production"
handler = File.new("kemal.log", "a")
handler.flush_on_newline = true
handler
... | Optimize CommonLogHandler to directly use the handler instead of string interpolation | Optimize CommonLogHandler to directly use the handler instead of string interpolation
| Crystal | mit | sdogruyol/kemal,sdogruyol/kemal,kemalcr/kemal |
132e25258e35ab219e79de82618640086ab6adcc | src/cli.cr | src/cli.cr | require "commander"
require "logger"
require "./crow.cr"
cli = Commander::Command.new do |cmd|
cmd.use = "crow"
cmd.long = "Transpile Crystal to Flow (JS) code."
cmd.flags.add do |flag|
flag.name = "verbose"
flag.short = "-v"
flag.long = "--verbose"
flag.default = false
flag.description = "... | require "commander"
require "logger"
require "./crow.cr"
cli = Commander::Command.new do |cmd|
cmd.use = "crow"
cmd.long = "Transpile Crystal to Flow (JS) code."
cmd.flags.add do |flag|
flag.name = "version"
flag.short = "-v"
flag.long = "--version"
flag.default = false
flag.description = "... | Replace -v flag with version in CLI | Replace -v flag with version in CLI
| Crystal | mit | geppetto-apps/crow |
ed19081eef4af36faba8f96290c6b63e3cac5078 | src/discordcr/mappings/user.cr | src/discordcr/mappings/user.cr | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: {type: String, nilable: true},
email: {type: String, nilable: true},
bot: {type: Bool, nilable: true}
)
end... | require "./converters"
module Discord
struct User
JSON.mapping(
username: String,
id: {type: UInt64, converter: SnowflakeConverter},
discriminator: String,
avatar: {type: String, nilable: true},
email: {type: String, nilable: true},
bot: {type: Bool, nilable: true}
)
end... | Add a method to PartialUser to check whether it has all data | Add a method to PartialUser to check whether it has all data
Required to check whether a presence update introduces a new member to the
cache.
| Crystal | mit | meew0/discordcr |
3ab631c359dfd06bd7be80e189eeb624fcef66c6 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | Add basic READY handling to the dispatch handler | Add basic READY handling to the dispatch handler
| Crystal | mit | meew0/discordcr |
12ec74e9238db30129e9885ffdfa2c7b9cbeb212 | src/kemal/exceptions.cr | src/kemal/exceptions.cr | module Kemal::Exceptions
class RouteNotFound < Exception
def initialize(context)
super "Requested path: '#{context.request.override_method as String}:#{context.request.path}' was not found."
end
end
class CustomException < Exception
getter context
def initialize(@context)
super "Rend... | module Kemal::Exceptions
class RouteNotFound < Exception
def initialize(context)
super "Requested path: '#{context.request.override_method as String}:#{context.request.path}' was not found."
end
end
class CustomException < Exception
def initialize(context)
super "Rendered error with #{co... | Add instance types for Crystal 0.16.0 | Add instance types for Crystal 0.16.0
| Crystal | mit | sdogruyol/kemal,MGerrior/kemal,sdogruyol/kemal,kemalcr/kemal,MGerrior/kemal |
690e2989a0abc0820fbf5c3e26e67cd08c76e37b | src/discordcr/mappings.cr | src/discordcr/mappings.cr | require "json"
module Discordcr
module Mappings
end
end
| require "json"
module Discordcr
module REST
# A response to the Get Gateway REST API call.
class GatewayResponse
JSON.mapping (
url: String
)
end
end
end
| Create a mapping for the gateway request response | Create a mapping for the gateway request response
| Crystal | mit | meew0/discordcr |
1e6458075aae201d9cec3bbfd6a8501db059b2fc | src/roadshow/cli.cr | src/roadshow/cli.cr | require "colorize"
require "file_utils"
require "option_parser"
require "yaml"
require "./*"
require "./commands/*"
module Roadshow
module CLI
def self.run(stdin, stdout, args) : Int
command = args.shift?
if command
Command.get_command(command).run(stdin, stdout, args)
else
pr... | require "colorize"
require "file_utils"
require "option_parser"
require "yaml"
require "./*"
require "./commands/*"
module Roadshow
module CLI
def self.run(stdin, stdout, args) : Int
command = args.shift?
if command
Command.get_command(command).run(stdin, stdout, args)
else
pr... | Add missing commands to usage | Add missing commands to usage
| Crystal | mit | rf-/roadshow |
32e2ee6a17762d39374215a0509b91411b8bd9b9 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = HTTP::WebSocket.new(URI.parse(url))
@websocket.not_nil!.on_messa... | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = HTTP::WebSocket.new(URI.parse(url))
@websocket.not_nil!.on_messa... | Fix the typing for on_message | Fix the typing for on_message
| Crystal | mit | meew0/discordcr |
0904b85efa06e30c827e0164006433ea66cb8d91 | kernel/src/lib/runtime/exceptions.cr | kernel/src/lib/runtime/exceptions.cr | class Exception
def self.new(message) : NoReturn
panic
end
end
class TypeCastError < Exception
def self.new(message) : NoReturn
super message
end
end
| class Exception
def self.new(message, __file__ = __FILE__, __line__ = __LINE__) : NoReturn
panic message, __file__, __line__
end
end
class TypeCastError < Exception
def self.new(message, __file__ = __FILE__, __line__ = __LINE__) : NoReturn
super message, __file__, __line__
end
end
| Add support for exception messages | Add support for exception messages
Signed-off-by: Splitty <e8820feff88402cc56882fceaf96271e952e1a96@gmail.com>
| Crystal | mit | TheKernelCorp/NuummiteOS |
df2485d50899b5f5af9c2b5b9bb8f2c3014de9e5 | crystal.000/gc.cr | crystal.000/gc.cr | gcfile = File.new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
at = 0
gc = 0
a = 65_u8
t = 84_u8
g = 71_u8
c = 67_u8
gcfile.each_line() do |line|
if line.starts_with?('>')
next
end
line.each_byte() do |c|
case c
when a, t
at += 1
next
when g, c
gc += 1
next
end
... | gcfile = File.new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
at = 0
gc = 0
a = 65_u8
t = 84_u8
g = 71_u8
c = 67_u8
gcfile.each_line() do |line|
if line.starts_with?('>')
next
end
line.each_byte() do |chr|
case chr
when a, t
at += 1
next
when g, c
gc += 1
next
e... | Fix bug in Crystal code | Fix bug in Crystal code
| Crystal | mit | samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark,samuell/gccontent-benchmark |
838079471948036e1d3dcd6476e2d91026099601 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | require "http/web_socket"
require "json"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = URI.parse(gateway.url)
@websocket = websocket = HTTP::WebSocket.new(
host: url.host.not_nil!,
path... | Return nil from on_message to satisfy the compiler | Return nil from on_message to satisfy the compiler
| Crystal | mit | meew0/discordcr |
5ddc56e4869d837311e521f4a8c25b3b4f642e0f | src/amber/router/session/abstract_store.cr | src/amber/router/session/abstract_store.cr | module Amber::Router::Session
# All Session Stores should implement the following API
abstract class AbstractStore
abstract def id
abstract def destroy
abstract def update(other_hash : Hash(String | Symbol, String))
abstract def set_session
abstract def current_session
end
end
| module Amber::Router::Session
# All Session Stores should implement the following API
abstract class AbstractStore
abstract def id
abstract def destroy
abstract def update(hash : Hash(String | Symbol, String))
abstract def set_session
abstract def current_session
end
end
| Fix naming warning raised by crystal compiler about positional names being mismatched | Fix naming warning raised by crystal compiler about positional names being mismatched
| Crystal | mit | amberframework/amber,amberframework/amber,amberframework/amber |
c0992f9a6084bf5fb97fdfa7c57dbea7a493b9e9 | majority_element_cr.cr | majority_element_cr.cr | def majority_element(elements)
counts = elements.each_with_object(Hash(String, Int32).new(0)) do |element, collector|
collector[element] += 1
collector
end
result = counts.map do |element, count|
count > elements.count / 2 ? element : nil
end.compact
if result.count == 0
return nil
elsif r... | def majority_element(elements)
counts = elements.each_with_object(Hash(String, Int32).new(0)) do |element, collector|
collector[element] += 1
collector
end
result = counts.map do |element, count|
count > elements.size / 2 ? element : nil
end.compact
if result.size == 0
return nil
elsif res... | Upgrade crystal (needed it to compare output against Clojure code). | Upgrade crystal (needed it to compare output against Clojure code).
| Crystal | mit | dahofer/majority-element,dahofer/majority-element,dkhofer/majority-element,dkhofer/majority-element,dkhofer/majority-element,dkhofer/majority-element,dahofer/majority-element,dahofer/majority-element |
dbe11b34a9c6f280cc30613456012f7217c037ff | src/discordcr/mappings.cr | src/discordcr/mappings.cr | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
str = parser.read_string_or_null
str.not_nil!.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
module REST
#... | require "json"
require "time/format"
module Discord
module SnowflakeConverter
def self.from_json(parser : JSON::PullParser) : UInt64
str = parser.read_string_or_null
str.not_nil!.to_u64
end
def self.to_json(value : UInt64, io : IO)
io.puts(value.to_s)
end
end
module REST
#... | Add a mapping for permission overwrites | Add a mapping for permission overwrites
| Crystal | mit | meew0/discordcr |
eb384c34ba415312bec464662d4838ace7818723 | src/raven/client_state.cr | src/raven/client_state.cr | module Raven
class Client::State
enum Status
ONLINE
ERROR
end
@status : Status
@retry_number : Int32
@last_check : Time?
@retry_after : Time::Span?
def initialize
@status = Status::ONLINE
@retry_number = 0
end
def should_try?
return true if @status.... | module Raven
class Client::State
enum Status
ONLINE
ERROR
end
@status : Status
@retry_number : Int32
@last_check : Time?
@retry_after : Time::Span?
def initialize
@status = Status::ONLINE
@retry_number = 0
end
def should_try?
return true if @status.... | Fix Client::State exponential backoff logic | Fix Client::State exponential backoff logic
| Crystal | mit | Sija/raven.cr |
10d309f17455d2aad2da15b13261a7b3bcedeba6 | src/mnd/platforms.cr | src/mnd/platforms.cr | module Mnd
PLATFORMS = {
"prime" => [
Repo.new("mynewsdesk", color: :cyan),
Repo.new("social-media-monitor", color: :green),
Repo.new("mnd-audience", color: :light_cyan, alias: "audience"),
Repo.new("mnd-langdetect", color: :light_yellow),
Repo.new("audience-api", color: :yellow),
... | module Mnd
PLATFORMS = {
"prime" => [
Repo.new("audience-api", color: :yellow),
Repo.new("mnd-audience", color: :light_cyan, alias: "audience"),
Repo.new("mnd-events-api", color: :yellow, alias: "events-api"),
Repo.new("mnd-langdetect", color: :light_yellow, alias: "langdetect"),
Rep... | Sort platform repos and add aliases | Sort platform repos and add aliases | Crystal | mit | mynewsdesk/mnd-dev,mynewsdesk/mnd-dev |
11549cc9e192d3eb2adb811246e9e3aab43f8c8e | kernel/src/lib/pointer.cr | kernel/src/lib/pointer.cr | struct Pointer(T)
def +(other : Int)
self + other.to_i64
end
def [](offset : Int) : T
self.value
end
def []=(offset : Int, value : T)
(self + offset).value = value
end
end | struct Pointer(T)
def +(other : Int)
self + other.to_i64
end
def [](offset : Int) : T
(self + offset).value
end
def []=(offset : Int, value : T)
(self + offset).value = value
end
end | Fix [] operator on Pointer(T) | Fix [] operator on Pointer(T)
| Crystal | mit | TheKernelCorp/NuummiteOS |
ac1254bdee50f83e26917c639790b2935da65d4d | kernel/src/lib/hal/pit.cr | kernel/src/lib/hal/pit.cr | private PIT_CH0_DATA = 0x40_u16
private PIT_CH1_DATA = 0x41_u16
private PIT_CH2_DATA = 0x42_u16
private PIT_COMMAND = 0x43_u16
private PIT_FREQ = 1193182_u32
struct PIT
@@ticks = 0_u64
@@divisor = 0_u32
@@frequency = 0_u32
def self.setup(frequency : Int)
divisor = PIT_FREQ / frequency
outb PIT_COMMAND... | private PIT_CH0_DATA = 0x40_u16
private PIT_CH1_DATA = 0x41_u16
private PIT_CH2_DATA = 0x42_u16
private PIT_COMMAND = 0x43_u16
private PIT_FREQ = 1193182_u32
module PIT
extend self
@@ticks = 0_u64
@@divisor = 0_u32
@@frequency = 0_u32
def setup(frequency : Int)
divisor = PIT_FREQ / frequency
outb P... | Change the PIT struct to a module | Change the PIT struct to a module
Signed-off-by: Splitty <e8820feff88402cc56882fceaf96271e952e1a96@gmail.com>
| Crystal | mit | TheKernelCorp/NuummiteOS |
ed9ba3a5371c257619b54f31548820f32ea6b5d7 | src/raven/integrations/lucky/error_handler.cr | src/raven/integrations/lucky/error_handler.cr | require "http"
require "../http/*"
module Raven
module Lucky
# Exception handler capturing all unhandled `Exception`s.
# After capturing exception is re-raised.
#
# ```
# server = HTTP::Server.new([
# # ...
# Lucky::ErrorHandler.new(action: Errors::Show),
# Raven::Lucky::ErrorHa... | require "http"
require "../http/*"
module Raven
module Lucky
# Exception handler capturing all unhandled `Exception`s.
# After capturing exception is re-raised.
#
# ```
# server = HTTP::Server.new([
# # ...
# Lucky::ErrorHandler.new(action: Errors::Show),
# Raven::Lucky::ErrorHa... | Add missing `.new` call in Lucky::ErrorHandler docs | Add missing `.new` call in Lucky::ErrorHandler docs
| Crystal | mit | Sija/raven.cr |
e361b84af14c1782373d7f864c1050bb4f4db0eb | src/web_app_skeleton/src/pages/main_layout.cr | src/web_app_skeleton/src/pages/main_layout.cr | abstract class MainLayout
include Lucky::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
abstract def content
def render
html_doctype
html lang: "en" do
head do
... | abstract class MainLayout
include Lucky::HTMLPage
include Shared::FieldErrorsComponent
include Shared::FlashComponent
# You can put things here that all pages need
#
# Example:
# needs current_user : User
abstract def content
def render
html_doctype
html lang: "en" do
head do
... | Include the responsive_meta_tag by default in the main layout | Include the responsive_meta_tag by default in the main layout
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
04aed629b598a35d860b70275f41cc4d8639bba3 | src/discordcr/client.cr | src/discordcr/client.cr | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = HTTP::WebSocket.new(URI.parse(url))
end
private def on_messag... | require "http/web_socket"
require "./rest"
module Discordcr
class Client
include REST
def initialize(@token : String, @client_id : UInt64)
end
def run
url = gateway.url
url += "?v=6&encoding=json"
@websocket = HTTP::WebSocket.new(URI.parse(url))
@websocket.on_message(->on_m... | Fix the typing of the on_message call | Fix the typing of the on_message call
| Crystal | mit | meew0/discordcr |
2ccfe09d2fecc31e2e6750de3861b723c4381797 | src/messenger-bot/graph_api.cr | src/messenger-bot/graph_api.cr | module Messenger::Bot
# A wrapper for Facebook's Graph API
class GraphAPI
# Build an API instance with which you can send messages.
# Pass *api_version* (current is 2.6) an *access_token*, which you need to
# authenticate yourself to the Graph API
def initialize(@api_version : String, @access_token ... | module Messenger::Bot
# A wrapper for Facebook's Graph API
class GraphAPI
# Build an API instance with which you can send messages.
# Pass *api_version* (current is 2.6) an *access_token*, which you need to
# authenticate yourself to the Graph API
def initialize(@api_version : String, @access_token ... | Print Graph API error in rescue block | Print Graph API error in rescue block
| Crystal | mit | zmalltalker/crystal-messenger-bot |
909565ddd251bebf86f78e2bc546eb508edeca8b | src/scry/protocol/initialize_params.cr | src/scry/protocol/initialize_params.cr | require "json"
module Scry
struct InitializeParams
JSON.mapping({
process_id: {type: Int64 | Int32, key: "processId"},
root_uri: {type: String, key: "rootPath"},
capabilities: JSON::Any,
trace: String,
})
end
end
| require "json"
module Scry
struct InitializeParams
JSON.mapping({
process_id: {type: Int64 | Int32, key: "processId"},
root_uri: {type: String, key: "rootPath"},
capabilities: JSON::Any,
trace: String?,
})
end
end
| Allow trace to be nilable. | Allow trace to be nilable.
This ensures compatibility with Atom and is more accurate to LSP
| Crystal | mit | crystal-lang-tools/scry |
fca26bfb0dc98e5eb25ded0bec91c16b2c5b60b8 | src/charly/gc_warning.cr | src/charly/gc_warning.cr | lib LibGC
alias WarnProc = LibC::Char*, Word ->
fun set_warn_proc = GC_set_warn_proc(WarnProc)
$warn_proc = GC_current_warn_proc : WarnProc
end
LibGC.set_warn_proc ->(msg, word) {
# Ignore the message in production builds
{% unless flag?(:release) %}
puts String.new(msg)
{% end %}
}
| lib LibGC
alias WarnProc = LibC::Char*, Word ->
fun set_warn_proc = GC_set_warn_proc(WarnProc)
$warn_proc = GC_current_warn_proc : WarnProc
end
LibGC.set_warn_proc ->(msg, word) {
# Ignore the message
}
| Hide GC warnings in all builds | Hide GC warnings in all builds
| Crystal | mit | charly-lang/charly,KCreate/charly-lang |
48ff82f562e9310f8f4a0b3534fb57de263de8e6 | src/generators/webpack.cr | src/generators/webpack.cr | class LuckyCli::Generators::Webpack
include LuckyCli::GeneratorHelpers
def initialize(@project_name : String)
@project_dir = File.join(@project_name)
@template_dir = File.join(__DIR__, "templates")
end
def self.run(project_name : String)
puts "Adding webpacker config and asset directories"
new... | class LuckyCli::Generators::Webpack
include LuckyCli::GeneratorHelpers
def initialize(@project_name : String)
@project_dir = File.join(@project_name)
@template_dir = File.join(__DIR__, "templates")
end
def self.run(project_name : String)
puts "Adding webpacker config and asset directories"
new... | Install turbolinks and rails-ujs by default | Install turbolinks and rails-ujs by default
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
b680a9d1f77badb2ba163b09bfb5891106e689ba | kernel/src/lib/int.cr | kernel/src/lib/int.cr | struct Int
def <<(count) unsafe_shl count end
def >>(count) unsafe_shr count end
def ===(other : Int) self == other end
def /(other : Int)
if other == 0
self
end
unsafe_div other
end
def times
i = 0
while i < self
yield i
... | struct Int
def <<(count) unsafe_shl count end
def >>(count) unsafe_shr count end
def ===(other : Int) self == other end
def /(other : Int)
if other == 0
self
end
unsafe_div other
end
def %(other : Int)
if other == 0
self
end
... | Add % override to Int | Add % override to Int
| Crystal | mit | TheKernelCorp/NuummiteOS |
95a944abf0ec6febc4d721bd5edaa3120a871817 | src/controllers/home_controller.cr | src/controllers/home_controller.cr | require "kemal"
require "kemal-session"
module Vulnsearch
class HomeController
get "/" do |env|
query = env.params.query.fetch("q", "")
render_default "home/index"
end
get "/search" do |env|
query = env.params.query.fetch("q", "")
like_query = "%#{query}%"
cves = Cve.from_r... | require "kemal"
require "kemal-session"
module Vulnsearch
class HomeController
get "/" do |env|
query = env.params.query.fetch("q", "")
render_default "home/index"
end
get "/search" do |env|
query = env.params.query.fetch("q", "")
like_query = "%#{query}%"
cves = Cve.from_r... | Order default by id for now | Order default by id for now
| Crystal | mit | t-richards/vulnsearch,t-richards/vulnsearch |
7222b92155e9272c42a67c57ac851ecaad284d6d | src/mocks/have_received_expectation.cr | src/mocks/have_received_expectation.cr | module Mocks
class HaveReceivedExpectation
def initialize(@receive)
end
def match(@target)
method.received?(oid, @receive.args)
end
def failure_message
"expected: #{expected}\n got: #{got}"
end
def negative_failure_message
"expected: receive != #{expected}\n go... | module Mocks
class HaveReceivedExpectation
def initialize(@receive)
end
def match(@target)
method.received?(oid, @receive.args)
end
def failure_message
"expected: #{expected}\n got: #{got}"
end
def failure_message(_ignored)
failure_message
end
def negative... | Upgrade to a newer version of matcher protocol | Upgrade to a newer version of matcher protocol
| Crystal | mit | waterlink/mocks.cr |
083b64eccad96f95c0c3b1bd1aa0abe7223e5a87 | spec/files/incorrect_method_type.cr | spec/files/incorrect_method_type.cr | def accepts_int(int: Int)
puts int
end
accepts_int("Not a String.")
| def accepts_int(int : Int)
puts int
end
accepts_int("Not a String.")
| Fix method type spec so it returns the correct error. | Fix method type spec so it returns the correct error.
| Crystal | mit | AtomLinter/linter-crystal,atom-crystal/linter-crystal |
34507b5e3631f67b38f5c22902d995053437302a | src/discordcr/rest.cr | src/discordcr/rest.cr | require "http/client"
require "openssl/ssl/context"
require "./mappings/*"
require "./version"
module Discord
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
USER_AGENT = "DiscordBot (https://github.com/meew0/discordcr, #{Discord::VERSION})"
API_BASE = "https://discordapp.com/api/v6"
d... | require "http/client"
require "openssl/ssl/context"
require "./mappings/*"
require "./version"
module Discord
module REST
SSL_CONTEXT = OpenSSL::SSL::Context::Client.new
USER_AGENT = "DiscordBot (https://github.com/meew0/discordcr, #{Discord::VERSION})"
API_BASE = "https://discordapp.com/api/v6"
d... | Add a method for the get channel endpoint | Add a method for the get channel endpoint
| Crystal | mit | meew0/discordcr |
6c7daab7c7d3e3d7394a32faa2afc2161e7e70cc | src/discordcr/mappings/gateway.cr | src/discordcr/mappings/gateway.cr | require "./converters"
require "./user"
require "./channel"
module Discord
module Gateway
struct ReadyPayload
JSON.mapping(
v: UInt8,
user: User,
private_channels: Array(PrivateChannel),
guilds: Array(UnavailableGuild),
session_id: String
)
end
struct ... | require "./converters"
require "./user"
require "./channel"
module Discord
module Gateway
struct ReadyPayload
JSON.mapping(
v: UInt8,
user: User,
private_channels: Array(PrivateChannel),
guilds: Array(UnavailableGuild),
session_id: String
)
end
struct ... | Add a mapping for the payload used by dispatches dealing with bans | Add a mapping for the payload used by dispatches dealing with bans
| Crystal | mit | meew0/discordcr |
3d223aed27eae125b7b08162d204290612b652b6 | src/base_authentication_app_skeleton/spec/support/boxes/user_box.cr | src/base_authentication_app_skeleton/spec/support/boxes/user_box.cr | class UserBox < Avram::Box
def initialize
email "test@example.com"
encrypted_password Authentic.generate_encrypted_password("password")
end
end
| class UserBox < Avram::Box
def initialize
email "#{sequence("test-email")}@example.com"
encrypted_password Authentic.generate_encrypted_password("password")
end
end
| Use unique email address in UserBox | Use unique email address in UserBox
| Crystal | mit | luckyframework/cli,luckyframework/cli,luckyframework/cli |
9328436d831b21d2105e1ea0631e3e586b2dd572 | src/reql/executor/get_all_stream.cr | src/reql/executor/get_all_stream.cr | require "./stream"
require "./row_value"
require "../../storage/*"
module ReQL
struct GetAllStream < Stream
class InternalData
property channels = [] of Channel(RowValue?)
end
def reql_type
"STREAM"
end
def initialize(@table : Storage::AbstractTable, @keys : Array(Datum) | Set(Datum... | require "./stream"
require "./row_value"
require "../../storage/*"
module ReQL
struct GetAllStream < Stream
class InternalData
property channels = [] of Channel(RowValue?)
end
def reql_type
"STREAM"
end
def initialize(@table : Storage::AbstractTable, @keys : Array(Datum) | Set(Datum... | Simplify GetAllStream: channel is never null | Simplify GetAllStream: channel is never null
| Crystal | mit | lbguilherme/rethinkdb-lite |
bd886ee01750f29ae6d1f5240bc0c08b1b2f20e7 | spec/spec_helper.cr | spec/spec_helper.cr | require "../src/microtest"
require "./helpers"
include Microtest::DSL
include Helpers
COLOR_REGEX = %r{\e\[\d\d?(;\d)?m}
def uncolor(str)
str.gsub(COLOR_REGEX, "")
end
macro microtest_test(&block)
{%
c = <<-CRYSTAL
require "./src/microtest"
include Microtest::DSL
#{block.body.id}
... | require "../src/microtest"
require "./helpers"
include Microtest::DSL
include Helpers
COLOR_REGEX = %r{\e\[\d\d?(;\d)?m}
def uncolor(str)
str.gsub(COLOR_REGEX, "")
end
macro microtest_test(&block)
{%
c = <<-CRYSTAL
require "./src/microtest"
include Microtest::DSL
#{block.body.id}
... | Use progress reporter for tests | Use progress reporter for tests
| Crystal | mit | Ragmaanir/microtest,Ragmaanir/microtest |
9d44f9f560bee48e7969382a9fcefbdd27f5ed7d | config/routes.cr | config/routes.cr | Amber::Server.instance.config do |app|
pipeline :web do
# Plug is the method to use connect a pipe (middleware)
# A plug accepts an instance of HTTP::Handler
plug Amber::Pipe::Logger.new unless app.env == "test"
plug Amber::Pipe::Flash.new
plug Amber::Pipe::Session.new
plug Amber::Pipe::CSRF.n... | Amber::Server.instance.config do |app|
pipeline :web do
# Plug is the method to use connect a pipe (middleware)
# A plug accepts an instance of HTTP::Handler
plug Amber::Pipe::Logger.new unless app.env == "test"
plug Amber::Pipe::Flash.new
plug Amber::Pipe::Session.new
plug Amber::Pipe::CSRF.n... | Use Amber::Pipe::Static handler to set http response cache headers | Use Amber::Pipe::Static handler to set http response cache headers
Enables caching of static files in `public/` dir which
will improve page load time and prevent delays in applying css/js to the
dom.
https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers
| Crystal | mit | crystal-community/crystal-ann |
4e4cbee42680ade2680db2857479e6eec38b0e1f | spec/crustache_spec.cr | spec/crustache_spec.cr | require "./spec_helper"
describe Crustache do
describe ".parse" do
it "shold parse a string" do
Crustache.parse("Hello, {{Mustache}} World").should be_truthy
end
it "should parse a IO" do
Crustache.parse(StringIO.new "Hello, {{Mustache}} World").should be_truthy
end
it "raise a pars... | require "./spec_helper"
describe Crustache do
describe "#parse" do
it "shold parse a string" do
Crustache.parse("Hello, {{Mustache}} World").should be_truthy
end
it "should parse a IO" do
Crustache.parse(StringIO.new "Hello, {{Mustache}} World").should be_truthy
end
it "raise a pars... | Add Engine's spec to crustache specs | Add Engine's spec to crustache specs
| Crystal | mit | MakeNowJust/crustache |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.