Skip to content

Instantly share code, notes, and snippets.

View AquisTech's full-sized avatar
💻
Speaking via <code/>

AquisTech AquisTech

💻
Speaking via <code/>
View GitHub Profile
@AquisTech
AquisTech / flash_message_helper.rb
Created February 25, 2016 16:39
Flash Message Helper (Foundation 6)
module FlashMessagesHelper
def render_flash_messages
flash.delete(:timedout) # FIX: https://github.com/plataformatec/devise/issues/1777
safe_join flash.map { |flash_type, message| alert_box(flash_type, message) }
end
private
def close_button(dismiss)
@AquisTech
AquisTech / missing_translation.css
Last active July 11, 2020 06:54
Detect and prompt missing translation in browser
span.translation_missing {
background: red;
}
@AquisTech
AquisTech / .editorconfig
Last active March 3, 2016 07:05
My EditorConfig
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@AquisTech
AquisTech / .overcommit.yml
Last active March 3, 2016 07:07
My Overcommit config
# Overcommit configurations followed in BaseApp
#
#-------------------------------------------------------------------------------
# Loads Bundler context from a Gemfile. If false, does nothing (default).
#
# Specifying a Gemfile for Bundler to load allows you to control which gems are
# available in the load path (i.e. loadable via `require`) within your hook
# runs. Note that having a Gemfile requires you to include `overcommit` itself
# in your Gemfile (otherwise Overcommit can't load itself!).
@AquisTech
AquisTech / form.haml
Last active March 3, 2016 07:04
jQuery Birthdate Picker
= javascript_include_tag 'jquery/jquery-birthday-picker'
:javascript
$(document).ready(function() {
$('.birth_date_selection').birthdayPicker({monthFormat: 'long', minAge: 18, defaultDate: '15-05-2015'});
});
= form_for @user do |user|
.birth_date_selection
= user.date_select(:birth_date, order: [:month, :day, :year])
@AquisTech
AquisTech / unicode_regexp.rb
Created March 3, 2016 04:53
Unicode supported Regular expressions
# /lib/unicode_regexp.rb
class UnicodeRegexp
# Returns string of Special Characters to be used in Regex
SPECIAL_CHARACTERS = [
'\\~', '\\!', '\\@', '\\#', '\\$', '\\%', '\\^', '\\&', '\\*', '\\(', '\\)', '\\_', '\\+', '\\-',
'\\=', '\\|', '\\{', '\\}', '\\[', '\\]', '\\:', '\\;', '\\"', '\\<', '\\>', '\\.', '\\?', '\\/',
"\\\\\s" # Backslash & space character are purposely kept together in a string
].join
@AquisTech
AquisTech / news_letters.txt
Created March 12, 2016 01:45
News Letters
Ruby Weekly
@AquisTech
AquisTech / TODO.txt
Created March 21, 2016 05:26
DRY AjaxDatatablesRails
# TODOs
1. Support for associated models
2. Support for serielized models
3. Enable/disable search/sort for particular column
@AquisTech
AquisTech / factories_spec.rb
Last active March 23, 2016 11:09
Generalized specs to test all factories and traits
require 'rails_helper'
FactoryGirl.factories.each do |factory|
describe "The '#{factory.name}' factory" do
it 'is valid' do
build(factory.name).should be_valid
end
factory.definition.defined_traits.each do |trait|
describe "The '#{trait.name}' trait" do
it 'is valid' do
@AquisTech
AquisTech / explode_dotted_keys.rb
Last active April 2, 2016 09:06
explode_dotted_keys.rb
require 'ap'
module HashExt
def explode_keys(key_delimiter: '.')
recursive_hash = self.class.new { |hash, key| hash[key] = self.class.new(&hash.default_proc) }
result = self.to_h.reduce(recursive_hash) do |recursive_acc, (input_key_path, input_value)|
keys = input_key_path.to_s.split(key_delimiter)
tree = keys.map {|key| [:[], key] }