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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Test HTTP2 Protocol</title> | |
| <link rel="stylesheet" href="style.css"> | |
| <script src="scripts/d3.js"></script> |
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 HTTPS_PORT = 3000; | |
| const HTTP2_PORT = 3001; | |
| /** | |
| * create an http2 server | |
| */ | |
| const http2 = require("http2"); | |
| // read and send file content in the stream | |
| const sendFile = (stream, fileName) => { |
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
Show hidden characters
| { | |
| "extends": "airbnb", | |
| "parser": "babel-eslint", | |
| "plugins": ["react", "jsx-a11y", "import"], | |
| "env": { | |
| "browser": true, | |
| "jest": true, | |
| "node": true | |
| }, | |
| "settings": { |
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
| /** | |
| * Common fetchAPI which can handle GET and POST method | |
| * Content-Type is set to 'application/json' | |
| * payload should be in JSON format | |
| */ | |
| export async function fetchAPI(url, data, method = 'POST') { | |
| // raise an error if url is missig | |
| if (!url) { | |
| throw new Error('url is missing'); | |
| } |
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
| // convert a key string to camelcase | |
| function toCamelCase(str) { | |
| // when str is not define reuturn | |
| if (!str) { | |
| return str; | |
| } | |
| let letters = str.split(""); | |
| let idx = letters.indexOf("_"); | |
| while (idx > -1) { |
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 main | |
| import ( | |
| "encoding/base64" | |
| "fmt" | |
| "net/http" | |
| "strings" | |
| "github.com/gin-gonic/gin" | |
| ) |
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
| fn modPow(base: u64, exponent: u64, modulus: u64) -> u64 { | |
| if m == 1 { | |
| return 0; | |
| } | |
| let mut r = 1; | |
| let mut pow = exponent; | |
| let mut num = base % modulus; | |
| loop { | |
| if pow == 0 { | |
| break; |
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
| fn fibonacci(term: u64) -> u64 { | |
| let (_, tot) = (0..=term).fold((0_u64, 1_u64), |acc, t| { | |
| match t { | |
| 0 => (0_u64, 0_u64), | |
| 1 => (0, 1_u64), | |
| 2 => (1, 1_u64), | |
| _ => { | |
| let (prev, tot) = acc; | |
| (tot, tot + prev) |
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
| // URL Parser | |
| #![allow(dead_code, unused_imports)] | |
| use std::io; | |
| use std::num::ParseIntError; | |
| use std::str::FromStr; | |
| #[derive(Debug, PartialEq, Eq)] | |
| enum CustomError { |
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
| use flate2::read::GzDecoder; | |
| use flate2::write::GzEncoder; | |
| use flate2::Compression; | |
| use std::fs::File; | |
| use tar::Archive; | |
| const TEST_DIR: &str = "test"; | |
| const TAR_FILE_NM: &str = "test.tar.gz"; | |
| // compress input directory into a _.tar.gz file |
OlderNewer