Skip to content

Instantly share code, notes, and snippets.

View kamilio's full-sized avatar
🇲🇽

Kamil Jopek kamilio

🇲🇽
  • Aguas, the city that never sleeps
View GitHub Profile
@kamilio
kamilio / custom-thunk.js
Created May 10, 2016 16:08
Redux, eventBus solved with middlewares or without
// *** Middleware - custom thunk implementation (slightly diffferent though) - maybe more scalable appraoch
export default function createEventBusMiddleware(eventBus) {
return ({ dispatch, getState }) => (next) => (action) => {
// we could optimize further here and use rest operator to get all arguments and compose the middlewares
if (typeof action === 'function') {
return action({ dispatch, eventBus, getState });
}
return next(action);
};
@kamilio
kamilio / programmingWithFunctions.js
Last active August 29, 2015 14:19
Programming with Functions - Stuttgart JS Meetup
// ***************************
// Programming with functions (Kamil Jopek)
// Stuttgart JS Meetup Talk (13th April 2015)
// ***************************
// Basic functions
var add = function(a, b) {
return a + b;
};

How to configure gems

Are you writing a new gem and you are not sure how to let user configure it? Here is a short gist to show you how to do it. I like this style of configurations, inspired by many already existing gems such as Devise, Airbrake, PDFkit and many more.

# Configuration
MyShinyGem.configure do |config|
  config.binary = '/bin/ls'
 config.username = 'superuser'
RSpec::Core::RakeTask.module_eval do
def pattern
dir = EngineName.root # replace with you the name of your engine
extras = []
if File.directory?( dir )
extras << File.join( dir, 'spec', '**', '*_spec.rb' ).to_s
end
[@pattern] | extras
end
end