This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.kunalchhabra | |
| import kotlinx.coroutines.* | |
| fun main() = runBlocking { | |
| val startTime = System.currentTimeMillis() | |
| // Launch a new coroutine in background and continue | |
| val result1 = async { fetchDataFromSource1() } | |
| val result2 = async { fetchDataFromSource2() } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const http = require('http'); | |
| const WebSocket = require('ws'); | |
| const app = express(); | |
| const server = http.createServer(app); | |
| const wss = new WebSocket.Server({ server }); | |
| const PORT = process.env.PORT || 3000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from 'express'; | |
| import http from 'http'; | |
| import { WebSocketServer } from 'ws'; | |
| import fetch from 'node-fetch'; | |
| import Joi from 'joi'; | |
| const app = express(); | |
| const server = http.createServer(app); | |
| const wss = new WebSocketServer({ server }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example | |
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.channels.Channel | |
| import kotlin.random.Random | |
| fun main(){ | |
| val channel = Channel<Int>(2) | |
| runBlocking { | |
| launch { produceValue(channel, 5) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.example | |
| import java.sql.DriverManager | |
| fun main() { | |
| val rows: List<Map<String, Any?>> | |
| DriverManager.getConnection("jdbc:postgresql://localhost:5432/myapp", "myapp", "password").use { connection -> | |
| connection.createStatement().use { stmt -> | |
| stmt.executeQuery("select * from salesforce.account").use { rs -> | |
| rows = generateSequence { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.example | |
| import io.jsonwebtoken.Jwts | |
| import io.jsonwebtoken.security.Keys | |
| import java.time.Duration | |
| import java.util.* | |
| fun main() { | |
| // val secretKey = SIG.HS512.key().build().encoded | |
| val secretKey = "JNu4i@rL����&�#�k\"�\u000Bv0��hn����xH)�\u007FZ�]�&\u0013�]\u0011>8�qB~M�bA�1\u0017Y�U�K" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # main.py | |
| import asyncio | |
| from fastapi import FastAPI, WebSocket, WebSocketDisconnect | |
| app = FastAPI() | |
| async def stream_shell_output(command: str, websocket: WebSocket) -> None: | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/epoll.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <fcntl.h> | |
| #include <unistd.h> | |
| #include <cstring> | |
| #include <iostream> | |
| #include <thread> | |
| #include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Makefile | |
| # '@' added to suppress printing commands on shell | |
| # Variables | |
| CXX = g++ | |
| CXXFLAGS = -O3 | |
| TARGET = main | |
| SRC = main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| typedef struct person | |
| { | |
| const char* name; | |
| int age; | |
| void (*print)(struct person*); | |
| } person_t; |