Skip to content

Instantly share code, notes, and snippets.

View oelmekki's full-sized avatar

kik oelmekki

View GitHub Profile
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

From dc02b1cc6ec8b8c3c2693c1f91892e13bafefef8 Mon Sep 17 00:00:00 2001
From: Olivier El Mekki <olivier@el-mekki.com>
Date: Sun, 17 May 2015 19:18:32 +0200
Subject: [PATCH] ADD tagline in slack message
---
app/Console/Commands/PostUpvotes.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/Console/Commands/PostUpvotes.php b/app/Console/Commands/PostUpvotes.php
# Allows to create event on piwik from server side code.
#
# Usage:
#
# piwik = Piwik.new
# piwik.create_event( category: 'sale', action: 'new_interface', name: '100_sales_from_same_country', value: 10_000 )
# piwik.create_event( name: 'user_changed_locale' )
#
#
# Required gems:
" File: ruby_check.vim
" Author: Olivier El Mekki
" Email: olivier@el-mekki.com
" Description: ruby syntax checks the buffer
" Usage:
" :RUBYCheck - lauch the syntax check
if exists('ruby_check_plugin')
finish
endif
class App.Url
parser_regexp: /^(.*:\/\/)([^:\/]+)(:[^\/]+)?(.*?)(\?.*?)?(#.*)?$/
constructor: ( initial ) ->
initial.replace( @parser_regexp, ( match, @_protocol, @_domain, @_port, @_path, @_params, @_anchor ) => )
@protocol = if @_protocol then @_protocol.replace( /:\/\//, '' ) else ''
@domain = @_domain or ''
@port = if @_port then @_port.replace( /:/, '' ) else ''
@path = @_path or ''
@params = if @_params then @_params.replace( /^\?/, '' ) else ''

Why progressive enhancement matters

A recent story on Hacker News pop up and informed us that progressive enhancement is dead.

The main point for this article was that it's kind of ridiculous in 2013 to build a whole app having in mind that user may deactivate javascript. I can't agree more with that, as did most HN commenters.

" File: replace_quotes.vim
" Author: Olivier El Mekki
" Email: olivier@el-mekki.com
" Description: quick replace of quotes you're inside
" Usage:
" :QuotesToDouble - replaces outer single quotes with double quotes
" :QuotesToSingle - replaces outer double quotes with single quotes
if exists('replace_quotes_plugin')
finish
class Object
# Display an object methods list with their source location.
#
# @param [Regexp] method_pattern grep method name
# @param [Regexp] file_pattern grep file name
def located_methods( method_pattern = nil, file_pattern = nil )
list = ( method_pattern ? methods.grep( method_pattern ) : methods ).sort.map do |name|
location = method( name ).source_location
location = "#{location.first} line #{location.second}" if location
[ name.to_s.colorize( :yellow ), location ]
module ApplicationHelper
# Format errors for display.
# Resource may be a model or an handler - just anything including ActiveModel::Validations
#
# @param [Object] resource the source of errors
# @return [String] the error html
def error_messages_for_handler( resource )
message = <<-EOS
<div id="error_explanation">
<ul>
# A context encapsulate behavior for altering database
# in a specific situation.
#
# It is most notably responsible for validations and
# parameters filtering. You may also add in there all the
# custom logic that should be trigger on a specific context,
# like sending mails or updating other resources.
#
#
# # The problem