Skip to content

Instantly share code, notes, and snippets.

View cuongld2's full-sized avatar

Le Dinh Cuong cuongld2

View GitHub Profile
type SymbolSearchXml struct {
XMLName xml.Name `xml:"eSearchResult"`
Count int `xml:"Count"`
RetMax int `xml:"RetMax"`
RetStart int `xml:"RetStart"`
IdList []int `xml:"IdList>Id"`
TranslationSet string `xml:"TranslationSet"`
TranslationStack TranslationStackXml `xml:"TranslationStack"`
QueryTranslation string `xml:"QueryTranslation"`
}
@cuongld2
cuongld2 / variant_id.go
Created June 5, 2021 07:36
Retrieve variant_id from complex json
var mapResp map[string]interface{}
if err := json.NewDecoder(res.Body).Decode(&mapResp); err == nil {
// fmt.Println(`&mapResp:`, &mapResp, "\n")
// fmt.Println(`mapResp["hits"]:`, mapResp["hits"])
for _, value := range mapResp["hits"].(map[string]interface{}) {
if reflect.TypeOf(value).Kind() != reflect.Float64 {
for _, each := range value.([]interface{}) {
@cuongld2
cuongld2 / quick_sort.jl
Created May 22, 2021 02:59
quick sort implementation in julia
function quick_sort(list)
if length(list)<2
return list
end
pivot = list[1]
greater = []
lesser = []
for i = 2:length(list)
if pivot <= list[i]
append!(greater,list[i])
@cuongld2
cuongld2 / binary_search.jl
Created May 21, 2021 11:01
binary search using recursion in julia language
k=0
g=0
t=0
function binary_search(list,item,len_list)
global k
global g
global t
if list==[]
return 0
end
@cuongld2
cuongld2 / maximum.jl
Created May 20, 2021 10:34
Find maxium number in a list - julia
function find_maximum(array)
global maximum
if length(array)==0
return maximum
end
if maximum<last(array)
maximum=last(array)
end
println(array)
@cuongld2
cuongld2 / length_array.jl
Created May 20, 2021 09:47
get length of array in julia using recursive
function get_length(array)
if array==[]
return 0
end
deleteat!(array, last(array))
return 1 + get_length(array)
end
println(get_length([1,2,3,4]))
@cuongld2
cuongld2 / sum.jl
Created May 20, 2021 09:10
recursive sum function in julia
function sum(array)
k=length(array)
if k==0
return 0
end
if k==1
return array[k]
end
return array[k] + sum(array[1:k-1])
end
@cuongld2
cuongld2 / binary_search.jl
Created May 13, 2021 10:03
Binary search in Julia
function binary_search(list,item)
low = 0
high = size(list)[1]
while low <= high
mid = (low + high)
guess = list[mid]
if guess == item
return mid
end
if guess > item
@cuongld2
cuongld2 / main.rs
Created April 17, 2021 09:02
Code demonstration for getting good stock
#[path="models/cafef_liveboard.rs"]
pub mod cafef_liveboard;
use reqwest::header::CONTENT_TYPE;
use reqwest::header::USER_AGENT;
use regex::Regex;
use chrono::prelude::*;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use crate::cafef_liveboard::*;
@cuongld2
cuongld2 / mutation_assessor.rs
Created March 24, 2021 03:35
Model for mutation assessor
extern crate reqwest;
extern crate tokio;
extern crate serde_json;
extern crate serde;
use serde::{Deserialize};
#[derive(Deserialize, Debug)]