Skip to content

Instantly share code, notes, and snippets.

@abhinaykumar
abhinaykumar / Jest-encountered-an-unexpected-token.md
Created December 13, 2021 09:22
Jest encountered an unexpected token (when importing MD format file)
<!-- ERROR -->
Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.
@abhinaykumar
abhinaykumar / Http.rb
Created June 26, 2022 04:21
Common class to make HTTP requests using Faraday. Parallel POST requests with Faraday and Typhoeus Hydra.
class Http
class << self
def send_request(url, options = {}, verb = :get)
headers = options[:headers]
headers = headers.present? ? default_headers.merge(headers) : default_headers
body = options[:body].presence
body = body.to_json if headers['Content-Type'] == 'application/json'
query = options[:query].presence
payload = verb == :get ? query : body
@abhinaykumar
abhinaykumar / map-fontawesome-icon-with-social-media-url.json
Last active September 5, 2022 03:41
Mapping of fontawesome icons with top social medial url
{
"facebook.com": "<i class='fa-brands fa-facebook-f'></i>",
"twitter.com": "<i class='fa-brands fa-twitter'></i>",
"instagram.com": "<i class='fa-brands fa-instagram'></i>",
"linkedin.com": "<i class='fa-brands fa-linkedin-in'></i>",
"snapchat.com": "<i class='fa-brands fa-snapchat'></i>",
"tumblr.com": "<i class='fa-brands fa-tumblr'></i>",
"pinterest.com": "<i class='fa-brands fa-pinterest-p'></i>",
"reddit.com": "<i class='fa-brands fa-reddit-alien'></i>",
"tiktok.com": "<i class='fa-brands fa-tiktok'></i>",
@abhinaykumar
abhinaykumar / how-to-copy-aws-rds-to-local.md
Created September 24, 2022 03:58 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@abhinaykumar
abhinaykumar / scrapper.ruby
Created August 25, 2023 07:34
Scrape page with Nokigiri
# https://soravjain.com/digital-marketing-agencies-india/
data = []
email= nil
address=nil
phone=nil
website=nil
services=nil
brands=nil
doc.css("p").each do |x|
if x.content.start_with?("Services")