Skip to content

Instantly share code, notes, and snippets.

View achukka's full-sized avatar
👋
Let's Learn

Aditya Chukka achukka

👋
Let's Learn
View GitHub Profile
@achukka
achukka / createmaps.java
Created February 22, 2023 17:45
Create Maps using a reduce operation
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Arrays;
public class MyClass {
public static void main(String args[]) {
List<String> values = List.of("1", "2", "3", "4", "5", "5", "2");
Map<String, List<String>> map = values.stream()
@achukka
achukka / datasource.ts
Last active June 3, 2021 03:56
Add PostgreSQL to Express Server
import pg from "pg";
import { item, user } from "./models";
import { CONFIG } from "./pgenv";
const to_item = (itemRow: pg.QueryResult<any>): item => {
return {
id: parseInt(itemRow["id"]),
task: itemRow["task"],
priority: parseInt(itemRow["priority"]),
@achukka
achukka / datasource.ts
Last active May 30, 2021 04:15
Create data source for tdsvc
import { readFileSync, writeFileSync } from "fs";
import { item, user } from "./models";
const ITEMS_SOURCE = "data/items.json";
const USERS_SOURCE = "data/users.json";
const load_items = (): Array<item> => {
const data = readFileSync(ITEMS_SOURCE, "utf-8");
if (!data) {
return [];
@achukka
achukka / index_1.ts
Last active May 30, 2021 05:18
Route for Items in Express Server
import express from "express";
import { router as item_router } from "./items";
const app = express();
const port = 3000;
app.use("/tdsvc/item", item_router);
app.listen(port, (err?) => {
if (err) {
@achukka
achukka / index.ts
Created May 26, 2021 03:39
A Basic Node Express
import express from "express";
const app = express();
const port = 3000;
app.get("/", (req, res) => {
res.send("You are listening from express server");
});
app.listen(port, (err) => {
if (err) {
@achukka
achukka / App.tsx
Created May 13, 2021 04:07
Gist for App with AddItem and Display
import React from "react";
import AddItem from "./AddItem";
import ToDoList, { Item } from "./ToDoList";
const initialList = [
{
task: "Pick up Milk",
priority: 1,
},
{
@achukka
achukka / App.tsx
Created May 13, 2021 03:39
Gist for App in ToDoList
import React from "react";
import ToDoList, { Item } from "./ToDoList";
const initialList = [
{
task: "Pick up Milk",
priority: 1,
},
{
task: "Buy Eggs",
@achukka
achukka / AddItem.ts
Last active May 13, 2021 04:08
Gist for AddItem in ToDoList project
import React from "react";
import { Item } from "./ToDoList";
const isValid = (item: Item): boolean => {
return item.task !== "" && item.priority !== -1;
};
class AddItem extends React.Component<{ addItem: any }, Item> {
constructor(props: any) {
super(props);
@achukka
achukka / ToDoListSorted.ts
Last active May 13, 2021 03:23
sorted to do list
import React from "react";
export interface Item {
task: string;
priority: number;
}
const getTableStyleProps = (): {} => {
return {
@achukka
achukka / interace.ts
Last active May 12, 2021 03:47
Gist for create to do list
export interface Item {
task: string;
priority: number;
}