Skip to content

Instantly share code, notes, and snippets.

Avatar
🦆
quacking!

Elia Schito elia

🦆
quacking!
View GitHub Profile
View .diff
diff --git a/app/backend/beestore/client.rb b/app/backend/beestore/client.rb
index 2e7c8f67d..aa9ccb708 100644
--- a/app/backend/beestore/client.rb
+++ b/app/backend/beestore/client.rb
@@ -380,7 +380,9 @@ module Beestore
# Use this in case you need to restore stocks.
# New 22 Jun 2016.
# Used in VariantAvailabilityRestore (worker, multistock) and Quantifier (multistock in single stock location)
- # stock_locations is an array of stock locations instances.
+ #
@elia
elia / opal-pr-1653.md
Created Apr 11, 2017
Opal: constants system rewrite (in two parts) #1653
View opal-pr-1653.md

from: https://github.com/opal/opal/pull/1653

master

commit 447e1b4cb313de4bd416f1184b27fcee8cd5edd8
Author: Elia Schito <elia@schito.me>
Date:   Wed Apr 12 00:00:35 2017 +0200
    Establish a constant lookup IPS benchmark
@elia
elia / init_conf.rb
Last active Feb 21, 2017
opal -I. main.rb
View init_conf.rb
module InitConf
# how to add a new parameter
# 1. set the default here
# 2. maintain neatjson options to get it sorted here as well
# 3. update controller_command_defnitions to provide the add / edit commands
# 4. update conf_doc_source.rb to provide the documentation and help
# 5. update config-form.rb to attach a type
# 6. update user-interface.js to add the menu entries
def self.init_conf()
result =
View Gemfile
source 'https://rubygems.org'
gem "opal"
View simple_server.rb
require 'opal/deprecations'
# Opal::SimpleServer is a very basic Rack server for Opal assets, it relies on
# Opal::Builder and Ruby corelib/stdlib. It's meant to be used just for local
# development.
#
# For a more complete implementation see opal-sprockets (Rubygems) or
# opal-webpack (NPM).
#
# @example (CLI)
View assets-initializer.rb
# Remove when https://github.com/rails/sprockets/issues/242 is resolved
unless Rails.env.development?
module SprocketsCachedLoader
def initialize(*)
super
@expanded_assets_cache = {}
end
def asset_from_cache(key)
return @expanded_assets_cache[key] if @expanded_assets_cache.has_key?
View read_proc.rb
class IO
def read
if @eof
''
else
`res = self.read_proc(@path)`
@eof = true
@lineno = res.size
res
end
@elia
elia / tail_logentries.rb
Created Dec 17, 2015
Connect to a Logentries log set and tail logs to the terminal
View tail_logentries.rb
warn "Usage: #{$0} ACCOUNT_KEY LOG_SET LOG_NAME" if ARGV.size != 3
account_key = ARGV[0]
log_set = ARGV[1]
log_name = ARGV[2]
msec = -> t { (t.to_f * 1000).to_i }
now = Time.now
require 'thread'
View bm.rb
require 'benchmark/ips'
require 'set'
require 'digest'
# The encouragement:
# https://github.com/elia/sprockets/blob/3-0/let-it-go/lib/sprockets/digest_utils.rb#L37-L44
def digest_class
Digest::SHA256
end
@elia
elia / ruby-modules.coffee
Created Jul 15, 2015
Included and prepended modules in JavaScript with __proto__
View ruby-modules.coffee
p = console?.log
# Prepend module "mod" to the class "cla"
prepend_module = (cla, mod)->
icla = dup_methods(mod.prototype)
icla.__proto__ = cla.pre.__proto__
cla.pre.__proto__ = icla
cla
# Include module "mod" into the class "cla"
You can’t perform that action at this time.