Skip to content

Instantly share code, notes, and snippets.

View mfebrianto's full-sized avatar

michael febrianto mfebrianto

View GitHub Profile
@mfebrianto
mfebrianto / grep_select_benchmark.rb
Last active August 29, 2015 14:18
performance comparison between grep vs select to get result of array_of_hash
require 'rubygems'
require 'benchmark'
phone1 = { phone_number: '0434889994', plan: 'standard' }
phone2 = { phone_number: '0452649226', plan: 'standard' }
phone3 = { phone_number: '0434556677', plan: 'data_only' }
phone4 = { phone_numner: '0434889995', plan: 'data_only' }
array_of_hash = [phone1, phone2, phone3, phone4]
proc_find = ->(s) {s[:plan] == 'standard'}
# location of this file : required_field_style/spec/required_field_style_spec.rb
require 'spec_helper'
module RequiredFieldStyle
describe '/accounts/new.html.erb', :type => :view do
it 'should render mandatory style for required field' do
required_field = 'Account no'
mandatory_style = '<sup style=\"color:red\">&nbsp;*</sup>'
assigns[:account] = Account.new
<!-- path of this file : required_field_style/app/views/accounts/new.html.erb -->
<% form_for (@account), :url => '' do |f| %>
<%= f.label :account_no %><br />
<%= f.text_field :account_no %><br />
<%= f.label :company_name %><br />
<%= f.text_field :company_name %><br />
<% end %>
@mfebrianto
mfebrianto / 0_reuse_code.js
Created August 17, 2014 11:53
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<a href="#" onclick="NewServiceWizard.add_new_service_tariff({"data":{},"url":"http://localhost:3000/services/3612/service_tariffs/new"});; return false;">Add a new service tariff</a>