Skip to content

Instantly share code, notes, and snippets.

View cben's full-sized avatar

Beni Cherniavsky-Paskin cben

View GitHub Profile
@cben
cben / feedback-on-gitbook-editor-5-beta.md
Created January 29, 2016 06:52
Feedback for Gitbook Editor 5 beta

saw it on hacker news but it's already closed for comments.

[specifically tried gitbook-editor-5.0.0-beta.6-linux-x64.deb on lubuntu 15.10]

Very nicely done WYSIWYM! I'm author of mathdown.net & https://github.com/cben/CodeMirror-MathJax/, which only renders math, and less well than your implementation.

(the exact meaning of "WYSIWYM" is fuzzy; styled text is probably not exactly what LyX meant but math/image/link rendering brings it closer, and in any case it's a better description than "WYSIWYG". I understand the term never got widely known and you might prefer WYSIWYG for publicity...)

@cben
cben / README.md
Last active March 15, 2016 14:20
Testing https://github.com/openshift/openshift-ansible/pull/1582 (at 1b8e8ef75c50a9ddb8c3922979fe6ddb027f10a4)
> bin/cluster -v create libvirt metrics4 --option use_openshift_metrics=true
...
PLAY RECAP ******************************************************************** 
localhost                  : ok=90   changed=31   unreachable=0    failed=0   
metrics4-master-d780a      : ok=282  changed=51   unreachable=0    failed=0   
metrics4-node-compute-0e7b2 : ok=129  changed=30   unreachable=0    failed=0   
metrics4-node-compute-266fe : ok=129  changed=30   unreachable=0    failed=0   
metrics4-node-infra-48f49  : ok=129  changed=30   unreachable=0    failed=0   
@cben
cben / build_pod_vs_pod_labels.txt
Last active April 18, 2016 12:18
ManageIQ labels and tags examples
irb(main):050:0> pp ContainerBuildPod.all.map{|p| {name: p.name,
build_pod_labels: p.labels.pluck(:name, :value),
pod_labels: p.container_group && p.container_group.labels.pluck(:name, :value)}}
[{:name=>"ruby-sample-build-1",
:build_pod_labels=>
[["app", "ruby-sample-build"],
["buildconfig", "ruby-sample-build"],
["name", "ruby-sample-build"],
["openshift.io/build-config.name", "ruby-sample-build"],
@cben
cben / 00_load_mappings.log
Last active April 28, 2016 14:42
DB traffic from labels->tags mapping https://github.com/ManageIQ/manageiq/pull/7605 [NO RAILS CACHING - development has action_controller.perform_caching = false]
irb(main):001:0> ContainerLabelTagMapping.hash_all_by_name_type_value
ContainerLabelTagMapping Load (0.4ms) SELECT "container_label_tag_mappings".* FROM "container_label_tag_mappings" ORDER BY "container_label_tag_mappings"."id" ASC LIMIT $1 [["LIMIT", 1000]]
ContainerLabelTagMapping Inst Including Associations (14.5ms - 5rows)
Tag Load (0.4ms) SELECT "tags".* FROM "tags" WHERE "tags"."id" IN (127, 128, 129, 130, 131)
Tag Inst Including Associations (3.5ms - 5rows)
MiqEvent.raise_evm_event(target, policy_event, inputs)
event_obj = build_evm_event(event, target)
pp event_obj
#<MiqEvent:0x0055ac981f45b0
id: 1550,
event_type: "containergroup_failedsync",
message: nil,
timestamp: Mon, 23 May 2016 10:26:45 UTC +00:00,
host_name: nil,
[----] E, [2016-05-23T15:12:26.572957 #11680:2af3b78b998c] ERROR -- : <AutomationEngine> MiqAeServiceModelBase.ar_method raised: <Errno::EPIPE>: <Broken pipe>
[----] E, [2016-05-23T15:12:26.573710 #11680:2af3b78b998c] ERROR -- : <AutomationEngine> /usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/interface.rb:79:in `write'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/interface.rb:79:in `print'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/interface.rb:79:in `errmsg'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/processors/command_processor.rb:171:in `rescue in safely'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/processors/command_processor.rb:169:in `safely'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/processors/command_processor.rb:122:in `run_auto_cmds'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/processors/command_processor.rb:131:in `before_repl'
/usr/local/lib/ruby/gems/2.2.0/gems/byebug-9.0.3/lib/byebug/
@cben
cben / byebug_term.rb
Last active March 29, 2017 21:51
Using byebug from background workers
# ~~TODO: send one-liner PR to byebug that would simplify this a lot.~~
# Released in byebug 9.0.6, now TODO: simplify this a lot :-)
# Enter byebug from a background by launching a terminal with byebug client.
# Only works on same machine, under X. (tmux left as excercise to reader)
#
# USAGE:
# 1. Have this file loaded (eg. put it in config/initializers/)
# 2. Write `byebug_term` in place of `byebug`.
# 3. If you don't have/like gnome-terminal, set BYEBUG_TERM_COMMAND env var
@cben
cben / PR.md
Last active June 22, 2016 11:06

Multiple ui_lookup calls in MiqPolicyController and children were failing due to incorrect capitaliztion (and a titleize-inflicted space. This wasn't highly visible in English because the fallback titleize behavior looked reasonable.

Fix implementation

I could pepper .camelize calls but IMO that doesn't convey the intent clearly. It's impossible to look at such code and notice "Here titleize should be camelize"... Instead I extracted ui_model[s]_from_id method (better naming welcome).

  • Arguably this doesn't belong in MiqPolicyController but in/near GlobalMethods#ui_lookup. However I'm unsure we want to camelize all model lookups, and anyway, I'm too scared to affect all UI in one change. (This PR took me almost a week to do, test, discard half, re-do, test...)
@cben
cben / pp_no_stdout.rb
Created June 19, 2016 11:29
PoC pretty-print with no access to stdout (byebug remote)
require 'pp'
require 'stringio'
class PPP
def initialize(obj)
io = StringIO.new
PP.pp(obj, io)
@pp = io.string
end
def inspect
(byebug) _("All %{typ} %{model}")
"»すべての %{typ} %{model}«"

(byebug) {:typ   => "#{ui_model_from_id(@sb[:nodeid])} #{@sb[:mode] ? @sb[:mode].capitalize : ""}", :model => ui_lookup(:models => "MiqPolicy")}
#LOOKUP model 'vm' -> 'Vm' RETURNS 'Vm' -> '»VM およびインスタンス«'
{:typ=>"»VM およびインスタンス« Compliance", :model=>"»ポリシー«"}

(byebug) puts "»すべての %{typ} %{model}«" % {:typ=>"»VM およびインスタンス« Compliance", :model=>"»ポリシー«"}
»すべての »VM およびインスタンス« Compliance »ポリシー««