Skip to content

Instantly share code, notes, and snippets.

View realms-ai's full-sized avatar

Realms AI realms-ai

View GitHub Profile
@realms-ai
realms-ai / flatten_array.rb
Created August 7, 2018 06:08
Flatten array Citrusbyte
/#
How to Run the Program
1. Add list of arrays in the list below to test code
2. Execute the file from it's location
$ ruby array_flatten.rb
You will get your results as below
array: [1, 2, 3, [4, 5, 6, 7, [8, 9]]]
flatten_array: [1, 2, 3, 4, 5, 6, 7, 8, 9]
# Single Stack Multi Array
=begin
Question: Remove all consecutive characters from string whose count is even
Input
array = [
'azxxzyyyddddyzzz',
'xyzzyyyzx',
'cbbbaaaabbbccc'
]
How it works
@realms-ai
realms-ai / range_data_in_different_time_frames.rb
Created October 31, 2018 20:43
This store procedure gives data for graphs in different time frames for better analytics on IOT data
class GetRangeData < ActiveRecord::Migration[5.1]
def up
execute "
CREATE OR REPLACE FUNCTION public.GetRangeData(
thng_id INTEGER,
parameter VARCHAR,
duration INTEGER, -- 0 -> months, 1 -> weeks, 2 --> days, 3 --> hours
mnth INTEGER, -- 0 -> all_months, 1 -> Jan, 2 --> Feb, 3 --> Mar, ...., 12 --> Dec
yr INTEGER,
parameter_division INTEGER DEFAULT 1,
@realms-ai
realms-ai / elastic-search.js
Created December 22, 2018 01:30
Elastic Search Query in Node.js
/**
* Making a Search Condition for Crawler Product in Elastic Search
*/
var search_condition = function(input){
return new Promise(function(resolve, reject) {
// Variables needed to execute functions and make condition
var conditions = {limit: input.limit || 10, offset: input.offset || 0 },
condition = [{term: {group_ids: input.group_id}}];
Promise.all([channel_group_conditions(input), pim_conditions(input), range_conditions(input), crawler_conditions(input)])
.then(function(condition){
@realms-ai
realms-ai / github_multiple_users.md
Last active June 24, 2023 19:32
Handle Multiple Github users

Handle Multiple Github Users

# Other github account: Simer   
Host *-s           
   HostName github.com      
   IdentityFile ~/.ssh/simer    
   IdentitiesOnly yes

# Other github account: UntroddenLabs 
@realms-ai
realms-ai / anyNumberSum.js
Last active June 12, 2023 08:56
This code gives you a sub-array of n-element whose sum is equal to the targetSum. TargetSum can be an array too to (In case of array, it returns the Object with targetSum as keys and value as an array of numbers whose sum is equal to the targetSum).
// num represents the no of element needed in sub-array whose total is equal to targetSum
function anyNumberSum(array, targetSum, num = 3) {
// write your code here
const hash = {} // = {'1': [], '2': [], '3': []}
let nArr = Array.from({length: num}, (v, i) => {
hash[i+1] = {}
return i + 1
})
nArr = nArr.reverse()
nArr.shift()
@realms-ai
realms-ai / docker-practice.md
Created June 24, 2023 19:29
Docker Commands to write a docker file along with compose files

Docker

Creating Network

Network helps container communicate with each other via a bridge

docker network create networkName
docker run mongo --net networkName
@realms-ai
realms-ai / github-action.md
Created June 24, 2023 19:30
Practicing Github to enable CI/CD for the applications

Github Actions

This is a tool to automate CI/CD of projects on Github Documentation

  • File stays in .github/workflows
name: nameOfTheActionService (Java CI with Gradle)
@realms-ai
realms-ai / kubernetes-practice.md
Last active June 27, 2023 22:33
Practicing kubernetes along with commands to do 80% of the tasks

Kubernetes

  • Open source container orchestration tool
  • Features
    • High Availability
    • Scalability or high performance
    • Disaster Recovery - backup and restore

K8s Architecture

@realms-ai
realms-ai / google-cloud-practice.md
Created June 24, 2023 19:37
Basic Google Cloud Service knowledge

Google Cloud

1. Virtual Machines

  • Pre-emptilbe (Just like Spot instances)
  • Committed Use Discounts (Reserve Instances)

2. IAM

  • Organization
  • Folders
  • Projects