Skip to content

Instantly share code, notes, and snippets.

View kredmer's full-sized avatar

Karsten Redmer kredmer

  • Saleshype UG(haftungsbeschränkt)
  • Hamburg, Germany
View GitHub Profile
@kredmer
kredmer / echoHttpRequest.js
Last active August 29, 2015 14:11 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
<?xml version="1.0" encoding="UTF-8"?>
<Request>
<Counter>100</Counter>
<DataFilter>
<Filter>
<Filtername>DateFilter</Filtername>
<FilterValues>
<DateFrom>01.01.2013 00:00:00</DateFrom>
<DateTo>31.12.2013 23:59:00</DateTo>
<FilterValue>CreateDate</FilterValue>
<Javascript async="false" continueOnError="false" enabled="true" name="javascript-step" timeLimit="200">
<DisplayName>Javascript-Step</DisplayName>
<FaultRules/>
<Properties/>
<IncludeURL>jsc://sharedlib</IncludeURL>
<ResourceURL>jsc://normaljsscript</ResourceURL>
</Javascript>
<extractvariables async="false" continueonerror="false" enabled="true" name="getArticleNumberfromPath">
<displayname>getItemNumberfromPath</displayname>
<faultrules>
<properties>
<uripath>
<pattern ignorecase="true">/*/{uri}</pattern>
</uripath>
<ignoreunresolvedvariables>true</ignoreunresolvedvariables>
<variableprefix>path</variableprefix>
</properties></faultrules>
@kredmer
kredmer / e4x2json.js
Last active December 16, 2015 22:19 — forked from olegp/e4x2json.js
// One way converter from E4X XML to JSON
// 1) turns <body><item>1</item><item>2</item></body> into
// body: {item: ["1", "2"]} so that lists are easier to work with
// 2) turns things like: <body a="a">whatever</body> into
// body: {_a: "a", _: "whatever"}
// however <body>whatever</body> becomes simply body: "whatever
// - attributes specified by ignored are ignored
function E4XtoJSON(xml, ignored) {
var r, children = xml.*, attributes = xml.@*, length = children.length();
if(length == 0) {
@kredmer
kredmer / hobo-model.rb
Created June 19, 2012 12:56
Wrong access of options
def belongs_to_with_test_methods(name, options={}, &block)
belongs_to_without_test_methods(name, options, &block)
refl = reflections[name]
id_method = refl.options[:primary_key] || refl.klass.primary_key
if options[:polymorphic]
# TODO: the class lookup in _is? below is incomplete; a polymorphic association to an STI base class
# will fail to match an object of a derived type
# (ie X belongs_to Y (polymorphic), Z is a subclass of Y; @x.y_is?(some_z) will never pass)
class_eval %{
--------> binding.pry
@kredmer
kredmer / gist:1496980
Created December 19, 2011 12:21
already initialized constant ...
ruby script/server
=> Booting WEBrick
=> Rails 2.3.11 application starting on http://0.0.0.0:3000
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:7: warning: already initialized constant VERSION
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:9: warning: already initialized constant ROOT
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:13: warning: already initialized constant DEFAULT_PUBLIC_ROOT
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:15: warning: already initialized constant DEFAULT_CONFIG_PATH
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:17: warning: already initialized constant DEFAULT_PACKAGE_PATH
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:19: warning: already initialized constant DEFAULT_JST_SCRIPT
/home/karsten/.rvm/gems/ruby-1.8.7-p334@saleshype/gems/jammit-0.6.5/lib/jammit.rb:21: warn
@kredmer
kredmer / gist:1309454
Created October 24, 2011 16:34
module RestfulMetrics - monkey patch
module RestfulMetrics
class Client
extend LogTools
@@connection = nil
@@debug, @@async, @@disabled = false
@@fqdn = nil
@kredmer
kredmer / gist:1270883
Created October 7, 2011 17:35
edit in place i18n translation select-one-editor
System:
ruby-1.8.7-p334
hobo (1.0.3)
rails (2.3.11)
Models:
Contact Model
has_many :contact_activities