openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.pem -days 3650
require 'socket' | |
require 'rack' | |
require 'sinatra' | |
# Simple, rack-compliant web server | |
class MyServer | |
STATUS_CODES = { | |
200 => 'OK', | |
500 => 'Internal Server Error' | |
} |
require "active_record" | |
ActiveRecord::Base.establish_connection('postgres:///testing') | |
ActiveRecord::Migration.verbose = false | |
ActiveRecord::Migration.class_eval do | |
create_table :played_quizzes, force: true do |t| | |
t.integer :player_ids, array: true | |
t.json :quiz_snapshot | |
end |
class AgencyVisitPolicy | |
def initialize(user) | |
@user = user | |
end | |
def to_proc | |
Proc.new { |visit| visit.agency_id.in?([@user.agency_id, nil]) } | |
end | |
end |
require 'lotus/model' | |
require 'json' | |
module Lotus::Model::Mapping::Coercions | |
def self.JSON(arg) | |
return nil if arg.nil? | |
case arg | |
when String | |
JSON.parse(arg) | |
else |
module Lotus | |
module Repository | |
# Timestamps handling using an entity's @created_at and @updated_at. | |
# | |
# @since 0.2.4 | |
module Timestamps | |
# Override existing public API into hosting class to support @created_at | |
# and @updated_at using Ruby implementations (database agnostic). | |
# | |
# @since 0.2.4 |
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
package main | |
import ( | |
"net/http" | |
) | |
func main() { | |
finish := make(chan bool) | |
server8001 := http.NewServeMux() |
# rack_sse.ru | |
# | |
# An example of basic real-time, single-room broadcast chat using Server Sent | |
# Events in plain old Rack. This example does NOT use hijack, or the async | |
# hacks, it just relies on a well implemented threaded Rack server (at time of | |
# writing this will therefore only work with puma!). Other servers should be | |
# fixed to support this, as it is pretty critical to how Rack *should* work on | |
# most servers. The only spec-acceptable failure in this case is not flushing | |
# the content stream on each yield (for which the rack spec has no workaround | |
# today). |
# Visit: | |
# /main/set_flash | |
# /main/show_no_flash (as many times as you like) | |
# /main/show_flash ... and it shows the flash message | |
# (Rails 4.1.8, Ruby 2.1.1) | |
# app/controllers/main_controller.rb | |
class MainController < ApplicationController | |
def show_flash | |
render inline: flash[:notice] || "Flash is blank!" |