Skip to content

Instantly share code, notes, and snippets.

View sanikamal's full-sized avatar

Sani Kamal sanikamal

View GitHub Profile
@sanikamal
sanikamal / solution.java
Created September 21, 2022 16:32
Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers.
public class Solution {
public static void print(String[] arr){
for(int i = arr.length - 1; i >= 0; i--){
System.out.print(arr[i] + " ");
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
@sanikamal
sanikamal / odd_even_char.php
Created September 21, 2022 16:27
Given a string,S , of length N that is indexed from 0 to N-1 , print its even-indexed and odd-indexed characters as space-separated strings on a single line
<?php
$handle = fopen ("php://stdin","r");
$t = fgets($handle);
for($i = 0; $i < $t; $i++) {
$input = trim(fgets($handle));
$even = '';
$odd = '';
for($j = 0; $j < strlen($input); $j++) {
@sanikamal
sanikamal / balance.php
Created September 8, 2022 14:55
Figure out initial balance for bank accounts to avoid them going into negative balance after transfer transactions
<?php
function solution($R, $V) {
// write your code in PHP7.0
$minA = 0;
$minB = 0;
$balA = 0;
$balB = 0;
for ($i = 0; $i < strlen($R); $i++) {
if ($R[$i] == 'A') {
$balA += $V[$i];
@sanikamal
sanikamal / steps.md
Last active September 28, 2022 06:32
Automating Infrastructure on Google Cloud with Terraform: Challenge Lab

Overview

  • Task - 1 : Create the configuration files
  • Task - 2 : Import infrastructure
  • Task - 3 : Configure a remote backend
  • Task - 4 : Modify and update infrastructure
  • Task - 5 : Taint and destroy resources
  • Task - 6 : Use a module from the Registry
  • Task - 7 : Configure a firewall

Task - 1 : Create the configuration files

@sanikamal
sanikamal / nltk_tokenize.py
Created January 28, 2021 08:42
Text Tokenization using NLTK
# Text Tokenization using NLTK
from nltk.tokenize import sent_tokenize, \
word_tokenize, WordPunctTokenizer
in_text = 'Use this option to select your font. The Show only monospaced fonts option if selected shortens the list of available fonts.'
# Sentence Tokenization
print(sent_tokenize(in_text))
@sanikamal
sanikamal / BigQuery-ML.txt
Created January 15, 2021 06:55
Create ML Models with BigQuery ML
## Task 1: Create a dataset to store your machine learning models
### dataset name is up to you
cloudshell: bq mk austin
or
create the dataset from bigquery console
## Task 2: Create a forecasting BigQuery machine learning model.
@sanikamal
sanikamal / face_detection.py
Created January 12, 2021 07:39
Face Detection using OpenCV & Python
import cv2
# Load the cascade
face_cascade = cv2.CascadeClassifier('haarcascade/haarcascade_frontalface_default.xml')
# Read the input image
img = cv2.imread('images/sanikamal.jpg')
# Convert into grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Detect faces
faces = face_cascade.detectMultiScale(gray, 1.3, 4)
# Draw rectangle around the faces
@sanikamal
sanikamal / slr.py
Created November 12, 2020 12:11
Simple Linear Regression:Template Code
#Import Library
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
#Load Train and Test datasets
#Identify feature and response variable(s)
x_train=input_variables_values_training_datasets
y_train=target_variables_values_training_datasets
x_test=input_variables_values_test_datasets
@sanikamal
sanikamal / cmcr.txt
Created October 25, 2020 12:19
Getting Started: Create and Manage Cloud Resources: Challenge Lab
Task 1: Create a project jumphost instance
Navigation menu > Compute engine > VM Instance
Task 2: Create a Kubernetes service cluster
gcloud config set compute/zone us-east1-b
gcloud container clusters create nucleus-jumphost-webserver1
@sanikamal
sanikamal / annuity_pay.py
Created August 4, 2020 14:21
Annuity payment
import math
cal_condition = input('What do you want to calculate? \ntype "n" for the number of months, \ntype "a" for the annuity monthly payment,\ntype "p" for the credit principal:\n')
if cal_condition=='n':
# You need 8 years and 2 months to repay this credit!
credit_principal = int(input('Enter the credit principal:\n'))
monthly_pay = float(input('Enter the monthly payment:\n'))
interest = float(input('Enter the credit interest:\n'))
i = interest/(12*100)