This file contains 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
"use strict"; | |
/** | |
* @file redis.ts | |
* @fileoverview Async Redis functions with JSDoc annotations | |
* @author Reinaldy Rafli <[email protected]> | |
* @copyright 2021 MIT | |
*/ | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
const path_1 = require("path"); | |
const RedisModule = require("redis"); |
This file contains 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
/** | |
* @file redis.ts | |
* @fileoverview Async Redis functions with JSDoc annotations | |
* @author Reinaldy Rafli <[email protected]> | |
* @copyright 2021 MIT | |
*/ | |
import { fileURLToPath } from 'url'; | |
import * as RedisModule from 'redis'; | |
import * as dotenv from 'dotenv'; | |
const envPath = fileURLToPath(new URL('.env', import.meta.url)); |
This file contains 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
/** | |
* @file redis.ts | |
* @fileoverview Async Redis functions with JSDoc annotations | |
* @author Reinaldy Rafli <[email protected]> | |
* @copyright 2021 MIT | |
*/ | |
import path from 'path'; | |
import * as RedisModule from 'redis'; | |
import * as dotenv from 'dotenv'; |
This file contains 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 type { IncomingMessage, ServerResponse } from 'http'; | |
import type { EventEmitter } from 'events'; | |
import yaml from 'yaml'; // npm install yaml | |
type Next = (err?: any) => void; | |
type RequestWithBody<T = any> = IncomingMessage & { body?: T } & EventEmitter | |
async function parseYaml(req: RequestWithBody, _: ServerResponse, next: Next) { | |
try { | |
let body = ''; |
This file contains 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 main | |
// The program will generate a random integer between 1 and 100. | |
// It will then prompt the player to enter a guess. | |
// After a guess is entered, the program will indicate whether the guess is too low or too high. | |
// If the guess is correct, the game will print a congratulatory message and exit. | |
import ( | |
"fmt" | |
"math/rand" |
This file contains 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
randomNumber = rand(100) | |
puts "The random number is: #{randomNumber}" | |
correct = false | |
until correct do | |
print "Guess the number: " | |
input = gets | |
if input.to_i > randomNumber | |
puts "No, it's smaller than that. Try again." |
This file contains 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 { test } = require('uvu') | |
const assert = require('uvu/assert') | |
const {main} = require('../src/parser') | |
test('1', () => { | |
const p = main('price lt 10000') | |
assert.equal(p, { | |
value: 'lt', | |
children: [ | |
{ |
This file contains 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
// This is a coffee shop. | |
// We can order coffee and see the menu. | |
// | |
// The problem is that this coffee shop | |
// code is not complete yet. | |
// | |
// This is just to train your skills on | |
// dealing with structs, variables, | |
// array/slices, methods, and types. | |
// |
This file contains 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
// Now we're creating a fintech (financial technology) company | |
// that you can store money to and can buy stocks. | |
// | |
// Like the previous challenge (well, not really lol - more like a homework) | |
// we use struct and methods to do things. Now we'll kind of | |
// do the same thing. | |
package main | |
import ( | |
"fmt" |
This file contains 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 main | |
import ( | |
"fmt" | |
"log" | |
"sync" | |
"time" | |
) | |
func main() { |
OlderNewer