Skip to content

Instantly share code, notes, and snippets.

@imxiaohui
imxiaohui / string-conversion.rs
Created April 27, 2022 14:54 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@imxiaohui
imxiaohui / test_bowling_game.csv
Created April 25, 2022 22:59 — forked from Vaguery/test_bowling_game.csv
test data for bowling score exercise
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4 in line 1.
# bowling score data
# score,roll_1,roll_2,roll_3 ...
33,0,1,1,2,1,5,0,1,0,3,3,4,6,0,1,4,0,0,1,0
34,4,2,0,1,4,3,0,1,1,0,1,0,4,2,7,3,0,0,1,0
35,1,2,3,3,1,0,0,1,1,3,1,0,7,0,1,4,2,0,5,0
36,0,0,1,0,1,4,1,2,3,4,0,6,0,1,2,0,5,4,0,2
37,2,1,4,0,9,1,1,2,0,0,1,2,0,1,4,3,0,0,5,0
38,4,0,2,1,2,1,6,0,1,0,3,1,0,8,7,0,0,0,2,0
39,6,2,0,0,3,4,0,2,8,0,1,0,0,3,2,3,4,0,1,0
40,4,2,2,0,2,3,0,3,2,0,0,1,2,3,8,0,0,0,3,5
@imxiaohui
imxiaohui / current-weather-openweathermap.js
Created June 16, 2021 13:18 — forked from chuckreynolds/current-weather-openweathermap.js
Open Weather Map API Current Weather, node js, javascript, axios
// API specific settings https://openweathermap.org/current
const API_URL = 'https://api.openweathermap.org/data/2.5/weather';
const API_KEY = '';
const LOCATION_CODE = '';
const FULL_API_URL = `${API_CURRENT_URL}?id=${LOCATION_CODE}&appid=${API_KEY}`;
axios
.get(FULL_API_CURRENT_URL)
.then(response => {
// Assign vars to response data
@imxiaohui
imxiaohui / youtube-dl-cheat.txt
Created April 2, 2021 10:05 — forked from philosopherdog/youtube-dl-cheat.txt
youtube-dl cheat sheet
# Basic Download:
youtube-dl URL
# Download Playlist, put in folder, and index with order:
youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' URL
# Download to /$uploader/$date/$title.$ext:
youtube-dl -o '%(uploader)s/%(date)s/%(title)s.%(ext)s' URL
# Download playlist starting from certain video:
@imxiaohui
imxiaohui / solution1.go
Created January 30, 2021 16:07 — forked from gmolveau/solution1.go
Go Tour concurrency crawler exercice with goroutines https://tour.golang.org/concurrency/10
/*
inspired by https://eduardolezcano.com/a-tour-of-go-web-crawler/
and https://github.com/fgrehm/go-tour/blob/master/73-web-crawler-golang-team-solution.go
solution with a "safe" map with mutex + a sub-function crawl with WaitGroup
this solution keeps the original signature of the Crawl function and does not change the main function
but does not use or store the body of the URL
*/
package main
@imxiaohui
imxiaohui / project-ideas01.md
Created January 22, 2021 02:31 — forked from MWins/project-ideas01.md
Back end Projects - list

Project Ideas

Ok. I'm going to list off some ideas for projects. You will have to determine if any particular idea is good enough to include in a portfolio. These aren't creative ideas. They likely already exist. Some are way too advanced while others are simplistic.

I will recommend to post any project you make to github and make a github project page for it. Explain in as much detail as possible how you made it, how it can be improved etc. Document it.

If you pick an advanced idea, setup a development roadmap and follow it. This will show some project management skills.

Another piece of advice for those who are design challenged. Use different front end frameworks and use different themes for those frameworks to provide appealing designs without looking like yet another bootstrap site.

@imxiaohui
imxiaohui / shared_folder_centos_virtualbox.txt
Created July 23, 2020 03:33 — forked from larsar/shared_folder_centos_virtualbox.txt
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
@imxiaohui
imxiaohui / code.md
Created January 15, 2020 02:48 — forked from gopalindians/code.md
Jetbrains IntelliJ IDEA 2019.2.4 Activation code

Please make fork of this, as this can be removed by Github.com sooner or later.

CATF44LT7C-eyJsaWNlbnNlSWQiOiJDQVRGNDRMVDdDIiwibGljZW5zZWVOYW1lIjoiVmxhZGlzbGF2IEtvdmFsZW5rbyIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJpY3Rpb24iOiJGb3IgZWR1Y2F0aW9uYWwgdXNlIG9ubHkiLCJjaGVja0NvbmN1cnJlbnRVc2UiOmZhbHNlLCJwcm9kdWN0cyI6W3siY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiQUMiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEUE4iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQUyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IkdPIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiRE0iLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJDTCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJTMCIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJDIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiUkQiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJQQyIsInBhaWRVcFRvIjoiMjAyMC0wMS0wOCJ9LHsiY29kZSI6IlJNIiwicGFpZFVwVG8iOiIyMDIwLTAxLTA4In0seyJjb2RlIjoiV1MiLCJwYWlkVXBUbyI6IjIwMjAtMDEtMDgifSx7ImNvZGUiOiJEQiIsI

[
{
"author": "Abraham Lincoln",
"quote": "Things may come to those who wait, but only the things left by those who hustle.",
"image": "http://upload.wikimedia.org/wikipedia/commons/1/1b/Abraham_Lincoln_November_1863.jpg"
},
{
"author": "Adam Smith",
"quote": "The great secret of education is to direct vanity to proper objects.",
@imxiaohui
imxiaohui / error-chain.rs
Created December 5, 2018 13:45 — forked from ivanovaleksey/error-chain.rs
Migrate from error-chain to failure
error_chain! {
foreign_links {
Diesel(::diesel::result::Error);
Json(::serde_json::Error);
Mqtt(::rumqtt::Error);
Utf8(::std::string::FromUtf8Error);
Uuid(::uuid::ParseError);
}
errors {