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;
# 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.
def format_bytes(bytes, as_bits: false, binary: true, full_suffix: false, precision: 2)
suffixes = ['', 'Kilo', 'Mega', 'Giga', 'Tera', 'Peta', 'Exa', 'Zetta', 'Yotta']
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
@Wardrop
Wardrop / gist:4976817
Created February 18, 2013 11:48
No means to access outer class from singleton class.
# Doesn't work; needs reference to outer class object.
class SomeClass
class << self
extend Delegate
def hash
@hash ||= {}
end
delegate hash, :[]=, :has_key?, :each
# Current Validation Strategy
validates_presence :place_id
errors.add(:place, "must have a parent") unless place.parent_id
# Improved Validation Strategy
validates_presence :place_id
validates :place, "must have a parent" { place.parent_id }
error do |e|
if response.content_type.index(mime_type(:json)) == 0
halt 400, {success: false, exception: e.message}.to_json
end
end
@Wardrop
Wardrop / gist:1797102
Created February 11, 2012 06:20
Padrino reloader problem...
DEBUG -11/Feb/2012 16:18:07 RELOAD (0.0157ms) /Users/tomwardrop/Sites/Tombstone/app/controllers/reservation.rb
DEVEL -11/Feb/2012 16:18:07Reloading Tombstone::App
DEVEL -11/Feb/2012 16:18:07Removed constant: Tombstone::Role
DEVEL -11/Feb/2012 16:18:07Removed constant: Tombstone::ModelPermissions::InstanceMethods
DEVEL -11/Feb/2012 16:18:07Removed constant: Tombstone::ModelPermissions::DatasetMethods
DEVEL -11/Feb/2012 16:18:07Removed constant: Tombstone::ModelPermissions
DEVEL -11/Feb/2012 16:18:07Removed constant: Tombstone
DEBUG -11/Feb/2012 16:18:07 LOADING (0.0287ms) /Users/tomwardrop/Sites/Tombstone/app/lib/model_permissions.rb
DEBUG -11/Feb/2012 16:18:07 LOADING (0.0549ms) /Users/tomwardrop/Sites/Tombstone/app/lib/permissions.rb
DEBUG -11/Feb/2012 16:18:07 LOADING (0.0221ms) /Users/tomwardrop/Sites/Tombstone/app/models/base.rb