Skip to content

Instantly share code, notes, and snippets.

View pama's full-sized avatar

Paulo Abreu pama

View GitHub Profile
@pama
pama / devise.pt.yml
Last active August 20, 2023 12:07
European Portuguese translation for devise
# Additional translations at https://github.com/heartcombo/devise/wiki/I18n
# European Portuguese translations for devise
#
# The translation does not respect the 1990 agreement
pt:
devise:
confirmations:
confirmed: "A sua conta foi confirmada com sucesso."
send_instructions: "Dentro de alguns minutos irá receber um e-mail com instruções para confirmar a sua conta."
@pama
pama / gist:b99e1ceaa849b6a67c05
Last active August 29, 2015 14:11
Countdown timer example (not accurate, though)
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
</head>
<body>
<div id="timer"></div>
<script>
@pama
pama / gist:65bcf526923d369c258f
Created December 18, 2014 09:41
will_paginate switching page by persisting a search form
# We need to trigger click event for pagination links and search submit. Also, we need to post
# to the entry point when searching, as it will avoid handling the search in 2 different places.
#
# The submit click event resets the page hidden field. The link event will get the page
# number, updates the page hidden field and submits the form.
# routes.rb
get 'will_paginate', to: 'will_paginate#index'
post 'will_paginate', to: 'will_paginate#index'
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
session[:omniauth] = auth.except('extra')
user = User.sign_in_from_omniauth(auth)
session[:user_id] = user.id
redirect_to root_url, notice: "Signed In"
end
@pama
pama / Gemfile
Created June 14, 2016 01:33
Carrier wave for multiple Uploads
# ...
gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'
@pama
pama / sublime.txt
Created January 5, 2017 12:51
Sublime text configuration
{
"ensure_newline_at_eof_on_save": true,
"font_size": 12,
"ignored_packages":
[
"Vintage"
],
"save_on_focus_lost": true,
"tab_size": 2,
"translate_tabs_to_spaces": true
@pama
pama / check_box_filter.rb
Last active January 9, 2017 18:13
Check box filters
scope :category_query, ->(query) do
if query.count == 1
joins(:article_categories).where('article_categories.category_id': query.first)
else
joins(:article_categories).
where('article_categories.article_id': ArticleCategory.select('article_categories.article_id')
.where(category_id: query)
.group('article_categories.article_id')
.having("COUNT(article_categories.article_id) > #{query.count - 1}"))
.uniq
@pama
pama / index.html.erb
Last active February 18, 2017 12:21
Example downloading a csv file preserving ransack search
<h1>Users</h1>
<%= search_form_for @q, url: dashboard_index_path do |f| %>
<%= f.label :name_cont %>
<%= f.search_field :name_cont %>
<%= f.submit %>
<% end %>
<ul>
@pama
pama / app.js
Last active March 16, 2022 12:17
Show data in a table using Express.JS
const express = require('express')
const app = express()
app.set('view engine', 'pug');
app.set('views','./views');
app.get('/', function (req, res) {
var users = [];
var mysql = require('mysql')
@pama
pama / .rubocop.yml
Last active October 12, 2018 08:50
#
# Some rubocop offenses are an insult to programmers
AllCops:
TargetRubyVersion: 2.5
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- 'db/**/*'