Skip to content

Instantly share code, notes, and snippets.

@faouzzz
faouzzz / tmux.conf
Created December 27, 2017 07:47
tmux conf
set -g prefix ^a
unbind ^b
bind a send-prefix
bind C-r source-file ~/.tmux.conf \; display-message '~/.tmux.conf reloaded !'
set -g mode-mouse on
set -g mouse-select-pane on
set -g default-terminal "screen-256color"
@faouzzz
faouzzz / notification.js
Last active October 24, 2017 11:03
semantic-ui notification
// semantic-ui flash notification hide / auto hide
function hideFlash() {
return ($('#flash').hasClass('hidden') ? '' : $('#flash').transition('slide', 800));
}
$(document).on('turbolinks:load', function () {
setTimeout(hideFlash, 5000);
$('#flash, #flash .message .close').on('click', hideFlash);
});
@faouzzz
faouzzz / application_record.rb
Created August 3, 2017 18:44
rails log validation errors on dev env
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
if Rails.env.development?
after_validation :log_errors, :if => Proc.new {|m| m.errors}
end
private
def log_errors
message = " Validation error for #{self.class.name}:\n\t - #{self.errors.full_messages.join("\n\t - ")}"
@faouzzz
faouzzz / notification.js
Created August 2, 2017 14:20
semantic ui flash notification custumized transparency and close / auto hide
// semantic-ui flash notification hide / auto hide
function hideFlash() {
return $('#flash').transition('slide', 800);
}
$(document).on('turbolinks:load', function(){
setTimeout(hideFlash, 5000);
$('#flash .message .close').on('click', hideFlash);
});
@faouzzz
faouzzz / datatable.net-se.css
Created August 1, 2017 19:26
datatable.net-se index files with buttons plugin
/*
*= require datatables.net-se/css/dataTables.semanticui
*= require datatables.net-buttons-se/css/buttons.semanticui
*/
@faouzzz
faouzzz / .env
Last active July 31, 2017 17:55
Dockerfile and docker-compose with .env for rails application
DB_USER=postgres
DB_PASS=postgres_password
DOCKER_IMAGE=my_app
SECRET_KEY_BASE=b1cb46476e90acf49363e03be5a9bea53053c37bd4dda5b1d8d81351fef49e894f5d913dd03ceb389ba279379a6244571f8fcb48b46024334e98ef658dd49de6
RAILS_ENV=production
RAILS_WEB_PORT=3000
BUNDLE_PATH=/gems
@faouzzz
faouzzz / table_to_csv.rb
Created June 12, 2017 15:13 — forked from sandys/table_to_csv.rb
convert a html table to CSV using ruby
# run using ```rvm jruby-1.6.7 do jruby "-J-Xmx2000m" "--1.9" tej.rb```
require 'rubygems'
require 'nokogiri'
require 'csv'
f = File.open("/tmp/preview.html")
doc = Nokogiri::HTML(f)
csv = CSV.open("/tmp/output.csv", 'w',{:col_sep => ",", :quote_char => '\'', :force_quotes => true})
@faouzzz
faouzzz / rails.sh
Last active February 7, 2017 11:05
rails app creator
rails new $1 -CBT && cd $1 && \
git init . && git add . && git commit -m "initial commit" && \
curl -Lk https://git.io/vDW2B > Gemfile && bundle && \
rails g simple_form:install && \
curl -Lk https://git.io/vDWDc > config/initializers/simple_form.rb && \
curl -Lk https://git.io/vDlT6 > config/locales/simple_form.fr.yml && \
erb2haml && rm -fr app/views/layouts/*.erb && \
git add --all && git commit -m "set basic config" && git checkout -b dev
# curl -Lk https://raw.githubusercontent.com/tigrish/devise-i18n/master/rails/locales/fr.yml
@faouzzz
faouzzz / README.md
Created February 6, 2017 14:31 — forked from atenni/README.md
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@faouzzz
faouzzz / _form.html.erb
Last active February 6, 2017 18:00 — forked from kouheiszk/_form.html.erb
simple_form.rb for semantic ui
<%= f.input :email,
wrapper: :semantic_icon_input,
label: false,
required: true,
placeholder: t('users.form.placeholder.email'),
left_icon: 'user' %>