Skip to content

Instantly share code, notes, and snippets.

View geocodinglife's full-sized avatar
👨‍💻
Keep Coding

Ricardo Alarcon geocodinglife

👨‍💻
Keep Coding
  • remote
View GitHub Profile
@geocodinglife
geocodinglife / rails-jsonb-queries
Created September 13, 2023 21:40 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@geocodinglife
geocodinglife / git-alias.md
Created February 3, 2023 02:25 — forked from Klerith/git-alias.md
Useful Git Alias

Log

git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"

Status

git config --global alias.s status --short

Alternativa útil de status

git config --global alias.s status -sb

Git Cheat Sheet

Basic commands

git init Creates a new git repository in the directory

git add <file name> Adds a specific file to staging

git add . or git add -A Adds the full directory and its contents to staging

set nocompatible " be iMproved
" For vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#rc()
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "honza/vim-snippets"
@geocodinglife
geocodinglife / state_pattern.rb
Created September 2, 2019 03:16 — forked from travisjeffery/state_pattern.rb
State Pattern in Ruby
# State - allow an object to alter its behaviour when its internal state
# changes. The object will appear to change its class.
# Key idea - introduce an abstract class called SomethingState to represent the
# states of the object. Subclasses of the abstract class implement
# state-specific behaviour.
class Person
attr_accessor :state, :name
@geocodinglife
geocodinglife / latin1-to-utf8.rb
Created August 19, 2019 16:52 — forked from jeremyf/latin1-to-utf8.rb
A ruby script to help automate getting a Rails application out of MySQL's character encoding hell.
# The below script attempts to automate the character encoding challenges
# encountered with mysql, latin1 and UTF8
# http://www.bluebox.net/news/2009/07/mysql_encoding/
# ==============================================================================
# Copyright © 2013 University of Notre Dame
# Additional copyright may be held by others, as reflected in the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
puts "Eliminado información de ciudades"
City.delete_all
puts "Cargando información de municipios".red
townships = [
{id: 48002001, city_name: 'Bialystok', department_id: 48002},
{id: 48003001, city_name: 'Bielsko-Biala', department_id: 48003},
{id: 48004001, city_name: 'Bydgoszcz', department_id: 48004},
{id: 48005001, city_name: 'Chelm', department_id: 48005},
{id: 48006001, city_name: 'Ciechanów', department_id: 48006},
{id: 48007001, city_name: 'Cracovia', department_id: 48007},
puts "Eliminado información de departamentos"
Department.delete_all
puts "Cargando información de departamentos".red
departments = [
{id: 66075, department_name: 'Uthai Thani', country_id: 66},
{id: 66076, department_name: 'Uttaradit', country_id: 66},
{id: 79001, department_name: 'Carriacou', country_id: 79},
{id: 79002, department_name: 'Petite Martinique', country_id: 79},
{id: 79003, department_name: 'Saint Andrew', country_id: 79},
{id: 79004, department_name: 'Saint David', country_id: 79},
puts "Eliminado información de paises"
Country.delete_all
puts "Cargando datos de paises".red
countries = [
{id: 188, country_name: 'Afganistán', code: 'AF', country_status: false, phone_code: '+93', flag: 'AGO.png'},
{id: 355, country_name: 'Albania', code: 'AL', country_status: false, phone_code:'+355', flag: 'ALB.png'},
{id: 49, country_name: 'Alemania', code: 'DE', country_status: false, phone_code:'+49', flag: 'DEU.png'},
{id: 376, country_name: 'Andorra', code: 'AD', country_status: false, phone_code:'+376', flag: 'AND.png'},
{id: 244, country_name: 'Angola', code: 'AO', country_status: false, phone_code:'+244', flag: 'AGO.png'},
{id: 6, country_name: 'Anguilla', code: 'AI', country_status: false, phone_code:'+1-264', flag: 'AIA.png'},
@geocodinglife
geocodinglife / multiple_ssh_setting.md
Created June 15, 2019 15:22 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"