Skip to content

Instantly share code, notes, and snippets.

View wdiechmann's full-sized avatar

Walther Diechmann wdiechmann

View GitHub Profile
@wdiechmann
wdiechmann / mysql_incorrect_string_value
Created March 6, 2015 10:38
Trace of an error when trying to insert a record into a MySQL table
```
(0.1ms) ROLLBACK
ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect string value: '\xE5 vide...' for column 'body' at row 1: INSERT INTO `messages` (`title`, `msg_from`, `msg_to`, `body`, `created_at`, `updated_at`) VALUES ('Fwd: Kan ikke leveres: Re: test - svar', 'whd@sl2017.dk', 'sl2017@oxen.dk', '<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n</head>\n<body dir=\"auto\">\n<div>Pis<br>\n<br>\nMed venlig hilsen\n<div>Walther</div>\n</div>\n<div><br>\nStart p? videresendt besked:<br>\n<br>\n</div>\n<blockquote type=\"cite\">\n<div><b>Fra:</b> Microsoft Outlook &lt;<a href=\"mailto:MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e@korpskontoret.onmicrosoft.com\">MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e@korpskontoret.onmicrosoft.com</a>&gt;<br>\n<b>Dato:</b> 6. mar. 2015 kl. 03.34.44 CET<br>\n<b>Til:</b> &lt;<a href=\"mailto:whd@sl2017.dk\">whd@sl2017.dk</a>&gt;<br>\n<b>Emne:</b> <b>Kan ikke leveres: Re: test - svar</b><br>\n<br>\n</div>\n</blo
@wdiechmann
wdiechmann / rake_trace
Created January 24, 2012 08:44
tracing a rake assets:precompile error
[rails 3] git submodule init
Submodule 'vendor/bootstrap' (https://github.com/twitter/bootstrap.git) registered for path 'vendor/bootstrap'
[rails 3] git submodule update
Cloning into vendor/bootstrap...
remote: Counting objects: 7954, done.
remote: Compressing objects: 100% (3248/3248), done.
remote: Total 7954 (delta 5435), reused 6966 (delta 4556)
Receiving objects: 100% (7954/7954), 2.55 MiB | 577 KiB/s, done.
Resolving deltas: 100% (5435/5435), done.
Submodule path 'vendor/bootstrap': checked out 'b4b1ef68398b68dcdfa29465d06cd76d6bf2c49d'
@wdiechmann
wdiechmann / gist:1692260
Created January 28, 2012 02:55
cache: [GET /] miss - driving me crazy :(
==================== development mode ======================
every thing is dandy!
[rails 3] OX_ID=1 r s
=> Booting WEBrick
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-28 03:38:30] INFO WEBrick 1.3.1
@wdiechmann
wdiechmann / gist:1748930
Created February 6, 2012 02:02
Shoulda and Rspec question on undefined method 'have'
ruby-1.9.2-p290 :013 > @ox = Factory.create(:ox, id: 1)
=> #<Ox id: 1, name: "oxen", siteurl: "www.oxen.dk", created_at: "2012-02-06 01:46:15", updated_at: "2012-02-06 01:46:15", active: nil>
ruby-1.9.2-p290 :014 > user = Factory.create(:user, ox: @ox)
=> #<User id: 253, email: "test_user@oxen.dk", encrypted_password: "$2a$04$LgSZM2RH6Q5rW5WSpH8vmeKL/AXtHQ5WViUPfPZQcqaz...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, password_salt: nil, confirmation_token: "erGxuzj8Mtk3jY63xNdK", confirmed_at: nil, confirmation_sent_at: "2012-02-06 01:46:30", unconfirmed_email: nil, failed_attempts: 0, unlock_token: nil, locked_at: nil, created_at: "2012-02-06 01:46:30", updated_at: "2012-02-06 01:46:30", username: "username", ox_id: 1, approved: false, active: nil>
ruby-1.9.2-p290 :015 > role = Factory.create(:role, ox: @ox)
=> #<Role id: 218, ox_id: 1, name: "Role_2", cr
@wdiechmann
wdiechmann / next_rails.md
Created October 13, 2012 11:07
With the template gone - what's next?

Pitch

Building flexible Rails apps above the obvious '15-minute blog' requires a myriad of controllers, models, views and other stuff. Moving as many as possible of these bits and pieces into the DB will liberate the application and make it able to serve diversity better!

Idea

Models could be persisted to the DB and either eager- or lazy-loaded on web-server start/reload.

@wdiechmann
wdiechmann / trace.rb
Created October 25, 2012 15:33
Full trace of namespaced inherited_resources request gone sour
actionpack (3.2.8) lib/action_dispatch/routing/polymorphic_routes.rb:129:in `polymorphic_url'
inherited_resources (1.3.1) lib/inherited_resources/url_helpers.rb:232:in `collection_url'
actionpack (3.2.8) lib/abstract_controller/helpers.rb:53:in `collection_url'
app/views/abstract_actions/_index.haml:16:in `_app_views_abstract_actions__index_haml___1224373729827874985_70196125597280'
actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.8) lib/action_view/template.rb:143:in `render'
actionpack (3.2.8) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
actionpack (3.2.8) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
@wdiechmann
wdiechmann / actionpack.prying.rb
Created October 25, 2012 15:57
Could I have stumpled upon a bug in ActionPack, hmmm??!?
[7] pry(#<Messages::DistributionListsController>)> options
=> {}
[8] pry(#<Messages::DistributionListsController>)> args = record_or_hash_or_array.dup
=> ["messages",
#<Messages::DistributionList id: nil, ox_id: nil, user_id: nil, name: nil, active: nil, created_at: nil, updated_at: nil>]
[9] pry(#<Messages::DistributionListsController>)> inflection = :singular
=> :singular
[10] pry(#<Messages::DistributionListsController>)> args.delete_if {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
=> [#<Messages::DistributionList id: nil, ox_id: nil, user_id: nil, name: nil, active: nil, created_at: nil, updated_at: nil>]
[11] pry(#<Messages::DistributionListsController>)> args
@wdiechmann
wdiechmann / time_zone_io.md
Created November 13, 2012 14:21
time and time again, your rails will come clean :)

Started out with that frustrating issue that bites many a Rails developer (judging from just a tad over 24hrs googling and reading blogs etc) - time_zone!

I'm on

ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.4.2] - Rails 3.2.8
config.time_zone = 'Copenhagen'

and initially, I wanted to bark up this three, 'with the pack'

[31] pry(main)&gt; ent.enter_at=Time.now 
@wdiechmann
wdiechmann / gist:323dd78e83e34e87660c
Last active November 25, 2015 18:17
nanobox hurls - complaining about mysql
[premier] bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
...cut...
Using mysql2 0.3.20
Installing puma 2.15.3
Using sprockets 3.4.0
@wdiechmann
wdiechmann / gist:d85b6485316084934803
Created January 6, 2016 12:30
npm install -g vorlon fails
/Users/walther/.node/bin/vorlon -> /Users/walther/.node/lib/node_modules/vorlon/bin/vorlon
> bufferutil@1.1.0 install /Users/walther/.node/lib/node_modules/vorlon/node_modules/bufferutil
> node-gyp rebuild
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
In file included from ../src/bufferutil.cc:16:
../../nan/nan.h:261:25: error: redefinition of '_NanEnsureLocal'
NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) {
^