Skip to content

Instantly share code, notes, and snippets.

Avatar

Le Dinh Cuong cuongld2

View GitHub Profile
@cuongld2
cuongld2 / example.html
Created Dec 2, 2020
Example page keep reloading
View example.html
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Vingen · Vingen documentation site</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="Vingen documentation site"/><meta property="og:title" content="Vingen · Vingen documentation site"/><meta property="og:type" content="website"/><meta property="og:url" content="undefined/documentation/index.html"/><meta property="og:description" content="Vingen documentation site"/><meta name="twitter:card" content="summary"/><meta http-equiv="refresh" content="0; URL=/documentation/en/powerpoint/how_to_do_workflow.html"/><link rel="shortcut icon" href="/documentation/img/favicon.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"/><script src="/documentation/js/scrollSpy.js"></script><link rel="stylesheet" href="/documentation/css/main.css"/><script src="
@cuongld2
cuongld2 / k6.js
Created Nov 27, 2020
k6 test code
View k6.js
import http from 'k6/http';
import { sleep } from 'k6';
export let options = {
vus: 1000,
duration: '300s',
@cuongld2
cuongld2 / query.json
Created Nov 23, 2020
Query example with variables
View query.json
query($filter: JSON) {
family_history(filter: $filter){
submitter_id
auth_resource_path
family_history_id
}
}
@cuongld2
cuongld2 / unmarshal_dynamic_key.go
Last active Nov 16, 2020
Unmarshal dynamic key in JSON
View unmarshal_dynamic_key.go
func (s ResultObject) UnmarshalJSON(data []byte) map[string]interface{} {
var z map[string]interface{}
if err := json.Unmarshal(data, &z); err != nil {
fmt.Println(string(data[:]))
panic(err)
}
return z
}
@cuongld2
cuongld2 / crowdin.yaml
Created Nov 16, 2020
Crowdin configuration file example
View crowdin.yaml
project_id: $PROJECT_ID #open project settings and go to API section
api_token: $API_TOKEN #open profile settings and go to API & SSO > New Token > create Token
base_path: "./"
base_url: "https://api.crowdin.com"
preserve_hierarchy: true
files:
-
source: '/website/docs/**/*.md' #source files filter
translation: '/website/translated_docs/%locale%/**/%original_file_name%' #where translations are stored
@cuongld2
cuongld2 / scanline.go
Last active Nov 10, 2020
Scan line maxCapacity
View scanline.go
scanner := bufio.NewScanner(file)
const maxCapacity = 512*1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
// The bufio.ScanLines is used as an
// input to the method bufio.Scanner.Split()
// and then the scanning forwards to each
// new line using the bufio.Scanner.Scan()
@cuongld2
cuongld2 / test.rs
Created Nov 6, 2020
Rust replace string
View test.rs
let path = Path::new("resources/graphql_queries_popular.txt");
let path_new_file = Path::new("resources/graphql_generated_queries.txt");
let file = File::create(path_new_file).unwrap();
let mut file = LineWriter::new(file);
let mut reader = my_reader::BufReader::open(&path).unwrap();
let mut buffer = String::new();
while let Some(line) = reader.read_line(&mut buffer) {
use regex::{Regex,Captures};
@cuongld2
cuongld2 / max.scala
Created Nov 3, 2020
max function recursive
View max.scala
def max(xs: List[Int]): Int = {
if (xs.isEmpty)
throw new NoSuchElementException
else if (xs.length == 1)
xs.head
else
if (xs.head > max(xs.tail)) xs.head else max(xs.tail)
}
}
@cuongld2
cuongld2 / sum.scala
Created Nov 3, 2020
sum recursive functions
View sum.scala
def sum(xs: List[Int]): Int = {
if( xs.isEmpty)
0
else
xs.head + sum(xs.tail)
}
View unittest.java
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
properties = "blog-service.base-url:http://localhost:8082",
classes = BlogServiceClient.class)
@ContextConfiguration
public class UnitTest {
@Autowired
private BlogServiceClient blogServiceClient;