Skip to content

Instantly share code, notes, and snippets.

View keernel's full-sized avatar
🎯
Focusing

Fernando Varani keernel

🎯
Focusing
View GitHub Profile
Searching 2363 files for "has_many"
/Users/fernando/freelas/takiweb_dev/app/models/address.rb:
18: has_many :clients
19: has_many :app_users
/Users/fernando/freelas/takiweb_dev/app/models/app.rb:
25: has_many :orders
26: has_many :markets
27: has_many :app_users
{
"complement_categories": [
{
"id": 7,
"market_id": 1,
"item_id": 1,
"name": "Borda",
"min_quantity": 1,
"max_quantity": 1,
"is_required": true,
@keernel
keernel / _notifications.html.erb
Created February 16, 2018 15:48
notify on rails
<script type="text/javascript">
<% for key, msg in flash %>;
<% case key %>
<% when "notice" %>
$.notify({
message: "<%= msg %>",
icon: 'fa fa-check'
},{
type: "success"
});
@keernel
keernel / brazil_latitudes_longitudes
Created July 28, 2016 18:05
Latitude and longitude for brazilian cities.
{
"city":{"name": "Palmeiras do Tocantins", "state":"TO", "location":{"lat": -6.616584, "lng": -47.546429}},
"city":{"name": "Barro Preto", "state":"BA", "location":{"lat": -14.794773, "lng": -39.476029}},
"city":{"name": "Fernando de Noronha", "state":"PE", "location":{"lat": -3.839601, "lng": -32.410733}},
"city":{"name": "Campo de Santana", "state":"PB", "location":{"lat": -6.487585, "lng": -35.636707}},
"city":{"name": "Pracuúba", "state":"AP", "location":{"lat": 1.745427, "lng": -50.789248}},
"city":{"name": "Amapá", "state":"AP", "location":{"lat": 2.052669, "lng": -50.795653}},
"city":{"name": "Bujari", "state":"AC", "location":{"lat": -9.815277, "lng": -67.955029}},
"city":{"name": "Plácido de Castro", "state":"AC", "location":{"lat": -10.280640, "lng": -67.137133}},
"city":{"name": "Tarauacá", "state":"AC", "location":{"lat": -8.156975, "lng": -70.772154}},
cat file.txt | pbcopy
@keernel
keernel / !searchable.rb
Last active June 5, 2016 14:25
Simple reusable search module
module Searchable
extend ActiveSupport::Concern
module ClassMethods
def filter(filter_params)
filter_params_keys = filter_params.symbolize_keys
results = self.where(nil)
filter_params_keys.each do |key, value|
results = results.where(self.arel_table[key].matches("%#{value}%"))
end
@keernel
keernel / prompt confirmation on rake tasks
Created June 5, 2016 13:36
prompt confirmation on rake tasks
STDOUT.puts "Do you wish to clean your current database? \n Please respond with 'yes' or 'no' (or 'y' or 'n'). \n"
answer = STDIN.gets.chomp
@keernel
keernel / squash commits
Created June 3, 2016 11:57
Squash git commits
Let's say you have two commits in your branch:
$ git log --oneline origin/master..new-feature
73bbc09 Hack some more
f33b240 Hack hack
What the project maintainer wants is a single commit in the diff between your new-feature branch and the project's master branch. What we need here is the interactive rebase feature of Git:
$ git rebase -i origin/master
This will open your editor with these contents:
@keernel
keernel / setup.sh
Created May 30, 2016 20:18 — forked from hubertlepicki/setup.sh
PhantomJS 2.0.1 on codeship
# I am pasting that into setup steps
# binary provided by the amazing Codeship.io support
PHANTOMJS_URL="https://s3.amazonaws.com/codeship.io/checkbot/binaries/phantomjs_2.0.1"
set -e
rm -rf ~/.phantomjs
wget --continue "${PHANTOMJS_URL}" -O "${HOME}/cache/phantomjs"
ln -s "${HOME}/cache/phantomjs" "${HOME}/bin/"
chmod +x "${HOME}/bin/phantomjs"