Skip to content

Instantly share code, notes, and snippets.

View romanlehnert's full-sized avatar

Roman Lehnert romanlehnert

  • Munich, Germany
View GitHub Profile
"((void 0),(function (counter, val) {var topic = val.topic;topic.unread = topic_unread_counter(topic.uuid);scope.unread = topic.unread + scope.unread;save_topic_in_dom(topic);}))@http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js:29 (1,[object Object])@http://gobas.sharenotes.de/javascripts/run_v3.js:238 ([object Array],(function (i, scope) {scope.unread = 0;$.each(scope.subscriptions, function (counter, val) {var topic = val.topic;topic.unread = topic_unread_counter(topic.uuid);scope.unread = topic.unread + scope.unread;save_topic_in_dom(topic);});}))@http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js:30 scopes_for_template([object Array])@http://gobas.sharenotes.de/javascripts/run_v3.js:236 ([object Array],"success",[object XMLHttpRequest])@http://gobas.sharenotes.de/javascripts/app_v6.js:78 b()@http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js:124 ()@http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js:129 ([object Object])@http://ajax.googleapis.com/ajax/
@romanlehnert
romanlehnert / gist:1416783
Created December 1, 2011 13:37
Patch for qt
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
index e666ff7..8abcc48 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
@@ -100,7 +100,7 @@ int SocketStreamHandlePrivate::send(const char* data, int len)
if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
return 0;
quint64 sentSize = m_socket->write(data, len);
- QMetaObject::invokeMethod(this, "socketSentData", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "socketSentdata", Qt::QueuedConnection);
@romanlehnert
romanlehnert / gist:1417357
Created December 1, 2011 14:58
patchset for qt
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
index e666ff7..8abcc48 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/SocketStreamHandleQt.cpp
@@ -100,7 +100,7 @@ int SocketStreamHandlePrivate::send(const char* data, int len)
if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState)
return 0;
quint64 sentSize = m_socket->write(data, len);
- QMetaObject::invokeMethod(this, "socketSentData", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "socketSentdata", Qt::QueuedConnection);
@romanlehnert
romanlehnert / gist:6185966
Created August 8, 2013 16:06
Get a Hash dump from couchbase
c.save_design_doc('{ "_id": "_design/admin", "language": "javascript", "views": { "all": { "map": "function(doc){emit(doc);}" } } }')
docs = Hash[c.design_docs['admin'].all(:include_docs => true).map{ |doc| doc.data }.collect{ |doc| [doc["doc"]["meta"]["id"], doc["doc"]["value"]] }]
@romanlehnert
romanlehnert / gist:6522520
Created September 11, 2013 11:51
measuring delayed_job speed
def current_job_speed(time = 5)
start_time = Time.now
start_count = Delayed::Job.count
sleep time
end_time = Time.now
end_count = Delayed::Job.count
t = end_time - start_time
@romanlehnert
romanlehnert / truncate_rails_tables.rb
Created September 17, 2013 15:54
Truncate all tables in rails
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
next if table == 'schema_migrations'
case ActiveRecord::Base.connection.adapter_name.downcase.to_sym
when :mysql2 || :postgresql
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
when :sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
end
@romanlehnert
romanlehnert / gist:8546582
Created January 21, 2014 19:28
sql query for posts with multiple comment conditions
SELECT "posts".* FROM "posts"
WHERE
"posts"."id" IN
(SELECT post_id FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"
WHERE "comments"."title" = 'foo')
AND
"posts"."id" IN
(SELECT post_id FROM "posts"
INNER JOIN "comments" ON "comments"."post_id" = "posts"."id"

Goals of a bug report

The single goal of a bug report is to fix the bug. Chances for that are higher, when the report is clear, reproduceable and follows a fixed structure. Keep in mind, that not only developers need to understand a bug, but also the product owner and testers who may not have such a deep technical knowhow. Customers and other stakeholders have to talk about the bug. A software tester has to be able to reproduce it, and a developer is in charge to fix it. The following description is a "best practice" for reporting a bug.

Contents of a bug report

  1. Title
  2. Steps to reproduce
  3. Current result
  4. Expected result
  5. Environment
def self.with_latest_document
joins(" INNER JOIN
contract_documents AS joined_contract_documents
ON contracts.id = joined_contract_documents.contract_id
INNER JOIN
(
SELECT max(created_at) AS created_at, contract_id, id, status
FROM contract_documents
WHERE status IN ('uploaded', 'approved')
GROUP BY contract_id