Skip to content

Instantly share code, notes, and snippets.

View dividedmind's full-sized avatar

Rafał Rzepecki dividedmind

  • Wrocław, Poland
View GitHub Profile
@dividedmind
dividedmind / appmap-diff.md
Last active October 25, 2020 14:01
Simple execution trace diff with AppLand

Simple execution trace diff

At AppLand we're currently working on ways in which we can visualize how changes to the code affect program design and execution. But it turns out you don't need any fancy visuals to be able to tell something useful.

(BTW, see the whole code gallery!)

If you're not familiar with AppLand, at the very basic level, it allows you to record program execution traces. These traces can then be processed to surface interdependencies between code artifacts (such as classes, objects

@dividedmind
dividedmind / restclient_log.script
Created March 11, 2019 16:28
Example conjur CLI session using RESTCLIENT_LOG
$ RESTCLIENT_LOG=stderr conjur authn login
Enter your username to log into Conjur: admin
Please enter your password (it will not be echoed):
RestClient.get "https://cuke-master/authn/cucumber/login", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.1p111"
# => 200 OK | text/html 55 bytes
Logged in
$ RESTCLIENT_LOG=stderr conjur variable values add vaultName/lob8/safe_0/obj_832/password secret123
RestClient.post "https://cuke-master/authn/cucumber/admin/authenticate", "3j1aqpew0f2m02njp46c1pg0rft1j23r8a2zx878p3q5nb251njvkqh", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Content-Length"=>"55", "Content-Type"=>"text/plain", "User-Agent"=>"rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.1p111"
# => 200 OK | application/json 568 bytes
RestClient.post "https://cuke-master/secrets/cucumber/variable/vaultName%2Flob8%2Fsafe_0%2Fobj_832%2Fpassword", "secret123", "Accept"=>"*/*", "Accept-Encoding"=>"gzip, deflate", "Authorization"=>"Token token=\"e
@dividedmind
dividedmind / chromewallet.py
Created March 29, 2012 02:38
Chrome password extractor from KWallet
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Quick and dirty Chrome kwallet password extractor
from PyKDE4.kdeui import KWallet
from PyQt4.QtGui import QApplication
from sys import argv
app = QApplication([])
195 <13>1 2013-12-28T03:15:18.713037+00:00 app web.1 - - [authz-ci-conjur] [836de4aadf34a61d9f8f1c550227d0a7] Processing by RolesController#list_members as XML
227 <13>1 2013-12-28T03:15:18.715912+00:00 app web.1 - - [authz-ci-conjur] [836de4aadf34a61d9f8f1c550227d0a7] Parameters: {"members"=>nil, "account"=>"ci", "role"=>"layer/205cm0/ldap-test"}
202 <13>1 2013-12-28T03:15:18.720253+00:00 app web.1 - - [authz-ci-conjur] [836de4aadf34a61d9f8f1c550227d0a7] Sequel::Postgres::Database (3.9ms) BEGIN
296 <13>1 2013-12-28T03:15:18.725630+00:00 app web.1 - - [authz-ci-conjur] [836de4aadf34a61d9f8f1c550227d0a7] Sequel::Postgres::Database (3.7ms) SELECT * FROM "roles" WHERE ("id" = ROW('ci', 'layer:205cm0/ldap-test')::"role_id") LIMIT 1
279 <13>1 2013-12-28T03:15:18.738816+00:00 app web.1 - - [authz-ci-conjur] [836de4aadf34a61d9f8f1c550227d0a7] Sequel::Postgres::Database (12.0ms) SELECT * FROM "roles" WHERE ("id" = ROW('ci', 'user:kgilpin')::"role_id") LIMIT 1
sigi = sigma.instances[1];
var prefix = /.{7}/;
sigi.iterNodes(function (node) {
node.label = node.attr.kind + ": " + node.attr.name.replace(prefix, '');
});
WebFontConfig = {
google: { families: [ 'Lato::latin' ] }
#!/usr/bin/env ruby
# solution of http://uva.onlinejudge.org/external/13/1339.pdf
ARGF.map {|x| x.strip.chars.group_by(&:to_s).values.map(&:length).sort }.
each_slice(2) {|a, b| puts a == b ? 'YES' : 'NO' }
#!/usr/bin/env ruby
# I opted for a more conventional mapping, as in
# https://en.wikipedia.org/wiki/File:Telephone-keypad2.svg
MAP = {
'2' => 'abc',
'3' => 'def',
'4' => 'ghi',
'5' => 'jkl',
'6' => 'mno',
@dividedmind
dividedmind / Gemfile
Created October 9, 2013 18:12
Gemfile taking three minutes to resolve
source 'https://rubygems.org'
gem 'rails-api', '>= 0'
gem 'slosilo', '>= 0'
gem 'slosilo', '>= 0'
gem 'rails-api', '>= 0'
gem 'pg_random_id', '>= 0'
gem 'sequel-attribute_callbacks', '>= 0'
gem 'json_spec', '>= 0'
gem 'talentbox-sequel-rails', '>= 0'
@dividedmind
dividedmind / gist:5091386
Created March 5, 2013 16:06
ZTE modem losing connection on weak signal - syslog
Mar 5 16:07:57 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): --> 'AT+CSQ<CR>'
Mar 5 16:07:57 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): <-- '<CR><LF>+CSQ: 4,0<CR><LF><CR><LF>OK<CR><LF>'
Mar 5 16:07:57 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): --> 'AT%NWSTATE=1<CR>'
Mar 5 16:07:57 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): <-- '<CR><LF>%NWSTATE: 2,26002,3G,HSDPA-HSUPA-HSPA+,0<CR><LF><CR><LF>OK<CR><LF
>'
Mar 5 16:07:57 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): <-- '<CR><LF>%NWSTATE: 2,26002,3G,HSDPA-HSUPA-HSPA+,0<CR><LF>'
Mar 5 16:07:58 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1): <-- '<CR><LF>%NWSTATE: 1,26002,3G,HSDPA-HSUPA-HSPA+,0<CR><LF>'
Mar 5 16:08:03 daktylon modem-manager[1003]: <debug> [mm-at-serial-port.c:334] debug_log(): (ttyACM1)
describe "Foo" do
before do
allow_any_instance # ... user thing
allow_any_instance_of(Event).to receive(:resource_visible) { resource_visible }
end
let(:perform!) { get "etc" }
context "with an event invisible to both" do
let(:resource_visible) { true }