Skip to content

Instantly share code, notes, and snippets.

View tannakartikey's full-sized avatar
🏠
Working from home

Kartikey Tanna tannakartikey

🏠
Working from home
View GitHub Profile
@tannakartikey
tannakartikey / learner_collection.rb
Created August 15, 2023 18:31
Validate and create or import multiple records in Rails
# app/models/learner_collection.rb
class LearnerCollection
include ActiveModel::Model
attr_accessor :learners, :current_user
def initialize(learners_attributes: [], **kw_args)
super
end
@tannakartikey
tannakartikey / complete_reset.rake
Last active August 11, 2023 16:08
Destroy the schema and re-create the database from scratch
namespace :db do
desc 'reset the database by dropping the schema'
task complete_reset: :environment do
raise unless Rails.env.local?
FileUtils.rm_f('db/schema.rb')
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:migrate'].invoke
Rake::Task['db:seed'].invoke
@tannakartikey
tannakartikey / Dockerfile
Created April 5, 2023 08:42
Rails 7.1 default Dockerfile (no NodeJS)
# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.2.0
FROM ruby:$RUBY_VERSION-slim as base
# Rails app lives here
WORKDIR /rails
# Set production environment

Keybase proof

I hereby claim:

  • I am tannakartikey on github.
  • I am tannakartikey (https://keybase.io/tannakartikey) on keybase.
  • I have a public key ASAFTdi0U4QFng4ULAHyBwNVImv8O9BpLxbDfSHXCU3vXQo

To claim this, I am signing this object:

@tannakartikey
tannakartikey / _invoice.html.erb
Created September 30, 2020 03:53
Gists for the blog post
<!-- app/views/invoices/_invoice.html.erb -->
<% unless (invoice.total == 0) %>
<tr>
<td><%= link_to invoice.number, invoice_path(invoice.id) %></td>
<td><%= invoice.date %></td>
<td><%= number_to_currency(invoice.total, negative_format: "(%u%n)") %></td>
<td><%= invoice.period_start %> to <%= invoice.period_end %></td>
<td><%= invoice.paid? ? 'Paid' : 'Unpaid' %></td>
</tr>
@tannakartikey
tannakartikey / 🐱 GitHub Data
Last active July 8, 2020 22:02
⚡️ Github Stats
🏆 801 Contributions in year 2020
📦 Used 1023 MB in GitHub's Storage
📜 6 Public Gists
🔑 2 Public Keys
💼 Opted to Hire
@tannakartikey
tannakartikey / recent-activity.txt
Last active October 29, 2020 18:42
⚡️ Recent activity
💪 Opened PR #1 in excid3/uppy-activestorage-upload
❗️ Opened issue #93 in razorpay/razorpay-ruby
❗️ Opened issue #77 in pattex/jekyll-tagging
❗️ Closed issue #4 in tannakartikey/tannakartikey.github.io
❗️ Closed issue #5 in tannakartikey/tannakartikey.github.io
Started POST "/admin/action/1/edit" for ::1 at 2018-06-20 16:57:17 +0530
Processing by RailsAdmin::MainController#edit as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ghj7mN6I97ZsUsFr9kkE5rnhvl+G9OClQTwbKYbfffWXnqXcDPwst4Hwc7OtlECyzSa/cU5mQ6RQGHVE4mAVIg==", "return_to"=>"http://localhost:9999/admin/action", "_save"=>"", "model_name"=>"action", "id"=>"1"}
Action Load (0.7ms) SELECT "actions".* FROM "actions" WHERE "actions"."id" = $1 ORDER BY data ->> 'date' DESC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Completed 500 Internal Server Error in 28ms (ActiveRecord: 0.7ms)
TypeError (no implicit conversion of Symbol into Integer):
@tannakartikey
tannakartikey / list-of-postgres-command.md
Last active March 23, 2017 14:44
I am going to put all the commands I use while playing with Postgres. So that you don't have Google it frequently like I did.

List of Postgress Commands

Postgres Cheatsheet

All you might need while playing with Postgres

psql -U <username> : login using console (Windows)
'CREATE DATABASE <db_name>; : create database
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name='<your_table_name>' ORDER BY column_name ASC; : list all table columns in alphabetical(sorted) order

@tannakartikey
tannakartikey / designer.html
Last active August 29, 2015 14:27
designer
<link rel="import" href="../topeka-elements/theme.html">
<link rel="import" href="../topeka-elements/topeka-resources.html">
<link rel="import" href="../topeka-elements/topeka-app.html">
<link rel="import" href="../topeka-elements/topeka-datasource.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>