Skip to content

Instantly share code, notes, and snippets.

View SamsadSajid's full-sized avatar

SamsadSajid

View GitHub Profile
// add the followings in the vscode settings.json
// Credit: James King
"explorer.fileNesting.patterns":{
"*.ts": "${capture}.test.ts",
"*.go": "${capture}_test.go",
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts, ${capture}.test.js",
"*.jsx": "${capture}.test.jsx",
"*.tsx": "${capture}.test.tsx",
"tsconfig.json": "tsconfig.*.json",
Alias Command
gaa git add --all
gcmsg git commit -m
ggp git push origin $(current_branch)
gcm git checkout $(git_main_branch)
grhh git reset --hard
gcb git checkout -b
gsta git stash push
gstd git stash drop
@SamsadSajid
SamsadSajid / clean_code.md
Created May 9, 2022 10:41 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@SamsadSajid
SamsadSajid / scalaTut.scala
Last active April 15, 2022 23:58
Scala tut
// filtering alphanumeric with isLetterOrDigit
// convert a char to lower with toLower
val string: String = "A man, a plan, a canal: Panama"
string.toCharArray.filter(_.isLetterOrDigit).map(_.toLower)
// convert a string to lower case
string.toLowerCase()
// ========================================================================= //
// partial function demo with chaining //
@SamsadSajid
SamsadSajid / dropbox-db-schema.sql
Created December 29, 2021 13:51
Drop box sql schema
CREATE TABLE user(
user_id varchar(50) PRIMARY KEY,
name varchar(50)
);
CREATE TABLE devices(
device_id varchar(50) PRIMARY key,
user_id varchar(50) not null,
foreign key(user_id) references user(user_id)
query {
getCourseDetails(
courseId: 123
) {
title
description
ratings
numOfStudents
reviews {
review
@SamsadSajid
SamsadSajid / cpu-memory-usage-comparison-go-vs-spring-boot.csv
Last active February 9, 2021 11:01
cpu-memory-usage-comparison-go-vs-spring-boot.csv
Proxy type % CPU Number of OS threads Memory (MB)
Spring Boot proxy 7.2 46 124.2
Go Proxy 0.1 26 7.8
Number of Requests Standard Deviation (Spring Boot - Golang) Throughput req/sec (Spring Boot - Golang) Avg (Spring Boot - Golang) Min (Spring Boot - Golang) Max (Spring Boot - Golang) Received KB/sec (Spring Boot - Golang) Avg Bytes (Spring Boot - Golang) Notes
10000 4.14 --- 2.70 100.77801 --- 101.02337 2 --- 0 1 --- 0 208 --- 150 95.14 --- 88.99 966.7 --- 902.0 Ramp up period 100s
20000 7.82 --- 2.79 100.36483 --- 100.47373 3 --- 0 1 --- 0 342 --- 125 94.75 --- 88.50 966.7 --- 902.0 Ramp up period 100s
30000 5.85 --- 2.34 299.98200 --- 301.09599 3 --- 0 1 --- 0 275 --- 119 283.20 --- 265.22 966.7 --- 902.0 Ramp up period 100s
30000 14.20 --- 3.19 150.07654 --- 150.38348 5 --- 0 1 --- 0 495 --- 125 141.68 --- 88.50 966.7 --- 902.0 Ramp up period 200s
30000 5.00 --- 2.89 100.26671 --- 100.31834 2 --- 0 0 --- 0 245 --- 121 94.66 --- 88.37 966.7 --- 902.0 Ramp up period 300s
80000 11.63 --- 3.49 199.98850 --- 200.20772 4 --- 0 1 --- 0 497 --- 168 188.8 --- 176.35 966.7 --- 902.0 Ramp up perio
{
"StartAt": "InvokeLambdaState",
"States": {
"InvokeLambdaState": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-2:XXXXXXX:function:step-function-invoking-lambda-function",
"Parameters": {
"target_value": 9
},
"Next": "CheckStatusFromLambda"
def lambda_handler(event, context):
target_value = event['target_value']
print("Lambda is Invoked with the Integer:: ", target_value)
nums = [-1,0,3,5,9,12]
found, index = search(nums, target_value)
if found: