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 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
| 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
| 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
| 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
| package org.example; | |
| // <dependency> | |
| // <groupId>org.apache.httpcomponents</groupId> | |
| // <artifactId>httpclient</artifactId> | |
| // <version>4.5.14</version> | |
| // </dependency> | |
| // <dependency> | |
| // <groupId>org.json</groupId> | |
| // <artifactId>json</artifactId> |
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 javax.crypto.Cipher; | |
| import javax.crypto.SecretKey; | |
| import javax.crypto.SecretKeyFactory; | |
| import javax.crypto.spec.PBEKeySpec; | |
| import javax.crypto.spec.SecretKeySpec; | |
| import java.security.spec.KeySpec; | |
| import java.util.Base64; |
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 org.apache.http.HttpEntity; | |
| import org.apache.http.client.methods.CloseableHttpResponse; | |
| import org.apache.http.client.methods.HttpGet; | |
| import org.apache.http.impl.client.CloseableHttpClient; | |
| import org.apache.http.impl.client.HttpClients; | |
| import org.apache.http.util.EntityUtils; | |
| import org.json.JSONArray; |
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 ReactMarkdown from "react-markdown"; | |
| import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; | |
| import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; | |
| import Styled from "styled-components"; | |
| const Code = Styled.code` | |
| color: red; | |
| font-size: 0.8rem; | |
| padding: 0.2rem 0.4rem; | |
| background-color: #EDEDEB; |
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 string | |
| import secrets | |
| class PasswordGenerator: | |
| """ | |
| Generate a random password with the following parameters: | |
| :param length: Length of the password | |
| :param min_digits: Minimum number of digits in the password | |
| :param min_uppercase: Minimum number of uppercase letters in the password |