Skip to content

Instantly share code, notes, and snippets.

Resources:

https://github.com/ankane/searchkick

Indexing

By default, simply adding the call 'searchkick' to a model will do an unclever indexing of all fields (but not has_many or belongs_to attributes).

In practice, you'll need to customize what gets indexed. This is done by defining a method on your model called search_data

def search_data

@mike1011
mike1011 / rails_new_help_output.md
Created December 28, 2022 21:52 — forked from eliotsykes/rails_new_help_output.md
"rails new" options explained

Run rails new --help to view all of the options you can pass to rails new:

$ bin/rails new --help
Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]                                      # Path to the Ruby binary of your choice
                                                         # Default: /Users/eliot/.rbenv/versions/2.2.0/bin/ruby
@mike1011
mike1011 / arel_cheatsheet_on_steroids.md
Created October 25, 2022 21:13 — forked from ProGM/arel_cheatsheet_on_steroids.md
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 / Javascript questions
Created August 26, 2022 12:32
javascript questions with console.log
var a={},
b={key:'b'},
c={key:'c'};
a[b]=123;
a[c]=456;
console.log(a[b]);
console.log(a);
Output:
@mike1011
mike1011 / authenticable.rb
Created August 2, 2022 22:06 — forked from esteedqueen/authenticable.rb
JSON API User Registration and Sessions with Devise
module Authenticable
# Devise methods overwrite
def current_user
@current_user ||= User.find_by(authentication_token: request.headers['Authorization'])
end
def authenticate_with_token!
render json: { errors: "Not authenticated" },
status: :unauthorized unless user_signed_in?
@mike1011
mike1011 / Interview_Coding_Questions.txt
Last active August 26, 2022 12:33
Interview coding questions Or Data Structures
convert string in arrays
add all elements of array
find duplicate element in array
get fibonacci series of any given number
get factorial of any given number
create a pyramid of star
find remainder of a number
create recursive function - get value and add new value to the output
create a logic to check if number is a palindrome or not
check max occurance of any chars in a string
@mike1011
mike1011 / readme.md
Last active October 22, 2021 15:17 — forked from yosukehasumi/readme.md
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Redis
  8. Postgres
@mike1011
mike1011 / FrontEnd Interview questions
Last active July 17, 2023 19:46
Interview questions for nodejs/javascript.
What is Circular Dependency?
Shallow vs Deep Copy.
Array.sort() - with numbers and strings.
PUT vs PATCH
What is package-lock.json?
---ref - https://medium.com/iquii/good-practices-for-high-performance-and-scalable-node-js-applications-part-1-3-bb06b6204197
What is this? How arrow functions using it to help the binding?
Session Management in Nodejs
API Authentication in Nodejs
Default memory size in NOdejs
@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 ---
@mike1011
mike1011 / Add existing repo to a fresh new Repo
Last active August 1, 2020 01:25
Push existing code to new fresh repo
To begin with, firstly create a new repository on github WITHOUT INITIALIZING it.
## clean up existing repo
rm -rf .git
## re-initialize it with new .git settings
git init
## firstly, dont commit any code, just create/add new sample/readme file and push it to new repo/master
git add README.md
## add newly created fresh repo
git remote add origin [email protected]:username/my-new-master-repo.git