Skip to content

Instantly share code, notes, and snippets.

@nepsilon
nepsilon / how-to-use-mac-keychain-to-store-github-repos-credentials.md
Created July 18, 2017 06:50
How to use Mac KeyChain to store GitHub repos credentials? — First published in fullweb.io issue #108

How to use Mac KeyChain to store GitHub repos credentials?

You know the pain, you cloned a repo over HTTPS, and now Git asks you for your password each time you want to push or pull.

Chances are you already have the git credential-osxkeychain command installed. If not, just install Git with brew: brew install git.

Once installed, just tell Git to use the KeyChain to store your credentials:

git config --global credential.helper osxkeychain
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active December 17, 2025 22:03
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@mike1011
mike1011 / rails-jsonb-queries
Created April 26, 2020 17:18 — forked from mankind/rails-jsonb-queries
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")
@mike1011
mike1011 / Ruby on Rails - Questions
Last active March 3, 2022 12:29
Ruby on Rails - Interview questions
========== ONLY RUBY ==========
array vs hash - ordered indexed collection
convert hash to array = h.to_a
get even/odd entries from array -> select.each_with_index { |_, i| i.even? }
get hash keys in reverse order -> Hash[h.to_a.reverse] OR hash_array.keys.reverse
---replace strings --
value = "cat"
# Replace string at with ote.
value.sub!("at", "ote") // just first instance - cote
value = value.gsub("cat", "---") //all instances globally ---