Skip to content

Instantly share code, notes, and snippets.

View subrotoice's full-sized avatar
:octocat:
Codding is the beauty of life

Subroto Biswas subrotoice

:octocat:
Codding is the beauty of life
View GitHub Profile

TypeScript 101

TypeScript: JavaScript with Type Checking

  • Error checking at compile time. So less testing like unit test
  • Type checking, Code Completion, Refactoring, New features

Transpilation: .ts --> Com;iler --> .js

Install Typescript

@subrotoice
subrotoice / Nextjs -> ReactComponet -> ReactQuery
Last active March 7, 2025 14:15
Nextjs -> ReactComponet -> ReactQuery
// Nextjs page.tsx
const getPosts = async () => {
const res = await fetch("https://jsonplaceholder.typicode.com/posts");
return res.json();
};
export default async function PostsPage() {
const posts = await getPosts(); // Fetch posts on the server
return <PostsList initialPosts={posts} />;
@subrotoice
subrotoice / Google Calendar API
Last active February 25, 2025 13:58
Google Calender API
// Refresh Token: A long-lived token that is used to obtain a new access token without requiring user re-authentication.
// Access Token: A short-lived token (usually expires in 1 hour) that allows your application to access Google APIs on behalf of a user. It must be included in API requests as an Authorization header (e.g., Bearer <access_token>). Once expired, a new access token must be obtained using the refresh token.
// Step1: Get Authentication code (client_id, redirect_uri, state(custom_info))
https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/calendar%20https://www.googleapis.com/auth/calendar.events&access_type=offline&include_granted_scopes=true&response_type=code&state=11181&redirect_uri=https://vioniko.com/calendar/&client_id=346714970482-fe89v693ot2oos92ujeb6o14nkmvrai2.apps.googleusercontent.com&prompt=select_account
// Step2: Redirect url make auth code to refresh token
if (isset($_GET['code']) and $_GET['code'] != '') {
$userId = $_GET['state'];
# Initial git setup || Run For the first time.
git config --global user.name "subrotoice"
git config --global user.email "[email protected]" // Every space has meaning: git config --global user.email [email protected] will work
git config --list (Show all config) || git config user.name //(Show User Name)
# Ch-2: Creating Snapshots (do Commit) | https://prnt.sc/zIIkMN39czOk | stage area green , unstated red | https://prnt.sc/9_BUPJ6VX53L
1. Working Directory: Where you work on your files locally || "Project Folder" another name
2. Staging Area: A temporary holding area - Where proposed change for next commit
3. Repository (Store Snapshots Parmanently) | Store what content in the last stage area
Task 1:
function palindrome(input) {
var length = input.length;
if (length == 1) return true;
if (input[0] != input[length - 1]) return false;
var subStr = input.slice(1, length - 1);
return palindrome(subStr);
}
Task 1:
Write a function that does the following task.
You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string. Return the shuffled string.
Ans:
console.log(stringOrganize("mamacode", [4, 5, 6, 7, 0, 1, 2, 3]));
function stringOrganize(string, intArray) {
let newString = "";
const length = intArray.length;
https://docs.google.com/presentation/d/1wPOX0xevM-HGij9XdHUh4elh9N3OZh5hJ3w3mpzHbOE
training-d.nothi.gov.bd
114283 এ টি এম আল ফাত্তাহ Password: 02522016 (Admin)
200000002946 মোঃ তহুরুল হাসান Password: 02522016
200000002968 মি. ইশতিয়াক হোসাইন Password: 02522016
200000075964 নাদিয়া জামান নিসা Password: 02522016
D-Nothi ID: https://drive.google.com/file/d/12Rr20smVmfLzari_KjKtC-PgIPkNESQg/view?usp=sharing
Digital File Number: https://docs.google.com/document/d/1RppnLgOMa9vO1V0qtJVywSfTLTHeNWQWA9Xt9klRKxY/edit
@subrotoice
subrotoice / chatGPT
Last active February 22, 2024 10:03
chatGPT
https://docs.google.com/document/d/1wUqUDc8BHRRpRwTPHOIcnmbdcBmjTnC8WNPGuPukG-c/edit?usp=sharing
https://www.youtube.com/watch?v=jC4v5AS4RIM
Persona +
Context: Need to limit the endless possiblilities
Task: Always start the Task sentence with an Action Verb. e.g. Generate, Give, Write, Analyze, etc
Exemplar +
Format +
Tone
https://github.com/subrotoice/flex-grid
https://css-tricks.com/snippets/css/a-guide-to-flexbox
https://css-tricks.com/snippets/css/complete-guide-grid
https://www.youtube.com/watch?v=kRS5ficucNM
https://www.youtube.com/watch?v=18VLSXfsj94 (Best: Where to use Flex & Grid)
# Flex Box
.container {
display: flex;
flex-direction: row | row-reverse | column | column-reverse;
NB: Any Rule start with "RewriteRule ^" + Type url in browser + PHP file need to load
# .htaccess to get the value from url ie. edeves.com/myValue
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?id=$1
# index.php
<?php
if(isset($_GET["id"])){
if($_GET["id"]!="") {
echo "User ID: " . $_GET["id"]; // User ID: myValue