Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Gentu Paster
// @namespace Violentmonkey Scripts
// @match https://gentu.io/patients/*/clinical_history/letters/*
// @grant none
// @version 1.0
// @author -
// @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.2/waitForKeyElements.js
// @description 26/05/2020, 20:58:38
// ==/UserScript==
// Formats the given byte value into a human readable form.
//
// Accepts four optional arguments that control the output format:
// as_bits: If true, converts the given byte value to bits and adjusts the suffix accordingly. Defaults to false.
// binary: If true, calculates order of magnitude as base 2 (binary) instead of base 10 (decimal). Defaults to true.
// full_suffix: If true, uses full suffix names such as "Megabyte", otherwise uses abbreviations like "MB" or "Mib". Defaults to false.
// precision: The number of decimal points to include in the output. Trailing zero's are removed. Defaults to 2.
function formatBytes (bytes, as_bits, binary, full_suffix, precision) {
as_bits = typeof as_bits !== 'undefined' ? as_bits : false;
@Wardrop
Wardrop / gist:604f5ec38315e510ecff
Last active August 29, 2015 14:13
Transform value while preserving key example
require 'parslet'
class ExampleParser < Parslet::Parser
root(:root)
rule(:root) { width >> str("x") >> height }
rule(:width) { match["0-9"].repeat(1).as(:width) }
rule(:height) { match["0-9"].repeat(1).as(:height) }
end
class ExampleTransform < Parslet::Transform
require 'scorched'
class Base < Scorched::Controller
middleware << proc do
use Rack::Session::Cookie, secret: 'mysecretcookie'
end
end
class Sub < Base
get '/hello' do
class ApiV1 < Scorched::Controller
RedisDB = 15
def redis
@redis ||= Redis.new(RedisDB)
end
end
class Base < Scorched::Controller
include Scorched::Options('settings')
end
Class Test < Base
settings[:some_settings] = 'hello'
end

Questions

1) What inspired you to create your own Ruby framework?

As much as I like Sinatra, there were some limitations I found frustrating and unnecessary when using it in the real-world. These were mainly issues of code management and scalability. You either had to put all your routes for your entire application in a single "controller", in which they shared helpers, filters, configuration, and so on, or otherwise try and break your application out into multiple mini Sinatra applications, and mount them under different mappings using Rack. Neither solution was elegant. I thought Padrino might address a few of those issues, but found it equally if not more frustrating.

Given that I had a pretty good idea of what I wanted and because it was simple enough (maybe not in hindsight), I decided to roll my own, knowing that I'd not only be scratching my itch, but the itches of many other developers who inadvertantly run into issues of practicaility when using Sinatra.

2) How did you come up with the n

require 'scorched'
class Base < Scorched::Controller
class << self
def inherited(klass)
klass.route('/*?') do
action = request.breadcrumb[-2].mapping[:conditions][:action]
if action && respond_to?(action)
send(action)
else
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.create('Ext.data.Store', {
storeId: 'petTypes',
fields: ['name', 'value'],
proxy: {
type: 'rest',
url: '/people/pet_types',
reader: {
This file has been truncated, but you can view the full file.
[ 2013-03-15 10:50:59.6637 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/erb.rb:445:
[ 2013-03-15 10:50:59.6638 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] [BUG]
[ 2013-03-15 10:50:59.6639 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] Segmentation fault
[ 2013-03-15 10:50:59.6639 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr]
[ 2013-03-15 10:50:59.6639 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]
[ 2013-03-15 10:50:59.6640 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr]
[ 2013-03-15 10:50:59.6640 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] -- Control frame information -----------------------------------------------
[ 2013-03-15 10:50:59.6641 13601/b6c9cb70 Pool2/Implementation.cpp:1109 ]: [App 13758 stderr] c:0055
[ 2013-03-15 10:50:59.6642 13601/b6c9cb70