Skip to content

Instantly share code, notes, and snippets.

View manojmj92's full-sized avatar

Manoj M J manojmj92

View GitHub Profile
@manojmj92
manojmj92 / mvv.md
Last active July 23, 2023 09:49
Documents to carry to Delhi/Mumbai/Bangalore Netherlands embassy for Highly Skilled Migrant (MVV) visa for Indians

Documents to carry to Delhi/Mumbai/Bangalore Netherlands embassy for Highly Skilled Migrant (MVV) visa

Valid for Indian citizens only.

Note: Written as per MVV visa interview experience on 9th December, 2021 for a couple. List of items may have changed in the meanwhile - please verify the list of items required by yourself. Please do not consider this list exhaustive.

For the primary visa holder:

  • 2 photos taken as per Netherlands specification for photos
  • DTDC AWB number (details here)
number_of_records time_taken(in ms)
500 105
1000 203
5000 900
10000 1850
20000 3300
# In the controller#action
respond_to do |format|
format.csv { send_data(generate_csv(column_names, records)) }
end
def generate_csv(column_names, records)
CSV.generate do |csv|
csv << column_names # add headers to the CSV
records.each do |record|
csv << record.attributes.values_at(*column_names)
end
end
end
@manojmj92
manojmj92 / sql.rb
Last active January 23, 2019 07:26
result = SqlConnection.execute(
"SELECT COLUMN_NAMES FROM JOINED_TABLES WHERE CONDITIONS_ARE_MET"
)
fibonacci = Enumerator.new do |sequence|
a = b = 1
loop do
sequence << a
a, b = b, a + b
end
end
def generate_csv(column_names, records)
Enumerator.new do |csv|
csv << column_names.to_csv # add headers to the CSV
records.each do |record|
csv << record.attributes.values_at(*column_names).to_csv
end
end
end
# In the controller#action
respond_to do |format|
format.csv { render_streaming_csv(generate_csv(column_names, records)) }
end
def render_streaming_csv(csv_enumerator)
# Delete this header so that Rack knows to stream the content.
headers.delete("Content-Length")
# Do not cache results from this action.
desc 'destroys employee update'
task :employee_update_remove => :environment do
puts "Starting Migration"
records = EmployeeUpdate.last(3)
records.each do |record|
puts "Going to destroy record #{record.id}"
record.destroy
end
puts "Migration Ended"
end
@manojmj92
manojmj92 / sandbox.rake
Created November 28, 2018 16:01
sanbox rake
desc 'Run rake tasks with sandboxing'
task sandbox: :environment do
# Start transaction
ActiveRecord::Base.connection.begin_transaction(joinable: false)
puts "🆒 Sandbox Mode: ON 🆒"
# Run your task
Rake.application.invoke_task(ARGV.delete_at(1))