Skip to content

Instantly share code, notes, and snippets.

View psahni's full-sized avatar

Prashant psahni

View GitHub Profile
@psahni
psahni / node.js
Created January 20, 2022 05:54
Sample http server
// Load HTTP module
const http = require("http");
const hostname = "127.0.0.1";
const port = 8000;
// Create HTTP server
const server = http.createServer(function(req, res) {
// Set the response HTTP header with HTTP status and Content type
@psahni
psahni / arch_problems.md
Last active January 12, 2022 06:10
arch_problems

The most common architecture problems are:

  • High availability and resiliency : Make a module to have zero downtime. H.A. often means modules running on different datacenters. The key point generaly is how to handle the latency/timeout
  • Security : How to patch a module live (i.e. with zero downtime)
  • Performance : How to reduce the amount of memory needed for a single module to run
  • Horizontal scalability : How to scale a module to increase its workload
  • Multi-tenancy : How to manage multiple customers in a single instance with a high level of security (avoid data crossing/leak)
  • Write once/Deploy everywhere : The CMDB is a first answer, but isn't enough. For example, how can a developer test locally his module without having the full stack ?
  • KPIs : Provide relevant KPIs for each module to monitor/supervise technical/business issues. Technical KPIs are generally the most straightforward, but business KPI are generally the most value-added ones
@psahni
psahni / react-rails
Created December 19, 2021 11:59
react-rails
https://github.com/reactjs/react-rails#ujs
https://github.com/reactjs/react-rails#ujs
yarn add @babel/preset-react
@psahni
psahni / interview_questions.md
Last active October 29, 2021 08:53
GeneralInterviewQuestions

NoSql Vs SQL

  • Relational Db gives you more structural rigidity, while noSql are more flexible.
  • Normalization works will with Rel db.
  • NoSql databases are horizontally scalable while SQL databases are vertically scalable.
  • NoSql documents may not contain same type of information.
  • NoSql is good for handling big data. It is low cost. Good for mobile app data handling.

NoSql Flexibility

Consider the case where you want to start tracking books’ number of pages: in a SQL database, you would have to change the book model and make sure you add a number of pages to each book instance, but in a NoSQL database, you can just add page numbers to new books as you create their documents (and you could choose to add page numbers for books

@psahni
psahni / rails_code_snippets.rb
Created October 28, 2021 05:23
rails_code_snippets
# app/controllers/application_controller.rb
class ApplicationController < ActionController::API
rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
private
def render_unprocessable_entity_response(invalid)
render json: { errors: invalid.record.errors }, status: :unprocessable_entity
end
end
@psahni
psahni / lazy_load_preloading.js
Created September 30, 2021 08:14
Angular Tutorials
ng g m about --route about --module app.module
app-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: 'about', loadChildren: () => import('./about/about.module').then(m => m.AboutModule) },
{ path: 'users', loadChildren: () => import('./users/users.module').then(m => m.UsersModule) },
{ path: '', redirectTo: '', pathMatch: 'full'}
@psahni
psahni / codility.rb
Last active August 22, 2021 12:32
Codility
Exercise1
p 345.to_s(2).split('') #=> "1001"
```
function getBinary(number) {
let binary = [];
while (number >= 1) {
binary.push(number%2);
number = parseInt(number/2);
@psahni
psahni / Javascript-tidbids.js
Created September 1, 2020 08:36
Javascript tidbids
Javascript tidbids
@psahni
psahni / pineal_gland.md
Last active September 28, 2020 10:27
Pineal Gland

pineal_gland.md

How to decalcify the Pineal Gland

https://medium.com/@humanoriginproject/20-ways-to-heal-pineal-gland-calcification-open-the-third-eye-39c67abc00a2#:~:text=Meditation%20helps%20produce%20deep%20brain,and%20open%20the%20third%20eye.

What is PI

It was well established that the pineal gland releases melatonin to direct circadian rhythms and sleep cycles. However, it’s now known to have a far broader purpose. As a conductor of the endocrine system, the pineal gland controls hormone signals to all organs. It plays a dual neural-endocrine role with functions spanning into all bodily systems. Today, evidence suggests the pineal gland is the master conductor of the physiology of the brain and body.