Skip to content

Instantly share code, notes, and snippets.

@jhilden
jhilden / README.md
Last active October 3, 2021 10:32
Setup for using i18n-js together with react-rails i18n-js for server side prerendering

When using react-rails for an internationalized app it makes a lot of sense to use i18n-js for translations, so that you can reuse the the strings from your rails app's .yml files (and all the tooling & services that exist around that).

When you use the prerender feature of react-rails you face 2 problems:

  • The first is that translation.js & i18n.js from i18n-js need to be loaded inside the server-side JS prerendering processes, which is achieved by loading them inside the components.js.
  • The second problem is the server processes need to be aware of the current locale of each HTTP request. This is done by adding a custom renderer and using the before_render hook to configure i18n-js accordingly for each render call.
@jhilden
jhilden / curl_output
Created March 27, 2012 08:05
curl to with special HTTP accept header
curl -v -H "Accept: text/javascript, text/html, application/xml, */*" http://localhost:3000/places/12356-apartment-berlin-prenzlauerberg/calendar\?for_date\=2012-05-01
* About to connect() to localhost port 3000 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /places/12356-apartment-berlin-prenzlauerberg/calendar?for_date=2012-05-01 HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3
> Host: localhost:3000
> Accept: text/javascript, text/html, application/xml, */*
>
< HTTP/1.1 200 OK
@jhilden
jhilden / railslove_developer_job_post.md
Created May 9, 2019 08:26
💚 Full-Stack Entwickler/in bei freundlicher kleiner Web/Mobile Agentur in Köln 💚

Hallo, wir sind ein Team aus 15 freundlichen Entwickler/innen und Designer/innen und haben in unserem gemütlich eingerichteten Büro im Herzen der Kölner Südstadt noch zwei freie Schreibtische, für die wir dieses Jahr zwei weitere Entwickler/innen finden wollen. Hättest du Lust? Wir haben Kunden aus dem Startup-Bereich, aber auch aus etablierten Unternehmen und bieten das komplette Produktentwicklungsspektrum an: von Business Case und User Research, über Design und Konzept, bis hin zur Full-Stack-Entwicklung. Wir geben uns Mühe unsere Kunden mit Bedacht auszuwählen und stellen Sinnhaftigkeit, Nachhaltigkeit und Sympathie über rein finanzielle Faktoren.

Was uns besonders macht

Wir schätzen an der Arbeit bei Railslove, dass wir viel Freiheit haben und das Vertrauen bekommen, eigenständig zu entscheiden wie wir am besten Arbeiten können (z.B. Stichworte: flexible Arbeitszeiten, Home Office). Wir sind ein Team von sehr passionierten Techies, die sich ständig weiterentwickeln und voneinander lernen möchten. P

@jhilden
jhilden / discourse_sso.rb
Last active June 16, 2018 04:11
# Discourse SSO Rails::Engine gem to perform cookie-based SSO login in [Discourse](http://www.discourse.org/). It expects your main app to set a cookie readable by Discourse with a Discourse `user_id` as the value (encrypting the value is a very good idea). See: http://meta.discourse.org/t/give-me-those-authentication-hooks-d/3943
module DiscourseSso
module ControllerExtensions
def self.included(klass)
klass.append_before_filter :ensure_sso_login
end
private
@jhilden
jhilden / Gemfile.lock
Created October 21, 2016 09:45
Gemfile.lock for css_splitter
PATH
remote: .
specs:
css_splitter (0.4.6)
sprockets (>= 2.0.0)
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.2.5)
@jhilden
jhilden / _action_button.md
Last active December 29, 2015 06:29
Livingstyleguide integration

// app/assets/stylesheets/modules/_action_button.css.ass

Action Button

Button style usually used for call to actions::

<button type="button" class="***m-action_button***">Action button</button>
<a class="***m-action_button***">Action button</a>
@jhilden
jhilden / SassMeister-input.sass
Created February 23, 2013 20:21
Generated by SassMeister.com, the Sass playground.
// Sass v3.2.5
.context-a, .context-b
border: 1px
.some-class
color: red
.another-class
color: blue
.icons-sprite
.icons-ad
.icons-add-small
.icons-add-tiny
.icons-ae
.icons-af
.icons-ag
.icons-ai
.icons-al
.icons-alert-error
@jhilden
jhilden / tabs.js.coffee
Created August 28, 2012 10:33
Remove jquery-ui styling for tabs
$ ->
jquery_ui_classes = [".ui-tabs", ".ui-tabs-nav", ".ui-tabs-panel", ".ui-widget", ".ui-widget-header", ".ui-widget-content", ".ui-corner-all", ".ui-corner-top", ".ui-corner-bottom", ".ui-helper-clearfix", ".ui-helper-reset", ".ui-state-default"]
$(".js-tabs").tabs().each ->
# removes all the jquery-ui specific classes (except ones like ui-state-active)
$elements = $(this).find( jquery_ui_classes.join(", ") ).andSelf()
$elements.removeClass( jquery_ui_classes.join(" ").replace(/\./g, "") )
@jhilden
jhilden / ruby_string_include_array.rb
Created August 30, 2011 16:02
[Ruby] String.include?([Array])
# I find myself constantly wanting to check whether one string is included within an array of strings.
# It is certainly possible (and also fast) to do that in Ruby with something like this: ["foo", "bar"].include?("foo")
# But I don't think it reads very nice :(
# Because what I actually want to test is, whether my string is included in the array and NOT the other way around.
# - Do you have the same problem?
# - What do you think about the following two solutions?
class String
# create a new method