Skip to content

Instantly share code, notes, and snippets.

View abhilashak's full-sized avatar
🎯
Focusing

Abhilash A K abhilashak

🎯
Focusing
View GitHub Profile
require 'English'
namespace :db do # rubocop:disable Metrics/BlockLength
task :prevent_disparate_pg_dump_versions => :environment do
allowed_pg_dump_version = '9.6.10'.freeze
`pg_dump --version`
pg_dump_exit_status = $CHILD_STATUS.exitstatus
locally_installed_version = `pg_dump --version`.chomp[/(\d.*)/,1] rescue nil
@abhilashak
abhilashak / encryption.js
Created August 12, 2021 05:55 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@abhilashak
abhilashak / sources.list
Created July 20, 2021 18:49 — forked from malikalichsan/sources.list
/etc/apt/sources.list for ubuntu 19.10
# deb cdrom:[Ubuntu 19.10 _Eoan Ermine_ - Release amd64 (20191017)]/ eoan main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
# deb-src http://id.archive.ubuntu.com/ubuntu/ eoan main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://id.archive.ubuntu.com/ubuntu/ eoan-updates main restricted
@abhilashak
abhilashak / sources.list
Created July 20, 2021 18:32 — forked from rhuancarlos/sources.list
Ubuntu 18.04 Bionic default /etc/apt/sources.list
#deb cdrom:[Ubuntu 18.04 LTS _Bionic Beaver_ - Release amd64 (20180426)]/ bionic main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
@abhilashak
abhilashak / regenerate_credentials.md
Created July 13, 2021 13:54 — forked from db0sch/regenerate_credentials.md
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@abhilashak
abhilashak / rails_new_options_help.md
Created July 9, 2021 05:37 — forked from kirillshevch/rails_new_options_help.md
List of "rails new" options to generate a new Rails 6 application

Run rails new --help to view all of the options you can use to generate new Rails application:

Output for Rails 6+

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated applications)
@abhilashak
abhilashak / bench_str_building.rb
Created June 12, 2021 15:10 — forked from alno/bench_str_building.rb
Benchmark: interpolation vs concatenation in Ruby
require 'benchmark'
count = 1000000
Benchmark.benchmark do |bm|
bm.report("concat") { count.times { 11.to_s + '/' + 12.to_s } }
bm.report("interp") { count.times { "#{11}/#{12}" } }
end
require 'sinatra'
get '/long_process' do
child_pid = Process.fork do
# hard work is done here...
sleep 10
Process.exit
end
@abhilashak
abhilashak / gimp-arrow.scm
Created January 30, 2020 06:39
Gimp Arrow Function
; Berengar W. Lehr ([email protected])
; Medical Physics Group, Department of Diagnostic and Interventional Radiology
; Jena University Hospital, 07743 Jena, Thueringen, Germany
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
@abhilashak
abhilashak / rails_new_help_output.md
Created June 24, 2019 09:50 — 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