├── x.md ├── c ├── sds │ ├── sdstest.c │ ├── .gitignore │ ├── sds.h.gch │ └── Makefile ├── implicit_convertion │ ├── compare.py │ ├── compare.php │ └── compare.c ├── encapsulation │ ├── point.h │ ├── main.c │ └── point.c ├── pidtest.c ├── limit.c ├── null_equal.c ├── setlinebuf.c ├── c11 │ └── noreturn.c └── devrandom.c ├── go ├── black_magic │ ├── a.s │ └── linkname.go ├── offheap │ └── main.go ├── concurrent │ └── readme.md ├── syscall │ ├── test.dat │ └── file.dat ├── unicorn │ └── readme.md ├── buffer_chain │ └── buf_test.go ├── file │ ├── list_all_file.go │ ├── merged │ ├── get_file_list.go │ ├── filetest.go │ └── read_all.go ├── flow_based │ ├── foo.txt │ └── foo.bar ├── gopsutil │ ├── .gitignore │ └── go.mod ├── left_recursion_detect │ └── main.go ├── deepl │ └── md.md ├── double_buffer │ └── readme.md ├── redis │ ├── readme.md │ └── redisTest.php ├── builtin │ ├── readme.md │ ├── str.go │ └── slice.go ├── peg │ └── readme.md ├── encrypt │ └── readme.md ├── gomod │ ├── vendor │ │ └── github.com │ │ │ ├── cch123 │ │ │ ├── elasticsql │ │ │ │ ├── .gitignore │ │ │ │ └── glide.yaml │ │ │ └── gomodexp │ │ │ │ └── esutil │ │ │ │ └── main.go │ │ │ └── xwb1989 │ │ │ └── sqlparser │ │ │ ├── .gitignore │ │ │ └── CONTRIBUTORS.md │ ├── main.go │ └── go.mod ├── lock │ ├── redlock.go │ └── local_lock.go ├── dataStructs │ ├── typeEqualTest │ │ ├── a │ │ │ └── sss.go │ │ └── typetest.go │ ├── complextest.go │ ├── arrtest.go │ ├── annoymous_struct.go │ ├── listtest.go │ └── maptest.go ├── elasticsearch │ ├── elastic.go │ └── elasticsql_example.go ├── map │ ├── readme.md │ ├── isMapOrdered.go │ ├── range.go │ └── structmap.go ├── pipe │ └── pipe ├── string │ ├── alloc_or_not_alloc │ │ ├── readme.md │ │ └── a_test.go │ ├── joinAndConcatBench │ │ └── readme.md │ ├── split_and_same_under_array │ │ ├── readme.md │ │ └── ben_test.go │ ├── convert.go │ ├── replaceTest.go │ ├── splintN.go │ ├── searchStr.go │ ├── replaceNums.go │ ├── b.go │ ├── hasPrefix.go │ ├── string_display_same_but_not_euqal.go │ └── splitTest.go ├── error │ ├── juju_err │ │ └── juju_err.go │ ├── internal_err.go │ ├── pkg_err │ │ └── printf.go │ └── err_print.go ├── panic │ ├── readme.md │ ├── panic_or_not.go │ ├── panic_recover_and_return.go │ └── before_1-9-2-bug.go ├── runtime │ ├── monitor │ │ └── memstats.go │ ├── forloopinline.go │ ├── gotoolobjdump.go │ ├── inline.go │ └── runtimeCaller.go ├── asm │ ├── func_call │ │ ├── readme.md │ │ ├── call.go │ │ └── call.s │ ├── control_flow │ │ └── m.go │ ├── leaq_test │ │ └── a.go │ ├── refer_to_global_var_in_go_file │ │ ├── a.go │ │ └── a.s │ ├── where_is_fp_sp │ │ ├── where.go │ │ └── where.s │ ├── hardware_or_virtual │ │ ├── where.go │ │ └── where.s │ ├── is_frame_pointer_on_stack_value_equal_to_directive_FP │ │ ├── global.go │ │ └── global.s │ ├── goid │ │ ├── goid_amd64.s │ │ ├── goid.go │ │ └── go_tls.h │ ├── local_var.go │ ├── global │ │ └── global.go │ ├── registers_test │ │ └── r.go │ ├── basic_math_ops │ │ └── math.go │ ├── relative_pos_of_FP_and_SP │ │ └── global.go │ └── what_is_struct_in_asm │ │ └── t.s ├── memmap │ ├── demo.jpg │ └── memmap.go ├── gc │ ├── pre-collect-problem │ │ └── readme.md │ └── readme.md ├── go1.13 │ ├── deferproc │ ├── deferstack.go │ └── deferproc.go ├── unsafe │ └── readme.md ├── escape_analysis │ ├── a.o │ └── a.go ├── goroutine │ ├── nilfuncgo.go │ ├── goForPrint.go │ ├── goroutinetest.go │ ├── channelmakeandchannelnotmake.go │ ├── goroutine.go │ ├── chantest.go │ └── channel.go ├── ringbuffer │ └── readme.md ├── json │ ├── ffjsontest.go │ ├── ffjs.go │ └── djsontest.go ├── circular_dependency │ ├── main.go │ ├── a │ │ └── a.go │ └── b │ │ └── b.go ├── dependency-experiment │ ├── interface_based │ │ ├── order_service.go │ │ └── user_service.go │ ├── nested_struct_based │ │ ├── order_service.go │ │ ├── price_service.go │ │ ├── user_service.go │ │ └── main.go │ ├── injection_based │ │ └── codis.go │ └── func_based │ │ └── test_funcs.go ├── flowControl │ ├── strtest.go │ ├── typetest.go │ ├── defertest.go │ ├── addaddtest.go │ ├── for.go │ ├── gototest.go │ └── panictest.go ├── mapexpr │ └── readme.md ├── os │ ├── pidtest.go │ ├── net_proc.go │ ├── ostest.go │ ├── sysinfo.go │ └── test │ │ └── www_test.go ├── ast │ ├── .vscode │ │ └── settings.json │ ├── example.go.bakk │ ├── example.go │ ├── example.go.bak2 │ └── example2.go ├── comparable │ └── str.go ├── grpc │ ├── readme.md │ └── hello.proto ├── import_cycle │ ├── break_cycle │ │ ├── action │ │ │ └── act.go │ │ ├── item │ │ │ └── item.go │ │ └── character │ │ │ └── cha.go │ └── original │ │ ├── character │ │ └── cha.go │ │ ├── item │ │ └── item.go │ │ └── action │ │ └── action.go ├── linux_processes │ ├── pidtest.go │ └── ppidtest.go ├── html-to-markdown │ └── go.mod ├── trace │ ├── readme.md │ └── trace.go ├── test_fail_in_1.13 │ ├── lib_test.go │ └── lib.go ├── test_with_tags │ ├── m_test.go │ ├── readme.md │ ├── production.go │ ├── test_fakes.go │ └── m.go ├── gdb │ └── t.go ├── goyacc │ ├── prac │ │ └── parse.y │ └── readme.md ├── version │ └── v.go ├── http │ ├── panic │ │ └── readme.md │ ├── http2 │ │ └── readme.md │ ├── httpclient.go │ └── handlerLeak.go ├── snowflake │ ├── maxInt.go │ └── snow.go ├── channel │ ├── writeToClosedChannel.go │ └── channelLen.go ├── types │ ├── intConvert.go │ └── aliasTypeConvert.go ├── array │ └── array2.go ├── atomic_bench │ ├── atomic.go │ └── atomic_test.go ├── race │ ├── g_test.go │ ├── g.go │ └── g2.go ├── unicode │ ├── utest.go │ └── encod.go ├── pprof │ ├── readme.md │ ├── pprof.go │ └── producer_consumer_test.go ├── interface │ ├── readme.md │ ├── multi_instance.go │ ├── interfaceReflect.go │ └── inter.go ├── uuidtest │ ├── uselib │ │ ├── util.go │ │ └── uuid_test.go │ └── useUUIDGEN │ │ ├── util.go │ │ └── uuid_test.go ├── assert │ ├── bench │ │ └── assert_test.go │ └── assert.go ├── cryptoBench │ ├── md4 │ │ ├── md4_test.go │ │ └── md4.go │ └── sha1 │ │ ├── sha1_test.go │ │ └── sha1.go ├── epoll │ ├── easygo │ │ ├── go.mod │ │ └── go.sum │ └── evio │ │ └── evio.go ├── pool │ └── redigo_with_pool │ │ ├── Godeps │ │ └── Readme │ │ └── vendor │ │ └── golang.org │ │ └── x │ │ └── net │ │ ├── AUTHORS │ │ └── CONTRIBUTORS ├── rand │ └── 1.go ├── badcode │ └── badcode.go ├── math │ ├── nan.go │ ├── accurance.go │ └── rand.go ├── thrift │ ├── GoUnusedProtection__.go │ └── hello.thrift ├── concurrent_map_write_iter │ └── readme.md ├── crawler │ └── z.go ├── raft │ ├── hashicorp │ │ └── main.go │ └── hashicorp.go ├── flag │ └── parse.go ├── full_chan.go ├── gocyclo.go ├── slice │ ├── reverse.go │ ├── merge_slices.go │ ├── append_when_under_array_has_capacity.go │ ├── del_elem.go │ ├── nil_and_empty_slice.go │ └── nil_slice_empty_slice.go ├── gopacket │ └── readme.md ├── reflect │ ├── struct_type.go │ ├── zero_is_what.go │ ├── reflecttest.go │ ├── time_type.go │ └── field_offset.go ├── strconv │ └── formatFloat.go ├── suffix │ └── main.go ├── atomic │ └── uber_atomic.go ├── errcheck │ └── errcheck.go ├── line_feed.go ├── algorithm │ └── leetcode │ │ ├── 1 │ │ └── 1_test.go │ │ ├── 344.go │ │ ├── 387.go │ │ ├── 27.go │ │ └── 561.go ├── internal │ ├── copytest2.go │ └── copytest.go ├── expand │ ├── readme.md │ ├── slice.go │ ├── channel.go │ └── map.go ├── goevaluate │ └── m.go ├── 1.9 │ └── syncMap.go ├── time │ └── timeunmarshal.go ├── future │ └── panic_or_not.go ├── receiver │ ├── pointer_rec.go │ └── normal.go ├── 1.8 │ └── db.go ├── hex │ └── decode.go ├── closure │ ├── closure.go │ └── closure2.go ├── sync │ └── structLock.go ├── net │ ├── iptest.go │ └── sockettest.go ├── pkgerror │ └── demo.go ├── beanstalkDemo │ └── producer.go ├── interface_unmsarshal.go ├── broadcast │ └── src │ │ └── main.go ├── dirty_part │ └── nil_receiver.go ├── dlv.go └── params │ └── demo.go ├── go_web ├── echo.go ├── gin │ └── templates │ │ └── index.tmpl ├── form │ └── ben_test.go ├── readme.md ├── martini.go └── chi_with_doc.go ├── syscall ├── what_is_fork.md ├── what_is_mmap.md ├── what_is_backlog.md ├── what_is_malloc.md └── what_is_sendfile.md ├── scala ├── rdd │ └── rdd.txt ├── readme.md ├── lists │ ├── create_from_range.scala │ ├── reduce_list.scala │ ├── short_hand.scala │ ├── use_paren.scala │ ├── immutable.scala │ ├── nil_compare.scala │ ├── access_by_position.scala │ ├── head_tail.scala │ ├── fold_left.scala │ ├── list.scala │ ├── tail_reuse.scala │ └── list_methods.scala ├── map │ └── basic_def.scala ├── spark │ └── test.scala ├── object.scala ├── object_is_singleton.scala ├── lambda │ ├── lambda.scala │ ├── returning_annoymous_function.scala │ ├── returning_function.scala │ └── closure2.scala └── tuple │ └── tuple.scala ├── js ├── node_modules │ └── fibers │ │ ├── bin │ │ ├── .npmignore │ │ ├── darwin-ia32-v8-3.14 │ │ │ └── fibers.node │ │ ├── darwin-x64-v8-3.14 │ │ │ └── fibers.node │ │ ├── linux-ia32-v8-3.14 │ │ │ └── fibers.node │ │ ├── linux-x64-v8-3.14 │ │ │ └── fibers.node │ │ ├── win32-ia32-v8-3.14 │ │ │ └── fibers.node │ │ └── win32-x64-v8-3.14 │ │ │ └── fibers.node │ │ ├── .npmignore │ │ ├── test │ │ ├── illegal-yield.js │ │ ├── bad-context.js │ │ ├── started.js │ │ ├── finish-multiple.js │ │ ├── process-title.js │ │ ├── already-running.js │ │ ├── current.js │ │ ├── stack-overflow.js │ │ ├── unwind.js │ │ └── pool.js │ │ ├── quick-test.js │ │ └── src │ │ └── libcoro │ │ └── README ├── test3.js ├── thistest.js ├── test.js ├── intervaltest.js ├── test2.js ├── closure2.js ├── timeouttest.js ├── segmentfault.js ├── generator.js └── sleep.js ├── python ├── guolele │ ├── guolele │ │ ├── __init__.py │ │ ├── items.pyc │ │ ├── __init__.pyc │ │ ├── settings.pyc │ │ ├── spiders │ │ │ ├── __init__.pyc │ │ │ ├── guolele_spider.pyc │ │ │ └── __init__.py │ │ └── pipelines.py │ └── scrapy.cfg ├── for_range.py ├── otp.py ├── dict_init.py ├── get_cpu.py ├── timedelta.py ├── osArgs.py └── checkAll.py ├── design_patterns ├── Go │ └── readme.md ├── Rust │ └── readme.md └── readme.md ├── readme.md ├── rust ├── rocket_complete_project │ ├── src │ │ ├── conf │ │ │ ├── db.toml │ │ │ ├── etcd.toml │ │ │ ├── redis.toml │ │ │ └── ratelimit.toml │ │ ├── config │ │ │ └── mod.rs │ │ ├── logic │ │ │ └── mod.rs │ │ ├── model │ │ │ └── mod.rs │ │ ├── controller │ │ │ ├── mod.rs │ │ │ ├── order.rs │ │ │ └── user.rs │ │ └── init.rs │ ├── build.rs │ └── Cargo.toml ├── programming_rust │ └── ch1 │ │ ├── hello │ │ ├── target │ │ │ └── rls │ │ │ │ └── debug │ │ │ │ ├── .cargo-lock │ │ │ │ ├── .fingerprint │ │ │ │ └── hello-361a3be39b79a777 │ │ │ │ │ ├── bin-hello-361a3be39b79a777 │ │ │ │ │ ├── dep-bin-hello-361a3be39b79a777 │ │ │ │ │ └── bin-hello-361a3be39b79a777.json │ │ │ │ ├── libhello.d │ │ │ │ └── deps │ │ │ │ └── hello-361a3be39b79a777.d │ │ ├── src │ │ │ └── main.rs │ │ ├── Cargo.lock │ │ └── Cargo.toml │ │ ├── gcd │ │ ├── Cargo.lock │ │ └── Cargo.toml │ │ ├── cmd_args │ │ ├── Cargo.lock │ │ └── Cargo.toml │ │ └── web-sum │ │ └── Cargo.toml ├── rust_programming_lang │ ├── .gitignore │ └── guess_num │ │ └── Cargo.toml ├── ngx_rs │ ├── src │ │ └── main.rs │ └── Cargo.toml ├── future-impl │ ├── simplefuture │ │ ├── src │ │ │ └── main.rs │ │ └── Cargo.toml │ ├── simple_poll │ │ └── Cargo.toml │ └── executor │ │ ├── src │ │ └── main.rs │ │ └── Cargo.toml ├── rust_book │ ├── ch2 │ │ ├── helloworld.rs │ │ └── cargo │ │ │ └── hello_world │ │ │ ├── src │ │ │ └── main.rs │ │ │ └── Cargo.toml │ └── ch1 │ │ ├── borrow_twice.rs │ │ └── clone.rs ├── box_linklist │ ├── Cargo.lock │ └── Cargo.toml ├── lifetime_test │ ├── Cargo.lock │ └── Cargo.toml ├── assoc3 │ ├── readme.md │ ├── Cargo.lock │ └── Cargo.toml ├── read_from_stdin │ ├── readme.md │ ├── src │ │ └── main.rs │ └── Cargo.toml ├── refcell_linklist │ ├── Cargo.lock │ └── Cargo.toml ├── module_test │ ├── src │ │ ├── array.rs │ │ ├── inner │ │ │ ├── go.rs │ │ │ └── mod.rs │ │ ├── main.rs │ │ └── list.rs │ └── Cargo.toml ├── print_file_and_line │ ├── src │ │ └── main.rs │ ├── Cargo.lock │ └── Cargo.toml ├── thrift_test │ ├── src │ │ └── main.rs │ └── Cargo.toml ├── csv_parser │ ├── numbers.csv │ ├── src │ │ └── csv.pest │ └── Cargo.toml ├── proc_macro_workshop │ ├── src │ │ ├── debug.rs │ │ └── easy.rs │ └── Cargo.toml ├── assoc │ ├── Cargo.lock │ └── Cargo.toml ├── pest_test │ ├── .idea │ │ ├── encodings.xml │ │ ├── vcs.xml │ │ ├── modules.xml │ │ └── misc.xml │ ├── Cargo.toml │ └── src │ │ └── ident.pest ├── assoc2 │ ├── Cargo.lock │ └── Cargo.toml ├── box_arr │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── closure │ ├── Cargo.lock │ └── Cargo.toml ├── flat_map │ ├── Cargo.lock │ └── Cargo.toml ├── hashmap │ ├── Cargo.lock │ └── Cargo.toml ├── rustyline_test │ ├── .idea │ │ ├── encodings.xml │ │ ├── vcs.xml │ │ ├── modules.xml │ │ └── misc.xml │ └── Cargo.toml ├── traits │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── combine │ └── demo │ │ ├── Cargo.toml │ │ └── src │ │ └── main.rs ├── partial_eq │ ├── Cargo.lock │ └── Cargo.toml ├── phantomdata │ ├── Cargo.lock │ └── Cargo.toml ├── maplit │ ├── .vscode │ │ └── settings.json │ └── Cargo.toml ├── nom │ └── basic │ │ ├── Cargo.toml │ │ └── readme.md ├── elastic_test │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── expr_test │ └── Cargo.toml ├── serdejson_test │ └── Cargo.toml ├── 1.40 │ └── non_exhaustive │ │ ├── a │ │ ├── src │ │ │ └── lib.rs │ │ └── Cargo.toml │ │ └── b │ │ ├── src │ │ └── main.rs │ │ └── Cargo.toml ├── reqwest │ └── example │ │ └── Cargo.toml ├── iter │ ├── Cargo.toml │ └── src │ │ └── main.rs ├── 1.42 │ └── hello │ │ └── Cargo.toml ├── 1.43 │ └── hello │ │ └── Cargo.toml ├── prec_climber_test │ └── Cargo.toml ├── astd_load_test │ └── Cargo.toml ├── httparse │ └── Cargo.toml ├── loop_time_and_mul_threads_join │ └── Cargo.toml ├── lazy_static │ └── Cargo.toml ├── rock_test │ └── Cargo.toml ├── actix │ └── actix_test │ │ └── Cargo.toml ├── load_test │ └── Cargo.toml ├── net2_test │ └── Cargo.toml ├── asyncstd │ └── Cargo.toml ├── tokio_load_test │ └── Cargo.toml ├── channel │ └── Cargo.toml ├── mio_test │ └── Cargo.toml └── async_tcp_server │ └── Cargo.toml ├── antlr_practise ├── .gitignore ├── expr │ ├── t.expr │ └── readme.md ├── calculator │ └── t.expr ├── grammar_import │ ├── readme.md │ ├── CommonLexerRules.g4 │ └── LibExpr.g4 ├── hello │ └── Hello.g4 └── readme.md ├── php ├── exec_test.php ├── dump.rdb ├── acc_test.php ├── php_int_max.php ├── func_test.php ├── nowtest.php ├── sort.php ├── ISO8601.php ├── uniqid_test.php ├── arr_test2.php ├── explode_test.php ├── nodirect.php ├── implode_test.php ├── json_test.php ├── time_test2.php ├── ob_clean.php ├── timetest3.php ├── functest.php ├── pregreplace_test.php ├── array_unique.php ├── csvtest.php ├── mb_substr.php ├── equaltest.php ├── mobile.php ├── intstrtest.php ├── redis.php ├── accurance.php ├── array_slice.php ├── magic_test.php ├── datetest.php ├── redis_subtest.php ├── sprintftest.php ├── arr_test.php ├── unset_test.php ├── array_slice_test.php ├── array_combine_test.php ├── decode_test.php ├── coltest.php ├── fuck.php ├── copydata.php ├── array_column_test.php └── multisort.php ├── .gitignore ├── uml ├── actor.png ├── activity.png ├── plantuml.jar ├── sequence.png ├── activity_icons.png ├── advanced_actor.png ├── advanced_activity.png ├── advanced_sequence.png ├── more_advanced_seq.png ├── more_advanced_activity.png ├── actor.txt ├── advanced_actor.txt ├── sequence.txt ├── advanced_sequence.txt ├── activity.txt ├── advanced_activity.txt ├── ufs.plantuml └── activity_icons.txt ├── graphviz └── psm.png ├── images └── 5g war.png ├── shell ├── forloop.sh ├── simple_loop.sh ├── awk │ ├── dat.txt │ ├── test.awk │ └── fix.sh ├── expect └── download.sh ├── c++ ├── memory_order │ └── run.sh ├── project_template │ ├── cpp │ │ ├── Makefile │ │ └── .vscode │ │ │ └── tasks.json │ └── .vscode │ │ └── tasks.json ├── c++14 │ ├── nullptr.cpp │ ├── rawstring.cpp │ ├── map.cpp │ ├── constptr.cpp │ ├── rvalue.cpp │ └── decltype.cpp ├── double.cpp ├── signal │ ├── signal.cc │ └── sigaction2.cc ├── goto.c ├── unordered_map.cpp └── parent.cpp ├── os ├── chapter_4 │ ├── readme.md │ ├── func_call.c │ └── more_than_7_params.c ├── chapter_3 │ └── practise │ │ ├── aplusb.go │ │ └── loop.s └── chapter_2 │ ├── main.c │ └── readme.md ├── rabbitmq └── delivery_confirm │ └── readme.md ├── elasticconfigs └── elasticsearch2.0 │ ├── result_window.json │ └── reindex.json ├── vscode_configs └── readme.md ├── vagrant_files ├── uinit.sh ├── readme.md ├── bootstrap.sh └── init.sh ├── net ├── programming │ ├── tcpip │ │ └── ch7 │ │ │ └── readme.md │ └── readme.md └── same_port │ └── same_port_outgoing_connections.py ├── github_icons └── show.md ├── ch.go └── gomod └── main.go /x.md: -------------------------------------------------------------------------------- 1 | ddf 2 | -------------------------------------------------------------------------------- /c/sds/sdstest.c: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/black_magic/a.s: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/offheap/main.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go_web/echo.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/concurrent/readme.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/syscall/test.dat: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/unicorn/readme.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /syscall/what_is_fork.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /syscall/what_is_mmap.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/buffer_chain/buf_test.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/file/list_all_file.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /syscall/what_is_backlog.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /syscall/what_is_malloc.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /syscall/what_is_sendfile.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /c/sds/.gitignore: -------------------------------------------------------------------------------- 1 | sds-test 2 | -------------------------------------------------------------------------------- /go/flow_based/foo.txt: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /go/gopsutil/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /go/left_recursion_detect/main.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scala/rdd/rdd.txt: -------------------------------------------------------------------------------- 1 | 10 1 x 2 | -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/.npmignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /python/guolele/guolele/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /design_patterns/Go/readme.md: -------------------------------------------------------------------------------- 1 | Go dir 2 | -------------------------------------------------------------------------------- /design_patterns/Rust/readme.md: -------------------------------------------------------------------------------- 1 | Rust dir 2 | -------------------------------------------------------------------------------- /js/test3.js: -------------------------------------------------------------------------------- 1 | var x 2 | console.log(x) 3 | -------------------------------------------------------------------------------- /go/deepl/md.md: -------------------------------------------------------------------------------- 1 | # abc 2 | 3 | sdfadf 4 | 5 | -------------------------------------------------------------------------------- /go/double_buffer/readme.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | -------------------------------------------------------------------------------- /go/flow_based/foo.bar: -------------------------------------------------------------------------------- 1 | resultforreplacefoo 2 | -------------------------------------------------------------------------------- /go/redis/readme.md: -------------------------------------------------------------------------------- 1 | go run -race redis-go.go 2 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/conf/db.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/conf/etcd.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/conf/redis.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /go/builtin/readme.md: -------------------------------------------------------------------------------- 1 | go run -gcflags "-N -l" xxx.go -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/conf/ratelimit.toml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/config/mod.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/logic/mod.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/model/mod.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /scala/readme.md: -------------------------------------------------------------------------------- 1 | 运行脚本: 2 | 3 | scala xxxx.scala 4 | -------------------------------------------------------------------------------- /antlr_practise/.gitignore: -------------------------------------------------------------------------------- 1 | */.antlr/* 2 | *.go 3 | *.tokens 4 | -------------------------------------------------------------------------------- /go/peg/readme.md: -------------------------------------------------------------------------------- 1 | peglint -ast -s '1 + 2 + 32' ./grammar.peg 2 | -------------------------------------------------------------------------------- /js/node_modules/fibers/.npmignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /php/exec_test.php: -------------------------------------------------------------------------------- 1 | 1, 4 | 'dd' => 2 5 | ]; 6 | print_r($arr); 7 | -------------------------------------------------------------------------------- /rust/lifetime_test/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "lifetime_test" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/gcd/Cargo.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "gcd" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/hello/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | } 4 | -------------------------------------------------------------------------------- /go/asm/leaq_test/a.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func run() int 4 | func main() { 5 | println(run()) 6 | } 7 | -------------------------------------------------------------------------------- /go/json/ffjsontest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Person struct { 4 | name string 5 | age int 6 | } 7 | -------------------------------------------------------------------------------- /go_web/gin/templates/index.tmpl: -------------------------------------------------------------------------------- 1 | 2 |

3 | {{ .title }} 4 |

5 | 6 | -------------------------------------------------------------------------------- /php/explode_test.php: -------------------------------------------------------------------------------- 1 | skip; 5 | -------------------------------------------------------------------------------- /c/pidtest.c: -------------------------------------------------------------------------------- 1 | #include "unistd.h" 2 | 3 | int main() { 4 | printf("%d\n", getpid()); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /go/ast/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | } -------------------------------------------------------------------------------- /go/comparable/str.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a string 5 | a = "abc" 6 | a = a + "def" 7 | } 8 | -------------------------------------------------------------------------------- /go/dependency-experiment/nested_struct_based/order_service.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type orderService struct{} 4 | -------------------------------------------------------------------------------- /go/string/split_and_same_under_array/readme.md: -------------------------------------------------------------------------------- 1 | go test -bench=. -benchmem 2 | 3 | strings.Replace is a disaster! 4 | -------------------------------------------------------------------------------- /php/ob_clean.php: -------------------------------------------------------------------------------- 1 | res 2 | ~/t/g/trace ❯❯❯ go tool trace -http=0.0.0.0:8888 ./res 3 | 4 | -------------------------------------------------------------------------------- /php/functest.php: -------------------------------------------------------------------------------- 1 | murphy: 爱和引力可以穿越 6 | @enduml 7 | -------------------------------------------------------------------------------- /vscode_configs/readme.md: -------------------------------------------------------------------------------- 1 | you need to set this to true first 2 | 3 | > gocode close 4 | 5 | > gocode set unimported-packages true 6 | -------------------------------------------------------------------------------- /go/goyacc/prac/parse.y: -------------------------------------------------------------------------------- 1 | %{ 2 | package main 3 | import ( 4 | "fmt" 5 | "text/scanner" 6 | ) 7 | 8 | type Expression struct {} 9 | %} -------------------------------------------------------------------------------- /go/import_cycle/break_cycle/item/item.go: -------------------------------------------------------------------------------- 1 | package item 2 | 3 | type Item struct { 4 | Name string 5 | Actions []action.Action 6 | } 7 | -------------------------------------------------------------------------------- /go/version/v.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "runtime" 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(runtime.Version()) 7 | } 8 | 9 | -------------------------------------------------------------------------------- /os/chapter_3/practise/aplusb.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a = 1 5 | var b = 2 6 | var c = a + b 7 | println(c) 8 | } 9 | -------------------------------------------------------------------------------- /php/array_unique.php: -------------------------------------------------------------------------------- 1 | 1, 'y' => 2], 4 | ['x' => 1, 'y' => 2], 5 | ['x' => 1, 'y' => 2], 6 | ]; 7 | -------------------------------------------------------------------------------- /python/guolele/guolele/spiders/guolele_spider.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/python/guolele/guolele/spiders/guolele_spider.pyc -------------------------------------------------------------------------------- /go/ast/example.go.bakk: -------------------------------------------------------------------------------- 1 | package lp 2 | 3 | var a = 1 4 | 5 | const a = 1 6 | 7 | type p struct { 8 | } 9 | 10 | func main() { 11 | } 12 | -------------------------------------------------------------------------------- /go/builtin/str.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func p(s string) { 4 | panic(1) 5 | } 6 | 7 | func main() { 8 | var s = "hello" 9 | p(s) 10 | } 11 | -------------------------------------------------------------------------------- /go/gomod/vendor/github.com/cch123/elasticsql/glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/cch123/elasticsql 2 | import: 3 | - package: github.com/xwb1989/sqlparser 4 | -------------------------------------------------------------------------------- /go/test_fail_in_1.13/lib.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import "flag" 4 | 5 | func init() { 6 | flag.Parse() 7 | } 8 | 9 | func Yes() { 10 | } 11 | -------------------------------------------------------------------------------- /go/test_with_tags/readme.md: -------------------------------------------------------------------------------- 1 | # how to test with tags and mock your function when test 2 | 3 | ```shell 4 | go test 5 | 6 | go test -tags=test 7 | ``` -------------------------------------------------------------------------------- /rust/rust_book/ch1/borrow_twice.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x = vec!["hello", "world"]; 3 | let y = &x[0]; 4 | x.push("anyway"); 5 | } 6 | -------------------------------------------------------------------------------- /rust/rust_book/ch1/clone.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x = vec!["hello", "world"]; 3 | let y = x[0].clone(); 4 | x.push("anyway"); 5 | } 6 | -------------------------------------------------------------------------------- /shell/awk/dat.txt: -------------------------------------------------------------------------------- 1 | 32323423423123 2 | 32323423423103 3 | 32323423423112 4 | 32323423423143 5 | 32323423423153 6 | 32323423423113 7 | 32323423423112 8 | -------------------------------------------------------------------------------- /c/implicit_convertion/compare.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | printf("%d\n", 4 < '2'); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /go/file/merged: -------------------------------------------------------------------------------- 1 | {"from" : 0,"size" : 15,"query" : {"bool": {"must" : [{"term" : {"phone" : "1866666666"}}]}},"sort" : [{"id" : "desc"}],"highlight" : {}} 2 | -------------------------------------------------------------------------------- /go/snowflake/maxInt.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(math.MaxInt64) 10 | } 11 | -------------------------------------------------------------------------------- /php/mb_substr.php: -------------------------------------------------------------------------------- 1 | 100, "A" -> 1) 2 | 3 | val myMap2 = Map(("a" ,1), ("b",2)) 4 | 5 | println(myMap) 6 | println(myMap2) 7 | -------------------------------------------------------------------------------- /go/asm/refer_to_global_var_in_go_file/a.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = 999 4 | 5 | func get() int 6 | 7 | func main() { 8 | println(get()) 9 | } 10 | -------------------------------------------------------------------------------- /go/builtin/slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func p(s []int) { 4 | panic(1) 5 | } 6 | 7 | func main() { 8 | var s = []int{1, 2, 3} 9 | p(s) 10 | } 11 | -------------------------------------------------------------------------------- /go/channel/writeToClosedChannel.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a = make(chan int, 4) 5 | close(a) 6 | // 直接panic,思考一下why 7 | a <- 4 8 | } 9 | -------------------------------------------------------------------------------- /go/types/intConvert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a int64 = 1 7 | var b = int32(a) 8 | fmt.Println(b) 9 | } 10 | -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/darwin-ia32-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/darwin-ia32-v8-3.14/fibers.node -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/darwin-x64-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/darwin-x64-v8-3.14/fibers.node -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/linux-ia32-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/linux-ia32-v8-3.14/fibers.node -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/linux-x64-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/linux-x64-v8-3.14/fibers.node -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/win32-ia32-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/win32-ia32-v8-3.14/fibers.node -------------------------------------------------------------------------------- /js/node_modules/fibers/bin/win32-x64-v8-3.14/fibers.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cch123/test/HEAD/js/node_modules/fibers/bin/win32-x64-v8-3.14/fibers.node -------------------------------------------------------------------------------- /php/equaltest.php: -------------------------------------------------------------------------------- 1 | 15810540851, 4 | 'content' => '您的订单已经发货,请注意查收', 5 | ); 6 | echo json_encode($x); 7 | 8 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/gcd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gcd" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /go/array/array2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = [10]int{1, 3, 4} 7 | var b = a[2:4:5] 8 | fmt.Println(b) 9 | } 10 | -------------------------------------------------------------------------------- /go/asm/refer_to_global_var_in_go_file/a.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | TEXT ·get(SB), NOSPLIT, $0-8 4 | MOVQ ·a(SB), AX 5 | MOVQ AX, ret+0(FP) 6 | RET 7 | -------------------------------------------------------------------------------- /go/atomic_bench/atomic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync/atomic" 4 | 5 | var a int64 6 | 7 | func atomicStore(i int) { 8 | atomic.StoreInt64(&a, int64(i)) 9 | } -------------------------------------------------------------------------------- /go/race/g_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchCalc(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | calc() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go/unicode/utest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "unicode" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(unicode.IsDigit('2')) 10 | } 11 | -------------------------------------------------------------------------------- /rust/csv_parser/src/csv.pest: -------------------------------------------------------------------------------- 1 | field = { (ASCII_DIGIT | "." | "-")+ } 2 | record = { field ~ ("," ~ field)* } 3 | file = { SOI ~ (record ~ ("\r\n" | "\n"))* ~ EOI } 4 | -------------------------------------------------------------------------------- /rust/module_test/src/list.rs: -------------------------------------------------------------------------------- 1 | use crate::inner::go; 2 | pub(super) fn print() { 3 | println!("{}", "this is in module crate::list"); 4 | go::print_gogo(); 5 | } -------------------------------------------------------------------------------- /rust/proc_macro_workshop/src/debug.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! each_tt { 3 | () => {}; 4 | ($_tt:tt $($rest:tt)*) => {each_tt!($($rest)*);}; 5 | } 6 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /vagrant_files/uinit.sh: -------------------------------------------------------------------------------- 1 | sudo pfctl -F all -f /etc/pf.conf >/dev/null 2>&1; echo "Removing Port Forwarding (80 => 8080)\nRemove Port Forwarding (443 => 4443)" 2 | 3 | -------------------------------------------------------------------------------- /go/goyacc/readme.md: -------------------------------------------------------------------------------- 1 | https://zhuanlan.zhihu.com/p/34770765 2 | 3 | https://github.com/vitessio/vitess/blob/dbdb3a1d6c2075edac0e0f11b93a63668f6e4559/go/vt/sqlparser/sql.y 4 | -------------------------------------------------------------------------------- /go/pprof/readme.md: -------------------------------------------------------------------------------- 1 | 只要简单的import _ "net/http/pprof" 2 | 3 | 然后就可以localhost:port/debug/pprof来看了 4 | 5 | 6 | // cpu gvz 7 | go tool pprof ../producer_consumer ./cpu.prof 8 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/illegal-yield.js: -------------------------------------------------------------------------------- 1 | // gh-3 2 | var Fiber = require('fibers'); 3 | try { 4 | Fiber.yield(); 5 | } catch(err) { 6 | console.log('pass'); 7 | } 8 | -------------------------------------------------------------------------------- /php/intstrtest.php: -------------------------------------------------------------------------------- 1 | "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /go_web/form/ben_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkTest(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | test() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rust/proc_macro_workshop/src/easy.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] // macro_export 会把这个 macro export 到 crate:: 根部 2 | macro_rules! four { 3 | () => { 4 | 1 + 3 5 | }; 6 | } 7 | -------------------------------------------------------------------------------- /rust/rust_book/ch2/cargo/hello_world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello_world" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /antlr_practise/readme.md: -------------------------------------------------------------------------------- 1 | build go target 2 | ----------- 3 | https://github.com/antlr/antlr4/blob/master/doc/go-target.md 4 | 5 | ``` 6 | antlr4 -Dlanguage=Go hello.g4 7 | ``` 8 | -------------------------------------------------------------------------------- /go/interface/readme.md: -------------------------------------------------------------------------------- 1 | go build -gcflags "-N -l" xxx.go 2 | 3 | gdb xxx 4 | 5 | l=>列出代码 6 | 7 | b `line_number` 列出行号 8 | 9 | r 运行程序,在断点处会自动停止 10 | 11 | i locals 12 | -------------------------------------------------------------------------------- /go/uuidtest/uselib/util.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import uuid "github.com/satori/go.uuid" 4 | 5 | var u1 uuid.UUID 6 | 7 | func test() { 8 | u1 = uuid.NewV4() 9 | } 10 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/bad-context.js: -------------------------------------------------------------------------------- 1 | var Fiber = require('fibers'); 2 | 3 | try { 4 | Fiber.prototype.run.call(null); 5 | } catch (err) { 6 | console.log('pass'); 7 | } 8 | -------------------------------------------------------------------------------- /php/redis.php: -------------------------------------------------------------------------------- 1 | connect("127.0.0.1", 6379); 4 | $setRes = $redis->set("a",1); 5 | var_dump($connRes); 6 | var_dump($setRes); 7 | -------------------------------------------------------------------------------- /rust/assoc/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "assoc" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /rust/box_linklist/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "box_linklist" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | -------------------------------------------------------------------------------- /rust/lifetime_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lifetime_test" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | -------------------------------------------------------------------------------- /rust/pest_test/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /go/asm/func_call/call.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import _ "strconv" 4 | 5 | func callOther() string 6 | 7 | func main() { 8 | x := callOther() 9 | println(x, len(x)) 10 | } 11 | -------------------------------------------------------------------------------- /go/assert/bench/assert_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkAssert(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | asx() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go/cryptoBench/md4/md4_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkUUID(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | test() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go/cryptoBench/sha1/sha1_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkSHA1(t *testing.B) { 6 | for i := 0; i < t.N; i++ { 7 | test() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go/epoll/easygo/go.mod: -------------------------------------------------------------------------------- 1 | module easygo 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f 7 | golang.org/x/sys v0.1.0 // indirect 8 | ) 9 | -------------------------------------------------------------------------------- /go/uuidtest/useUUIDGEN/util.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os/exec" 4 | 5 | var uuid []byte 6 | 7 | func test() { 8 | uuid, _ = exec.Command("uuidgen").Output() 9 | } 10 | -------------------------------------------------------------------------------- /go/uuidtest/uselib/uuid_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkUUID(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | test() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /php/accurance.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /rust/traits/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "generics" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /scala/lists/nil_compare.scala: -------------------------------------------------------------------------------- 1 | val a: List[String] = Nil 2 | val b: List[Int] = Nil 3 | 4 | a == Nil 5 | a eq Nil 6 | 7 | b == Nil 8 | b eq Nil 9 | 10 | // 上面的比较全都是 true 11 | -------------------------------------------------------------------------------- /go/flowControl/addaddtest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x = 1 5 | x++ 6 | println(x) 7 | //var y = x++ syntax error! 8 | //println(y++) syntax error! 9 | } 10 | -------------------------------------------------------------------------------- /go/uuidtest/useUUIDGEN/uuid_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkUUID(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | test() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /rust/combine/demo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "demo" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | combine = "3.3.0" -------------------------------------------------------------------------------- /rust/partial_eq/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "partial_eq" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /rust/refcell_linklist/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "refcell_linklist" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | -------------------------------------------------------------------------------- /scala/lists/access_by_position.scala: -------------------------------------------------------------------------------- 1 | val a = List(1,2,3) 2 | 3 | a(0) 4 | a(2) 5 | a(5) 6 | 7 | // ?? 8 | intercept[IndexOutOfBoundsException] { 9 | println(a(5)) 10 | } 11 | -------------------------------------------------------------------------------- /elasticconfigs/elasticsearch2.0/reindex.json: -------------------------------------------------------------------------------- 1 | { 2 | "source": { 3 | "index": "ark_callcenter" 4 | }, 5 | "dest": { 6 | "index": "ark_callcenter_g_service_worksheet" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /go/import_cycle/original/action/action.go: -------------------------------------------------------------------------------- 1 | // Package action provides ... 2 | package action 3 | 4 | type Action struct { 5 | Names []string 6 | Action func(character.Character) int 7 | } 8 | -------------------------------------------------------------------------------- /go/pool/redigo_with_pool/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /go/string/convert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(string("11")) 7 | fmt.Println(string('a')) 8 | fmt.Printf("%#v\n", string(49)) 9 | } 10 | -------------------------------------------------------------------------------- /rust/phantomdata/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "phantomdata" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /c++/c++14/nullptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int * p = nullptr; 6 | cout << "this is nullptr in c++14 " << p <男主角" as copper #99ff99 3 | actor "星际穿越的\n男主女儿" as murphy #red 4 | 5 | copper -[#orange]> murphy: 爱和引力可以穿越 6 | @enduml 7 | -------------------------------------------------------------------------------- /c++/c++14/rawstring.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | string raw = R"(\\a\\wqbdadfdsfsdf\dfadf\df\s\df\)"; 6 | cout << raw << endl; 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /go/circular_dependency/a/a.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import "../b" 4 | 5 | func Test() { 6 | b.FormatB() 7 | println("test a") 8 | } 9 | 10 | func FormatA() { 11 | println("format a") 12 | } 13 | -------------------------------------------------------------------------------- /go/circular_dependency/b/b.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "../a" 4 | 5 | func Test() { 6 | a.FormatA() 7 | println("test b") 8 | } 9 | 10 | func FormatB() { 11 | println("format b") 12 | } 13 | -------------------------------------------------------------------------------- /rust/nom/basic/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | nom = "4.2.0" 9 | 10 | -------------------------------------------------------------------------------- /scala/lists/head_tail.scala: -------------------------------------------------------------------------------- 1 | // head headOption tail 2 | val a = List(1,2,3) 3 | // 注意这两个的区别,scala里的Option是支持为空的head的,但不带option的可能会抛异常 4 | a.head 5 | a.headOption 6 | // tail没有tailOption之类的东西 7 | a.tail 8 | -------------------------------------------------------------------------------- /scala/spark/test.scala: -------------------------------------------------------------------------------- 1 | import org.apache.spark.sql.hive.HiveContext 2 | 3 | val hiveCtx = new HiveContext(sc) 4 | 5 | val studentRDD = hiveCtx.sql("select * from test.user").rdd 6 | 7 | studentRDD 8 | 9 | -------------------------------------------------------------------------------- /antlr_practise/grammar_import/CommonLexerRules.g4: -------------------------------------------------------------------------------- 1 | lexer grammar CommonLexerRules; // 注意开头的 lexer grammar 2 | 3 | ID : [a-zA-Z]+; 4 | INT : [0-9]+; 5 | NEWLINE:'\r'?'\n'; 6 | WS : [ \t]+ -> skip; // 丢弃空白字符 7 | -------------------------------------------------------------------------------- /c/null_equal.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "stdlib.h" 3 | 4 | int main() { 5 | char * x = NULL; 6 | void * a = x; 7 | int c = a == x? 1:0; 8 | printf("%d",c); 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /go/asm/hardware_or_virtual/where.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func where() (int, int, int, int) 6 | 7 | func main() { 8 | a, b, c, d := where() 9 | fmt.Println(a, b, c, d) 10 | } 11 | -------------------------------------------------------------------------------- /go/rand/1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | ) 7 | 8 | func main() { 9 | for i := 0; i < 1000; i++ { 10 | x := rand.Intn(10) 11 | fmt.Println(x) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /go/string/replaceTest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | var a = `('a','b','c')` 10 | fmt.Println(strings.Replace(a, `'`, `"`, -1)) 11 | } 12 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/started.js: -------------------------------------------------------------------------------- 1 | // gh-12 2 | var Fiber = require('fibers'); 3 | Fiber(function() { 4 | if (!Fiber.current.started) { 5 | throw new Error; 6 | } 7 | }).run(); 8 | console.log('pass'); 9 | -------------------------------------------------------------------------------- /js/thistest.js: -------------------------------------------------------------------------------- 1 | var name = 'top name'; 2 | function test() { 3 | var name = 'inner'; 4 | console.log(this.name); 5 | } 6 | test() 7 | this.sayHi = test 8 | this.name = name 9 | console.log(this) 10 | -------------------------------------------------------------------------------- /php/array_slice.php: -------------------------------------------------------------------------------- 1 | test(); 10 | -------------------------------------------------------------------------------- /rust/elastic_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "elastic_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | elastic_query = "0.1.0" 9 | -------------------------------------------------------------------------------- /rust/print_file_and_line/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "print_file_and_line" 5 | version = "0.1.0" 6 | 7 | -------------------------------------------------------------------------------- /rust/rustyline_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustyline_test" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | rustyline = "3.0.0" 9 | -------------------------------------------------------------------------------- /go/badcode/badcode.go: -------------------------------------------------------------------------------- 1 | if a { 2 | } else { 3 | if b { 4 | if c { 5 | } else { 6 | if d { 7 | } else { 8 | if e { 9 | } else { 10 | } 11 | } 12 | } 13 | } else { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /go/error/internal_err.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | err := errors.New("oh no") 10 | fmt.Println(err) 11 | fmt.Printf("%+v", err) 12 | } 13 | -------------------------------------------------------------------------------- /go/math/nan.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | func main() { 9 | n1 := math.NaN() 10 | n2 := math.NaN() 11 | fmt.Println(n1, n2) 12 | fmt.Println(n1 == n2) 13 | } 14 | -------------------------------------------------------------------------------- /go/string/splintN.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | var a = "abc@def@gh" 10 | res := strings.SplitN(a, "@", 2) 11 | fmt.Println(res) 12 | } 13 | -------------------------------------------------------------------------------- /go/thrift/GoUnusedProtection__.go: -------------------------------------------------------------------------------- 1 | // Autogenerated by Thrift Compiler (0.13.0) 2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 3 | 4 | package main 5 | 6 | var GoUnusedProtection__ int 7 | -------------------------------------------------------------------------------- /js/node_modules/fibers/quick-test.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | var Fiber = require('./fibers'); 3 | var fiber = Fiber(function() { 4 | process.stdout.write(Fiber.yield()); 5 | }); 6 | fiber.run(); 7 | fiber.run('pass'); 8 | -------------------------------------------------------------------------------- /php/datetest.php: -------------------------------------------------------------------------------- 1 | strtotime('20151212')) { 6 | echo 'yes'; 7 | }else { 8 | echo 'no'; 9 | } 10 | -------------------------------------------------------------------------------- /php/redis_subtest.php: -------------------------------------------------------------------------------- 1 | connect('127.0.0.1', 6379); 4 | $redis->subscribe(array("channel-1"), function($redis, $chan, $msg){ 5 | echo $msg; 6 | }); 7 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/hello/target/rls/debug/libhello.d: -------------------------------------------------------------------------------- 1 | /Users/caochunhui/test/rust/programming_rust/ch1/hello/target/rls/debug/libhello.rmeta: /Users/caochunhui/test/rust/programming_rust/ch1/hello/src/main.rs 2 | -------------------------------------------------------------------------------- /scala/object.scala: -------------------------------------------------------------------------------- 1 | // object 和 java 的静态方法类似,但实际上却是一个全局一致的单例 2 | 3 | object Greeting { 4 | def english = "Hi" 5 | def chn = "艹" 6 | } 7 | 8 | println(Greeting.english) 9 | println(Greeting.chn) 10 | -------------------------------------------------------------------------------- /go/concurrent_map_write_iter/readme.md: -------------------------------------------------------------------------------- 1 | https://github.com/golang/go/issues/26703 2 | 3 | 不打开 -race 的选项的话,有可能 race 的栈显示不全,如两个 goroutine 发生 race,而实际上只显示其中的一个。 4 | 5 | 但线上显然是没法打开的。 6 | 7 | 可以在压力测试中开 -race 进行单独的并发测试 8 | 9 | -------------------------------------------------------------------------------- /go/crawler/z.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | ) 7 | 8 | func main() { 9 | 10 | u, err := url.Parse("http://www.abc.com/afdsaf") 11 | fmt.Println(u.Hostname(), err) 12 | } 13 | -------------------------------------------------------------------------------- /go/redis/redisTest.php: -------------------------------------------------------------------------------- 1 | connect("localhost", "6379",0); 4 | echo time(); 5 | echo "\n"; 6 | for ($i =0;$i<10000;$i++) { 7 | $r = $a->get("foo".$i); 8 | } 9 | echo time(); 10 | -------------------------------------------------------------------------------- /go/runtime/forloopinline.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | var a []string 7 | for { 8 | var d = len(a) 9 | 10 | time.Sleep(time.Second) 11 | println(d) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /go/string/searchStr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sort" 4 | 5 | func main() { 6 | arr := []string{"iOS/0.9.4", "dafafa"} 7 | sort.Strings(arr) 8 | println(sort.SearchStrings(arr, "ANDROID/0.9w")) 9 | } 10 | -------------------------------------------------------------------------------- /python/guolele/guolele/spiders/__init__.py: -------------------------------------------------------------------------------- 1 | # This package will contain the spiders of your Scrapy project 2 | # 3 | # Please refer to the documentation for information on how to create and manage 4 | # your spiders. 5 | -------------------------------------------------------------------------------- /uml/sequence.txt: -------------------------------------------------------------------------------- 1 | @startuml 2 | participant Ark 3 | participant Noah 4 | participant "SMS网关" as sms 5 | 6 | Ark -> Noah : send sms 7 | Noah -> sms : send request 8 | Noah --> Ark : return success 9 | @enduml 10 | -------------------------------------------------------------------------------- /go/ast/example.go: -------------------------------------------------------------------------------- 1 | package lp 2 | 3 | type person struct { 4 | age, aaa int `json:"age" form:"age"` 5 | name int `json:"name" form:"name"` 6 | info struct { 7 | detail int `json:"detail"` 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /go/ast/example.go.bak2: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // for api @post @/user/create 4 | type createAccountRequest struct { 5 | Age int `form:"age" validation:"gte=18"` 6 | Name string `form:"name" validation:"length>0"` 7 | } 8 | -------------------------------------------------------------------------------- /go/http/http2/readme.md: -------------------------------------------------------------------------------- 1 | ``` 2 | ~ ❯❯❯ curl -i https://localhost:9090 -k 3 | HTTP/2 200 4 | content-type: application/json 5 | content-length: 5 6 | date: Thu, 23 Apr 2020 07:40:12 GMT 7 | 8 | hello 9 | 10 | ``` 11 | -------------------------------------------------------------------------------- /go/raft/hashicorp/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func main() { 6 | config(3) 7 | 8 | http.HandleFunc("/", Handler) 9 | err := http.ListenAndServe(":3333", nil) 10 | panic(err) 11 | } 12 | -------------------------------------------------------------------------------- /os/chapter_2/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void test() 5 | { 6 | printf("hello, world!\n"); 7 | } 8 | 9 | int main() 10 | { 11 | test(); 12 | return EXIT_SUCCESS; 13 | } 14 | -------------------------------------------------------------------------------- /php/sprintftest.php: -------------------------------------------------------------------------------- 1 | "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | pest = "2.0" 9 | pest_derive = "2.0" 10 | -------------------------------------------------------------------------------- /rust/pest_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pest_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | pest = "2.0" 9 | pest_derive = "2.0" 10 | -------------------------------------------------------------------------------- /rust/rust_programming_lang/guess_num/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | 9 | rand = "0.4.0" 10 | -------------------------------------------------------------------------------- /go/dependency-experiment/nested_struct_based/price_service.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func onlineGetPrice(orderID int) float64 { 4 | return 0 5 | } 6 | 7 | func testGetPrice(orderID int) float64 { 8 | return 0.11 9 | } 10 | -------------------------------------------------------------------------------- /go/escape_analysis/a.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func t(a *int) { 8 | } 9 | 10 | func main() { 11 | var a [1]int 12 | c := a[:] 13 | fmt.Println(c) 14 | var b int 15 | t(&b) 16 | } 17 | -------------------------------------------------------------------------------- /go/flag/parse.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | ) 7 | 8 | var a = flag.String("c", "", "flag a ") 9 | 10 | func main() { 11 | // 不parse不出结果 12 | flag.Parse() 13 | fmt.Println(*a) 14 | } 15 | -------------------------------------------------------------------------------- /go/json/ffjs.go: -------------------------------------------------------------------------------- 1 | package cch 2 | 3 | //ffjson这个是用已有的struct自动生成Marshal和Unmarshal的代码的库 4 | //必须得把代码放到GOPATH下才能正常运行。。 5 | //执行ffjson xxxxx.go,然后可以生成编解码代码 6 | 7 | type Person struct { 8 | name string 9 | age int 10 | } 11 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/finish-multiple.js: -------------------------------------------------------------------------------- 1 | // gh-16 2 | var Fiber = require('fibers'); 3 | Fiber(function() { 4 | Fiber(function() { 5 | Fiber(function() {}).run(); 6 | }).run(); 7 | }).run(); 8 | console.log('pass'); 9 | -------------------------------------------------------------------------------- /rust/serdejson_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "serdejson_test" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | serde_json = "1.0.37" 9 | 10 | 11 | -------------------------------------------------------------------------------- /scala/object_is_singleton.scala: -------------------------------------------------------------------------------- 1 | // 单例证明 2 | object Greeting { 3 | def english = "Hi" 4 | def chn = "艹" 5 | } 6 | 7 | val x = Greeting 8 | val y = x 9 | val z = Greeting 10 | println(x eq y) 11 | println(x eq z) 12 | -------------------------------------------------------------------------------- /vagrant_files/readme.md: -------------------------------------------------------------------------------- 1 | Vagrantfile是vagrant的配置文件,里面有关于vagrant-triggers的配置,如果能够成功安装vagrant-triggers这个插件的话,则不需要在mac上做额外的端口转发,如果不能安装,那么需要在启动虚拟机的时候运行init.sh 2 | 3 | init.sh是在mac上用来转发80到8080,443到4443端口的脚本 4 | 5 | uinit.sh是取消上述操作的脚本 6 | -------------------------------------------------------------------------------- /c/setlinebuf.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | 3 | int main() { 4 | setlinebuf(stdout); 5 | printf("abc"); 6 | printf("abc"); 7 | printf("abc"); 8 | printf("abc"); 9 | sleep(10); 10 | return 1; 11 | } 12 | -------------------------------------------------------------------------------- /go/error/pkg_err/printf.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/pkg/errors" 7 | ) 8 | 9 | func main() { 10 | err := errors.New("whoops") 11 | fmt.Println(err) 12 | fmt.Printf("%+v", err) 13 | } 14 | -------------------------------------------------------------------------------- /go/full_chan.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a = make(chan int, 1) 5 | for i := 0; i < 10; i++ { 6 | select { 7 | case a <- i: 8 | default: 9 | println("in default", i) 10 | } 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /go/gocyclo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i = 1 7 | switch i { 8 | case 0: 9 | case 1: 10 | case 2: 11 | default: 12 | } 13 | if i > 0 { 14 | } 15 | 16 | fmt.Println(i) 17 | } 18 | -------------------------------------------------------------------------------- /go/import_cycle/break_cycle/character/cha.go: -------------------------------------------------------------------------------- 1 | package character 2 | 3 | type Character struct { 4 | Inventory []item.Item 5 | } 6 | 7 | // Do implement the interface ActionTarget 8 | func (c Character) Do() int { 9 | } 10 | -------------------------------------------------------------------------------- /go/runtime/gotoolobjdump.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //go tool objdump可以看生成的汇编代码, 4 | //然后在汇编内容里搜索gotoolobjdump.go 5 | //可以找到对应的行数和汇编代码的关系 6 | 7 | func main() { 8 | a := []int{1, 2, 3} 9 | b := len(a) 10 | println(b) 11 | } 12 | -------------------------------------------------------------------------------- /go/slice/reverse.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | var a = []int{43, 32, 12, 32, 44} 10 | 11 | sort.Sort(sort.Reverse(sort.IntSlice(a))) 12 | fmt.Println(a) 13 | } 14 | -------------------------------------------------------------------------------- /go/thrift/hello.thrift: -------------------------------------------------------------------------------- 1 | namespace go echo 2 | 3 | struct EchoReq { 4 | 1: string msg; 5 | } 6 | 7 | struct EchoRes { 8 | 1: string msg; 9 | } 10 | 11 | service Echo { 12 | EchoRes echo(1: EchoReq req); 13 | } 14 | -------------------------------------------------------------------------------- /python/get_cpu.py: -------------------------------------------------------------------------------- 1 | import psutil 2 | import time 3 | 4 | p = psutil.Process(1) 5 | 6 | while 1: 7 | v = str(p.cpu_percent()) 8 | if "0.0" != v: 9 | print(111111, v, time.time()) 10 | time.sleep(1) 11 | 12 | -------------------------------------------------------------------------------- /rust/1.40/non_exhaustive/a/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[non_exhaustive] 2 | #[derive(Debug)] 3 | pub struct Person { 4 | age : i32, 5 | height : i32, 6 | } 7 | 8 | pub fn New() -> Person { 9 | Person {age :1, height : 2} 10 | } 11 | 12 | -------------------------------------------------------------------------------- /rust/csv_parser/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "csv_parser" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | pest = "2.0" 9 | pest_derive = "2.0" 10 | 11 | -------------------------------------------------------------------------------- /rust/elastic_test/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate elastic_query; 2 | 3 | fn main() { 4 | let result = elastic_query::convert("a = 1 and b in (1,2,3)".to_string(), 0, 100, vec![], vec![]).unwrap(); 5 | println!("{}", result); 6 | } 7 | -------------------------------------------------------------------------------- /rust/pest_test/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /go/gopacket/readme.md: -------------------------------------------------------------------------------- 1 | https://www.devdungeon.com/content/packet-capture-injection-and-analysis-gopacket 2 | 3 | loop 拿不到 link layer,需要再改改 4 | 5 | https://stackoverflow.com/questions/59985676/sending-udp-packets-to-127-0-0-1-with-gopacket 6 | -------------------------------------------------------------------------------- /go/os/net_proc.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "syscall" 6 | ) 7 | 8 | func main() { 9 | res, err := syscall.Sysctl("security.mac.device_enforce") 10 | fmt.Printf("%#v\n", res) 11 | fmt.Println(err) 12 | } 13 | -------------------------------------------------------------------------------- /go/pool/redigo_with_pool/vendor/golang.org/x/net/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /go/pool/redigo_with_pool/vendor/golang.org/x/net/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /go/reflect/struct_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | type Person struct { 9 | age int 10 | } 11 | 12 | func main() { 13 | var a Person 14 | fmt.Println(reflect.TypeOf(a)) 15 | } 16 | -------------------------------------------------------------------------------- /go/runtime/inline.go: -------------------------------------------------------------------------------- 1 | // go build -gcflags "-m" 2 | // 可以看到编译器会做哪些内联优化 3 | package main 4 | 5 | import "fmt" 6 | 7 | func test() { 8 | } 9 | 10 | func main() { 11 | test() 12 | var a []string 13 | fmt.Println(len(a)) 14 | } 15 | -------------------------------------------------------------------------------- /go/strconv/formatFloat.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | func main() { 9 | val := 0.00000001 10 | f := byte('e') 11 | fmt.Println(strconv.FormatFloat(float64(val), f, -1, 64)) 12 | } 13 | -------------------------------------------------------------------------------- /rust/reqwest/example/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "example" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | reqwest = "^0.9.18" 9 | serde_json = "1.0.40" 10 | -------------------------------------------------------------------------------- /rust/rustyline_test/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /c/sds/Makefile: -------------------------------------------------------------------------------- 1 | all: sds-test 2 | 3 | sds-test: sds.c sds.h testhelp.h 4 | $(CC) -o sds-test sds.c -Wall -std=c99 -pedantic -O2 -DSDS_TEST_MAIN 5 | @echo ">>> Type ./sds-test to run the sds.c unit tests." 6 | 7 | clean: 8 | rm -f sds-test 9 | -------------------------------------------------------------------------------- /go_web/readme.md: -------------------------------------------------------------------------------- 1 | 目前的binding和validate模块普遍存在一个问题 2 | 3 | 因为golang的int、string之类的字段的语义缺失问题的关系(不能=nil),如果先bind,再validate,没有办法判断一个字段的0值是因为默认值导致还是因为用户输入导致 4 | 5 | 而大多数validate模块的required实际上也就只是判断deserilize之后的值是否是字段的默认值而已,这样的判断是不严谨的。很可能会出bug 6 | 7 | -------------------------------------------------------------------------------- /js/test.js: -------------------------------------------------------------------------------- 1 | var foo = 0; 2 | var timer = setInterval(function(){ 3 | foo++; 4 | }, 500); 5 | while(1){ 6 | if(foo == 10){ 7 | clearInterval(timer); 8 | break; 9 | } else { 10 | console.log(foo); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /scala/lists/fold_left.scala: -------------------------------------------------------------------------------- 1 | val a = List(1, 3, 5, 7) 2 | 3 | // 和reduce一样,不过foldLeft有个start value 4 | println(a.foldLeft(0)(_ + _)) 5 | println(a.foldLeft(0)(_ * _)) 6 | println(a.foldLeft(10)(_ + _)) 7 | println(a.foldLeft(10)(_ * _)) 8 | 9 | -------------------------------------------------------------------------------- /go/go1.13/deferproc.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | for i := 0; i < 10; i++ { 7 | defer func() { 8 | for { 9 | var a = make([]int, 128) 10 | fmt.Println(a) 11 | } 12 | }() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /go/goroutine/goForPrint.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "runtime" 4 | import "time" 5 | 6 | func main() { 7 | 8 | runtime.GOMAXPROCS(1) 9 | for i := 0; i < 10; i++ { 10 | go println(i) 11 | } 12 | time.Sleep(2 * time.Second) 13 | } 14 | -------------------------------------------------------------------------------- /go/math/accurance.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | import "reflect" 5 | 6 | func main() { 7 | var a = 0.57 8 | var b = a * 100 9 | fmt.Println(reflect.TypeOf(a).Kind()) 10 | fmt.Println(b) 11 | fmt.Println(int(b)) 12 | } 13 | -------------------------------------------------------------------------------- /go/slice/merge_slices.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = []int{0, 1, 2, 3, 4, 5, 6, 7} 7 | merged := append([]int{}, a[:5]...) 8 | merged = append(merged, a[6:]...) 9 | fmt.Println(merged) 10 | } 11 | -------------------------------------------------------------------------------- /go/suffix/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "index/suffixarray" 6 | ) 7 | 8 | func main() { 9 | idx := suffixarray.New([]byte("abcdbcbcbcefg")) 10 | res := idx.Lookup([]byte("bc"), -1) 11 | fmt.Println(res) 12 | } 13 | -------------------------------------------------------------------------------- /go_web/martini.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/go-martini/martini" 4 | 5 | func hello() string { 6 | return "Hello world" 7 | } 8 | 9 | func main() { 10 | m := martini.Classic() 11 | m.Get("/", hello) 12 | m.Run() 13 | } 14 | -------------------------------------------------------------------------------- /php/arr_test.php: -------------------------------------------------------------------------------- 1 | ['sdfsdf'], 4 | 'sss' => ['sz'], 5 | 'x' => [] 6 | ]; 7 | print_r($arr); 8 | unset($arr[1]); 9 | unset($arr['sss']); 10 | unset($arr['x']); 11 | var_dump($arr); 12 | -------------------------------------------------------------------------------- /c/encapsulation/main.c: -------------------------------------------------------------------------------- 1 | #include "point.h" 2 | #include 3 | 4 | int main() { 5 | struct Point * p = makePoint(1.1, 2.2); 6 | printf("%p", p); 7 | // printf("%f", p->x); 8 | // 这样的无法访问到 p->x 的,编译会报错 9 | return 0; 10 | } -------------------------------------------------------------------------------- /go/asm/is_frame_pointer_on_stack_value_equal_to_directive_FP/global.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func output(int) (int, int) 8 | 9 | func main() { 10 | a, b := output(987654321) 11 | fmt.Println(a, b) 12 | } 13 | -------------------------------------------------------------------------------- /go/atomic/uber_atomic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | atomicex "go.uber.org/atomic" 7 | ) 8 | 9 | func main() { 10 | var a atomicex.Uint32 11 | fmt.Println(a.Load()) 12 | a.Store(23) 13 | fmt.Println(a.Load()) 14 | } 15 | -------------------------------------------------------------------------------- /go/test_with_tags/production.go: -------------------------------------------------------------------------------- 1 | // +build !test 2 | 3 | package xxx 4 | 5 | func init() { 6 | getUserFunc = func() bool { return true } 7 | validateFunc = func() bool { return true } 8 | createOrderFunc = func() bool { return true } 9 | } 10 | -------------------------------------------------------------------------------- /js/intervaltest.js: -------------------------------------------------------------------------------- 1 | var t, sec = 0; 2 | function countDown() { 3 | clearInterval(t); 4 | setTimeout(countDown, 1000); 5 | sec++; 6 | console.log(sec); 7 | } 8 | 9 | function test() { 10 | t = setInterval(countDown, 1000); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /js/test2.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | var z = 2; 3 | var y = function(x){ 4 | console.log(x); 5 | }; 6 | y(); 7 | (function(x){ 8 | y(); 9 | function y(x) { 10 | console.log(x); 11 | var x = 2; 12 | console.log(x); 13 | } 14 | })(); 15 | -------------------------------------------------------------------------------- /os/chapter_2/readme.md: -------------------------------------------------------------------------------- 1 | mac 环境, 2 | 3 | > brew install binutils 4 | 5 | 所有的命令以g开头,例如greadelf,gobjdump 6 | 7 | > gcc -c 8 | 9 | -c Only run preprocess, compile, and assemble steps 10 | 11 | 只运行预处理,编译,汇编 12 | 13 | 也就是说不做链接 14 | 15 | -------------------------------------------------------------------------------- /c++/double.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | double a = 0.57; 6 | double b = a * 100; 7 | cout << a << endl; 8 | cout << b << endl; 9 | cout << (int)b << endl; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /go/asm/goid/goid_amd64.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | #include "go_tls.h" 3 | 4 | TEXT ·getg(SB), NOSPLIT, $0-8 5 | get_tls(CX) 6 | MOVQ g(CX), AX 7 | LEAQ 152(AX), BX // this is the offset 8 | MOVQ (BX), DX 9 | MOVQ DX, ret+0(FP) 10 | RET 11 | -------------------------------------------------------------------------------- /go/errcheck/errcheck.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | // 这种场景可以用 gas/gometalinter 检查出来 10 | req, _ := http.NewRequest("GET", "http://www.baidu.com", nil) 11 | fmt.Println(req) 12 | } 13 | -------------------------------------------------------------------------------- /go/line_feed.go: -------------------------------------------------------------------------------- 1 | // in nginx, it append a line feed to each log line 2 | //http://www.perlmonks.org/?node_id=264431 3 | package main 4 | 5 | func main() { 6 | var a = "\x0a" 7 | var b = "\n" 8 | println(a == b) 9 | println([]byte(b)[0]) 10 | } 11 | -------------------------------------------------------------------------------- /go/slice/append_when_under_array_has_capacity.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = [...]int{1, 2, 3, 4, 5} 7 | // will use the cap of array underneath 8 | b := a[1:3] 9 | fmt.Println(len(b), cap(b)) 10 | } 11 | -------------------------------------------------------------------------------- /go/test_with_tags/test_fakes.go: -------------------------------------------------------------------------------- 1 | // +build test 2 | 3 | package xxx 4 | 5 | func init() { 6 | getUserFunc = func() bool { return false } 7 | validateFunc = func() bool { return false } 8 | createOrderFunc = func() bool { return false } 9 | } 10 | -------------------------------------------------------------------------------- /shell/awk/test.awk: -------------------------------------------------------------------------------- 1 | { 2 | x = $1 % 1000 3 | #print x 4 | driver_id = $1 5 | order_id = $2 6 | print "update db_name.table_name"driver_id % 1000 , "set star = 5 where order_id = " driver_id ";" 7 | #print order_id 8 | } 9 | 10 | -------------------------------------------------------------------------------- /go/ast/example2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Person is 4 | type Person struct { 5 | age int `json:"age"` //ffff 6 | } 7 | 8 | func main() { 9 | 10 | var i int 11 | for { 12 | if true { 13 | i++ 14 | } else { 15 | i-- 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /go/file/get_file_list.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "io/ioutil" 3 | 4 | import "fmt" 5 | func main() { 6 | //ioutil.ReadFile(filenamoe) 7 | filePathList, _:=ioutil.ReadDir("./") 8 | for _, p := range filePathList { 9 | fmt.Println(p.Name()) 10 | } 11 | } -------------------------------------------------------------------------------- /go/goroutine/goroutinetest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "runtime" 4 | 5 | func say(str string) { 6 | for i := 0; i < 5; i++ { 7 | runtime.Gosched() 8 | println(str) 9 | } 10 | } 11 | func main() { 12 | go say("hello") 13 | say("yess") 14 | } 15 | -------------------------------------------------------------------------------- /os/chapter_4/func_call.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int add(int a, int b) { 5 | return a + b; 6 | } 7 | 8 | int main(int argv, char ** argc) { 9 | int a = 1; 10 | int b = 2; 11 | printf("%d\n", add(a,b)); 12 | } 13 | -------------------------------------------------------------------------------- /php/array_slice_test.php: -------------------------------------------------------------------------------- 1 | "] 5 | 6 | [dependencies] 7 | iron = "0.5.1" 8 | mime = "0.2.3" 9 | router = "0.5.1" 10 | urlencoded = "0.5.0" 11 | -------------------------------------------------------------------------------- /scala/lambda/lambda.scala: -------------------------------------------------------------------------------- 1 | def lambda = {x: Int => x+1} 2 | def lambda2 = (x:Int) => x+2 3 | def lambda3 = (x:Int) => x+3 4 | 5 | def lambda4 = new Function1[Int, Int] { 6 | def apply(v1: Int) : Int = v1 - 1 7 | } 8 | 9 | def lambda5(x: Int) = x + 1 10 | -------------------------------------------------------------------------------- /go/algorithm/leetcode/344.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | } 5 | 6 | func reverseString(s string) string { 7 | var res []byte 8 | 9 | for i := len(s) - 1; i >= 0; i-- { 10 | res = append(res, s[i]) 11 | } 12 | 13 | return string(res) 14 | } 15 | -------------------------------------------------------------------------------- /go/cryptoBench/md4/md4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "golang.org/x/crypto/md4" 4 | 5 | var hash []byte 6 | 7 | func test() { 8 | 9 | s1 := "Hello, MD4 test text" 10 | ctx := md4.New() 11 | ctx.Write([]byte(s1)) 12 | hash = ctx.Sum(nil) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /scala/lists/list.scala: -------------------------------------------------------------------------------- 1 | // 注意,和 java 是反着的 2 | //eq tests identity (same object): 3 | val a = List(1, 2, 3) 4 | val b = List(1, 2, 3) 5 | (a eq b) 6 | 7 | //== tests equality (same content): 8 | val a = List(1, 2, 3) 9 | val b = List(1, 2, 3) 10 | (a == b) 11 | -------------------------------------------------------------------------------- /go/atomic_bench/atomic_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkAtomic(b * testing.B) { 6 | b.SetParallelism(100) 7 | b.RunParallel(func(pb *testing.PB) { 8 | for pb.Next() { 9 | atomicStore(0) 10 | } 11 | }) 12 | } 13 | -------------------------------------------------------------------------------- /go/cryptoBench/sha1/sha1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //Go 在多个 crypto/* 包中实现了一系列散列函数。 4 | import "crypto/sha1" 5 | 6 | var bs []byte 7 | 8 | func test() { 9 | s := "Hello, MD4 test text" 10 | h := sha1.New() 11 | h.Write([]byte(s)) 12 | bs = h.Sum(nil) 13 | } 14 | -------------------------------------------------------------------------------- /go/internal/copytest2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type integer int 6 | 7 | func (i integer) printAge() { 8 | fmt.Printf("%p\n", &i) 9 | } 10 | 11 | func main() { 12 | i := integer(1) 13 | fmt.Printf("%p\n", &i) 14 | i.printAge() 15 | } 16 | -------------------------------------------------------------------------------- /go/slice/del_elem.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = []int{0, 1, 2, 3, 4, 5, 6, 7} 7 | fmt.Println(a, "cap", cap(a), "len", len(a)) 8 | a = append(a[:5], a[6:]...) 9 | fmt.Println(a, "cap", cap(a), "len", len(a)) 10 | } 11 | -------------------------------------------------------------------------------- /rust/read_from_stdin/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io::{self, Read}; 2 | 3 | fn main() -> io::Result<()> { 4 | let mut buffer = Vec::new(); 5 | io::stdin().read_to_end(&mut buffer)?; 6 | println!("read result : {:?}", String::from_utf8(buffer)); 7 | Ok(()) 8 | } 9 | -------------------------------------------------------------------------------- /scala/lists/tail_reuse.scala: -------------------------------------------------------------------------------- 1 | val d = Nil 2 | 3 | val c = 3 :: d 4 | val b = 2 :: c 5 | val a = 1 ::b 6 | println(a) 7 | println(b) 8 | println(c) 9 | println(d) 10 | 11 | println(a.tail) 12 | println(b.tail) 13 | println(c.tail) 14 | //println(d.tail) exception 15 | -------------------------------------------------------------------------------- /c++/signal/signal.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void handle_sigint(int sig) 5 | { 6 | printf("Caught signal %d\n", sig); 7 | } 8 | 9 | int main() 10 | { 11 | signal(SIGINT, handle_sigint); 12 | while (1) ; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /go/interface/multi_instance.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Printer interface { 4 | Print() 5 | } 6 | 7 | type person struct{} 8 | 9 | func (p person) Print() {} 10 | 11 | type gogo struct{} 12 | 13 | func (g gogo) Print() {} 14 | 15 | func main() { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /go/raft/hashicorp.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/hashicorp/raft" 4 | 5 | func main() { 6 | conf := raft.Config{} 7 | logs := raft.Log{} 8 | stable := raft.StableStore{} 9 | raft.BootstrapCluster(conf, logs, stable, snaps, trans, configuration) 10 | } 11 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/process-title.js: -------------------------------------------------------------------------------- 1 | // gh-10 2 | var Fiber = require('fibers'); 3 | 4 | var title = process.title; 5 | Fiber(function() { 6 | process.title = 'pass'; 7 | }).run(); 8 | console.log(process.title === 'pass' || process.title === title ? 'pass' : 'fail'); 9 | -------------------------------------------------------------------------------- /rust/assoc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assoc" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/iter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "iter" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/pest_test/src/ident.pest: -------------------------------------------------------------------------------- 1 | alpha = { 'a'..'z' | 'A'..'Z' } 2 | digit = { '0'..'9' } 3 | 4 | ident = { (alpha | digit)+ } 5 | 6 | ident_list = _{ !digit ~ ident ~ (" " ~ ident)+ } 7 | // ^ 8 | // ident_list rule is silent which means it produces no tokens 9 | -------------------------------------------------------------------------------- /shell/expect: -------------------------------------------------------------------------------- 1 | #!/usr/bin/sh 2 | user=$1 3 | if [[ $user -eq "me" ]]; 4 | then 5 | expect << EOF 6 | set timeout 30 7 | spawn ssh root@10.10.38.89 -o StrictHostKeyChecking=no 8 | expect "password" 9 | send "iovVmVI!@vm\r" 10 | expect eof 11 | EOF 12 | fi 13 | -------------------------------------------------------------------------------- /go/expand/readme.md: -------------------------------------------------------------------------------- 1 | # 内置结构扩容 2 | 3 | 需要注意的是,虽然很多人说 slice 是引用传递,但这种说法是不精确的。 4 | 5 | 如果传入函数的 slice 在函数内发生了扩容,那么扩容之后的 slice 就是该函数中新的局部 slice 了,任何修改不会影响到 caller 的 slice。 6 | 7 | 因为本质上传入 callee 的是 caller 中 slice 的地址值,这个地址值还是一个副本,只是值与 caller 中的 slice 的一样。但一旦存储该地址值本身的变量发生了变化,那就和原来没什么关系了。 8 | -------------------------------------------------------------------------------- /go/goroutine/channelmakeandchannelnotmake.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a chan int 5 | var b = make(chan int) 6 | //注意,只声明不初始化的话,a的值是空,没法直接使用 7 | //go里的三种特殊数据结构都是需要初始化的 8 | println(a) 9 | println(b) 10 | a = make(chan int) 11 | println(a) 12 | } 13 | -------------------------------------------------------------------------------- /go/string/replaceNums.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "unicode" 7 | ) 8 | 9 | func main() { 10 | var a = `g_service_1323` 11 | a = strings.TrimRightFunc(a, unicode.IsDigit) 12 | a = strings.TrimRight(a, "_") 13 | fmt.Println(a) 14 | } 15 | -------------------------------------------------------------------------------- /js/closure2.js: -------------------------------------------------------------------------------- 1 | var name = "trigkit4"; 2 | var segmentFault = { 3 |  name : "My SF", 4 |  getNameFunc : function(){ 5 |   return function(){ 6 |    return this.name; 7 |  }; 8 | } 9 | }; 10 | console.log(segmentFault.getNameFunc()()); //弹出trigkit4 11 | -------------------------------------------------------------------------------- /os/chapter_3/practise/loop.s: -------------------------------------------------------------------------------- 1 | global _start 2 | 3 | section .text 4 | 5 | _start: 6 | mov rcx, 236 7 | mov rax, 123 8 | 9 | s: 10 | add rax, 123 11 | loop s; 在rcx 变为 0 之前,loop 会一直执行 12 | 13 | mov rax, 60; 'exit' syscall number 14 | xor rdi, rdi 15 | syscall 16 | 17 | -------------------------------------------------------------------------------- /os/chapter_4/more_than_7_params.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "stdlib.h" 3 | 4 | void test(long a, long b, long c, long d, long e, long f, long g, long h) { 5 | printf( "%ld\n", a+b+c+d+e+f+g+h); 6 | } 7 | 8 | int main() { 9 | test(1,2,3,4,5,6,7,8); 10 | } 11 | -------------------------------------------------------------------------------- /rust/1.42/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/1.43/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/assoc2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assoc2" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/assoc3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "assoc3" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/box_arr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "box_arr" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/closure/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "closure" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/hashmap/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hashmap" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/ngx_rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ngx_rs" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/traits/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "generics" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /github_icons/show.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/cch123/elasticsql.svg?branch=master)](https://travis-ci.org/cch123/elasticsql) 2 | [![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/cch123/elasticsql) 3 | -------------------------------------------------------------------------------- /go/asm/local_var.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // 注意观察这个函数的 args 和 locals 6 | // 以及生成的汇编的 $x-y 之间的关系 7 | func test(x []int) int { 8 | var a = 1 9 | var b = struct{ X int }{X: 93} 10 | fmt.Println(b) 11 | return a + b.X 12 | } 13 | 14 | func main() { 15 | } 16 | -------------------------------------------------------------------------------- /go/expand/slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func testSlice(sl []int) { 6 | for i := 0; i < 1000; i++ { 7 | sl = append(sl, i) 8 | } 9 | fmt.Println(sl) 10 | } 11 | 12 | func main() { 13 | var a = []int{} 14 | testSlice(a) 15 | fmt.Println(a) 16 | } 17 | -------------------------------------------------------------------------------- /rust/flat_map/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "flat_map" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/partial_eq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "partial_eq" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/prec_climber_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "prec_climber_test" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | pest = "2.0" 9 | pest_derive = "2.0" 10 | serde_json = "1.0.37" 11 | rustyline = "1" 12 | -------------------------------------------------------------------------------- /uml/advanced_sequence.txt: -------------------------------------------------------------------------------- 1 | @startuml 2 | participant Ark #white 3 | participant Noah #eeffee 4 | participant "SMS \n网关" as sms 5 | 6 | Ark -[#orange]> Noah : send sms 7 | Noah -> sms : send request 8 | Noah --[#red]> Ark : return success 9 | @enduml 10 | -------------------------------------------------------------------------------- /c++/c++14/map.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main(int argc, char * argv[]) { 6 | map m = {{"a", 1}, {"b", 2}, {"c", 3}}; 7 | cout << m.count("b") << endl; 8 | cout << m["b"] << endl; 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /go/algorithm/leetcode/1/1_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkSum1(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | test1() 8 | } 9 | } 10 | 11 | func BenchmarkSum2(b *testing.B) { 12 | for i := 0; i < b.N; i++ { 13 | test2() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /go/expand/channel.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func testChan(ch chan int) { 6 | ch = make(chan int, 10) 7 | fmt.Println("ch == nil : ", ch == nil) 8 | } 9 | func main() { 10 | var ch chan int 11 | testChan(ch) 12 | fmt.Println("ch == nil : ", ch == nil) 13 | } 14 | -------------------------------------------------------------------------------- /go/expand/map.go: -------------------------------------------------------------------------------- 1 | // map 即使在数组内部扩容了,也不会生成新的局部变量 2 | package main 3 | 4 | import "fmt" 5 | 6 | func testMap(m map[int]int) { 7 | for i := 0; i < 1000; i++ { 8 | m[i] = i 9 | } 10 | } 11 | 12 | func main() { 13 | var m = map[int]int{} 14 | testMap(m) 15 | fmt.Println(m) 16 | } 17 | -------------------------------------------------------------------------------- /go/flowControl/for.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | v := []int{1, 2, 3} 7 | for i := range v { 8 | v = append(v, i) 9 | } 10 | fmt.Println(v) 11 | /* 12 | it is the same with len = len(v) 13 | for i:=0;i 'a', "val" => "1"], 4 | ['name' => 'a', "val" => '2'] 5 | ]; 6 | 7 | $keys = array_column($arr, 'name'); 8 | $new_arr = array_combine($keys, $arr); 9 | $new_arr = array_values($new_arr); 10 | print_r($new_arr); 11 | -------------------------------------------------------------------------------- /php/decode_test.php: -------------------------------------------------------------------------------- 1 | array(1,2), 6 | 'content' => 'ssss' 7 | ]; 8 | var_dump($arr); 9 | var_dump(json_encode($new_arr)); 10 | -------------------------------------------------------------------------------- /rust/1.40/non_exhaustive/a/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "a" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/module_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "module_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/phantomdata/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "phantomdata" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /c++/goto.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int a() { 4 | goto ERROR_HANDLE; 5 | return 1; 6 | ERROR_HANDLE: 7 | printf("aaa"); 8 | return 0; 9 | } 10 | 11 | int main() { 12 | goto ERROR_HANDLE; 13 | ERROR_HANDLE: 14 | printf("1"); 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /go/asm/global/global.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func output() (int, float64, int) 8 | func output2() (int, float64, int) 9 | 10 | func main() { 11 | a, b, c := output() 12 | fmt.Println(a, b, c) 13 | a, b, c =output2() 14 | fmt.Println(a, b, c) 15 | } 16 | -------------------------------------------------------------------------------- /go/asm/where_is_fp_sp/where.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | TEXT ·where(SB), NOSPLIT, $8-32 4 | // MOVQ FP, AX 5 | MOVQ -8(SP), AX // this is hardwhere SP 6 | MOVQ x-8(SP), BX // this is the virtual register SP 7 | MOVQ AX, ret+16(FP) 8 | MOVQ BX, ret+24(FP) 9 | RET 10 | 11 | -------------------------------------------------------------------------------- /go/goevaluate/m.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/Knetic/govaluate" 8 | ) 9 | 10 | func main() { 11 | expr, err := govaluate.NewEvaluableExpression("1+2+3") 12 | v, err := expr.Eval(nil) 13 | fmt.Println(reflect.TypeOf(v), v, err) 14 | } 15 | -------------------------------------------------------------------------------- /go/internal/copytest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type person struct { 6 | age int 7 | } 8 | 9 | func (p person) printAge() { 10 | fmt.Printf("%p\n", &p) 11 | } 12 | 13 | func main() { 14 | p := person{age: 10} 15 | fmt.Printf("%p\n", &p) 16 | p.printAge() 17 | } 18 | -------------------------------------------------------------------------------- /go/reflect/zero_is_what.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(reflect.ValueOf(1).Kind()) 10 | var a = 0.0 11 | fmt.Println(reflect.ValueOf(a).Kind()) 12 | var b = 0 13 | fmt.Println(reflect.ValueOf(b).Kind()) 14 | } 15 | -------------------------------------------------------------------------------- /go/string/b.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a = map[string]int{"abc": 1} 5 | var b = []byte{'a', 'b', 'c'} 6 | // runtime.slicebytetostring 7 | var c = string(b) 8 | _ = a[c] 9 | 10 | // 这里会被优化掉 11 | // 不会出现runtime.slicebytetostring 12 | _ = a[string(b)] 13 | } 14 | -------------------------------------------------------------------------------- /go/string/split_and_same_under_array/ben_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkA(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | A() 8 | } 9 | } 10 | 11 | func BenchmarkB(b *testing.B) { 12 | for i := 0; i < b.N; i++ { 13 | B() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /rust/read_from_stdin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "read_from_stdin" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /c++/project_template/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "0.1.0", 5 | "command": "make", 6 | "isShellCommand": true, 7 | "args": [], 8 | "showOutput": "always" 9 | } -------------------------------------------------------------------------------- /go/1.9/syncMap.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | var codisManager sync.Map 9 | 10 | func main() { 11 | fmt.Printf("%#v\n", codisManager) 12 | codisManager.Store("abc", "1") 13 | res, err := codisManager.Load("abc") 14 | fmt.Println(res, err) 15 | } 16 | -------------------------------------------------------------------------------- /go/dataStructs/annoymous_struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var str = struct { 7 | settings struct { 8 | name string 9 | } 10 | }{ 11 | settings: struct{ name string }{ 12 | name: "fuck", 13 | }, 14 | } 15 | fmt.Printf("%+v\n", str) 16 | } 17 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/current.js: -------------------------------------------------------------------------------- 1 | var Fiber = require('fibers'); 2 | 3 | var current; 4 | Fiber(function() { 5 | current = Fiber.current; 6 | Fiber.yield(); 7 | console.log('pass'); 8 | }).run(); 9 | if (current) { 10 | current.run(); 11 | } else { 12 | console.log('fail'); 13 | } 14 | -------------------------------------------------------------------------------- /rust/astd_load_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "asyncstd_load_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/future-impl/simplefuture/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "future-impl" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/httparse/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "httparse" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | httparse = "1.3.4" -------------------------------------------------------------------------------- /c++/project_template/cpp/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "0.1.0", 5 | "command": "make", 6 | "isShellCommand": true, 7 | "args": [], 8 | "showOutput": "always" 9 | } -------------------------------------------------------------------------------- /go/asm/func_call/call.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | // func callOther() string 4 | TEXT ·callOther(SB), NOSPLIT, $24-16 5 | MOVQ $323232323, (SP) 6 | CALL strconv·Itoa(SB) 7 | MOVQ 8(SP), AX 8 | MOVQ 16(SP), BX 9 | MOVQ AX, ret+0(FP) 10 | MOVQ BX, ret+8(FP) 11 | RET 12 | -------------------------------------------------------------------------------- /go/slice/nil_and_empty_slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a []int 7 | var b = make([]int, 0) 8 | fmt.Println(a == nil) 9 | fmt.Println(b == nil) 10 | fmt.Println(a) 11 | fmt.Println(b) 12 | fmt.Printf("%p\n", &a) 13 | fmt.Printf("%p\n", &b) 14 | } 15 | -------------------------------------------------------------------------------- /rust/1.40/non_exhaustive/b/src/main.rs: -------------------------------------------------------------------------------- 1 | use a::Person; 2 | use a::New; 3 | fn main() { 4 | /* 5 | error[E0639]: cannot create non-exhaustive struct using struct expression 6 | --> src/main.rs:3:13 7 | | 8 | 3 | let p = Person {age :1}; 9 | | 10 | */ 11 | dbg!(New()); 12 | } 13 | -------------------------------------------------------------------------------- /rust/print_file_and_line/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "print_file_and_line" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/proc_macro_workshop/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "proc_macro_workshop" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /vagrant_files/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | debconf-set-selections <<< 'mysql-server mysql-server/root_password password MySuperPassword' 4 | debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password MySuperPassword' 5 | apt-get update 6 | apt-get install -y mysql-server 7 | -------------------------------------------------------------------------------- /c++/unordered_map.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | unordered_map m = {{1,2}, {3,2}}; 7 | m[12] = 1; 8 | m[14] = 1; 9 | for(auto &x: m) { 10 | cout << x.first << " " << x.second << endl; 11 | } 12 | } -------------------------------------------------------------------------------- /go/asm/registers_test/r.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func output() (int, int, int, int, int, int, int, int, int, int, int, int, int, int) 6 | 7 | func main() { 8 | a, b, c, d, e, f, g, h, i, j, k, l, m, n := output() 9 | fmt.Println(a, b, c, d, e, f, g, h, i, j, k, l, m, n) 10 | } 11 | -------------------------------------------------------------------------------- /go/string/hasPrefix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | var a = "g_qc_source_0" 10 | fmt.Println(strings.HasPrefix(a, "g_qc_source")) 11 | fmt.Println(strings.HasPrefix(a, "g_qc_sourcw")) 12 | fmt.Println(fmt.Sprintf("%v_%v", 1, "1")) 13 | } 14 | -------------------------------------------------------------------------------- /go/time/timeunmarshal.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "time" 7 | ) 8 | 9 | func main() { 10 | var a = `{"time" : "2015-01-01 00:00:00"}` 11 | var b struct { 12 | Time time.Time 13 | } 14 | err := json.Unmarshal([]byte(a), &b) 15 | fmt.Println(b, err) 16 | } 17 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/stack-overflow.js: -------------------------------------------------------------------------------- 1 | var Fiber = require('fibers'); 2 | try { 3 | Fiber(function() { 4 | function foo() { 5 | var hello = Math.random(); 6 | foo(); 7 | } 8 | foo(); 9 | }).run(); 10 | } catch (err) { 11 | err.name === 'RangeError' && console.log('pass'); 12 | } 13 | -------------------------------------------------------------------------------- /rust/loop_time_and_mul_threads_join/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "loop_time_cost" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | -------------------------------------------------------------------------------- /rust/thrift_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "thrift_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | thrift = "0.13.0" 11 | -------------------------------------------------------------------------------- /vagrant_files/init.sh: -------------------------------------------------------------------------------- 1 | echo " 2 | rdr pass inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080 3 | rdr pass inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 4443 4 | " | sudo pfctl -ef - >/dev/null 2>&1; echo "Add Port Forwarding (80 => 8080)\nAdd Port Forwarding (443 => 8443)" 5 | 6 | -------------------------------------------------------------------------------- /c++/c++14/constptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | const int a = 1; 6 | auto b = a; 7 | b = 4; 8 | auto c = &b; 9 | auto d = &a; 10 | 11 | cout << typeid(c).name() << endl; 12 | cout << typeid(d).name() << endl; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /go/future/panic_or_not.go: -------------------------------------------------------------------------------- 1 | // 还是会 panic 的,请注意 2 | package main 3 | 4 | import "fmt" 5 | 6 | func main() { 7 | var ch = make(chan int) 8 | var ch2 = make(chan int, 1) 9 | ch2 <- 1 10 | close(ch) 11 | select { 12 | case ch <- 1: 13 | case n := <-ch2: 14 | fmt.Println("not panic", n) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /go/goroutine/goroutine.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "runtime" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | runtime.GOMAXPROCS(1) 10 | //runtime.GOMAXPROCS(1) 11 | for i := 0; i < 10; i++ { 12 | go func(i int) { 13 | println(i) 14 | }(i) 15 | } 16 | time.Sleep(time.Second * 2) 17 | } 18 | -------------------------------------------------------------------------------- /go/map/isMapOrdered.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | var a = map[string]int{ 8 | "1": 1, 9 | "2": 2, 10 | } 11 | 12 | var counter int 13 | for counter < 100 { 14 | for key, _ := range a { 15 | fmt.Printf("%s ", key) 16 | } 17 | println() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /go/panic/panic_or_not.go: -------------------------------------------------------------------------------- 1 | // 还是会 panic 的,请注意 2 | package main 3 | 4 | import "fmt" 5 | 6 | func main() { 7 | var ch = make(chan int) 8 | var ch2 = make(chan int, 1) 9 | ch2 <- 1 10 | close(ch) 11 | select { 12 | case ch <- 1: 13 | case n := <-ch2: 14 | fmt.Println("not panic", n) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /go/receiver/pointer_rec.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type person struct{ age int } 6 | 7 | func (p *person) prin() { 8 | fmt.Printf("%p\n", p) 9 | p.age = 2 10 | } 11 | 12 | func main() { 13 | var p person 14 | // 会自动取地址 15 | p.prin() 16 | println(&p) 17 | fmt.Println(p) 18 | } 19 | -------------------------------------------------------------------------------- /js/node_modules/fibers/test/unwind.js: -------------------------------------------------------------------------------- 1 | var Fiber = require('fibers'); 2 | 3 | var ii; 4 | var fn = Fiber(function() { 5 | for (ii = 0; ii < 1000; ++ii) { 6 | try { 7 | Fiber.yield(); 8 | } catch (err) {} 9 | } 10 | }); 11 | 12 | fn.run(); 13 | fn.reset(); 14 | ii === 1000 && console.log('pass'); 15 | -------------------------------------------------------------------------------- /js/timeouttest.js: -------------------------------------------------------------------------------- 1 | var t, sec = 0; 2 | function countDown() { 3 | //clearTimeout(t); 4 | t = setTimeout(countDown, 1000); 5 | sec++; 6 | if(sec == 60) { 7 | clearTimeout(t); 8 | } 9 | console.log(sec); 10 | } 11 | 12 | function test() { 13 | t = setTimeout(countDown, 1000); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /rust/1.40/non_exhaustive/b/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "b" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | a = {path = "../a"} 11 | -------------------------------------------------------------------------------- /rust/lazy_static/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "lazy_static" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | lazy_static = "1.3.0" 11 | -------------------------------------------------------------------------------- /rust/rock_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rock_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | rocket = "0.4.2" 11 | 12 | -------------------------------------------------------------------------------- /c++/c++14/rvalue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int && ref = 1+2; 6 | ref +=1; 7 | int a = 1; 8 | cout << "value is " << ref << " and ptr is " << &ref << endl; 9 | cout << "value is " << a << " and ptr is " << &a<< endl; 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /go/flowControl/gototest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func test(i int) { 4 | if i < 0 { 5 | goto ERROR_HANDLE 6 | } 7 | return 8 | ERROR_HANDLE: 9 | println("this is error handle") 10 | return 11 | } 12 | 13 | func main() { 14 | println("test 2") 15 | test(2) 16 | println("test -1") 17 | test(-1) 18 | } 19 | -------------------------------------------------------------------------------- /go/gomod/vendor/github.com/cch123/gomodexp/esutil/main.go: -------------------------------------------------------------------------------- 1 | package esutil 2 | 3 | import "fmt" 4 | import "github.com/cch123/elasticsql" 5 | 6 | func init() { 7 | fmt.Println("init function in etcdcli") 8 | } 9 | 10 | func OhES() { 11 | fmt.Println("OhETCD") 12 | elasticsql.Convert("select * from a") 13 | } 14 | -------------------------------------------------------------------------------- /go/interface/interfaceReflect.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | var val interface{} = int64(58) 10 | fmt.Println(reflect.TypeOf(val)) 11 | val = 50 12 | fmt.Println(reflect.TypeOf(val)) 13 | val = "abc" 14 | fmt.Println(reflect.TypeOf(val)) 15 | } 16 | -------------------------------------------------------------------------------- /php/coltest.php: -------------------------------------------------------------------------------- 1 | 2014, 5 | 'value' => 100 6 | ), array( 7 | 'order_no' => 2014, 8 | 'value' => 130 9 | ) 10 | ); 11 | $key = array_column($arr, 'order_no'); 12 | $arr = array_combine($key, $arr); 13 | print_r($arr); 14 | -------------------------------------------------------------------------------- /rust/future-impl/simple_poll/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "simple_poll" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | futures = "0.3" 11 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/controller/order.rs: -------------------------------------------------------------------------------- 1 | #![feature(proc_macro_hygiene)] 2 | #![feature(decl_macro)] 3 | 4 | #[get("/info/")] 5 | pub fn get_order_info(id: i64) -> String { 6 | let mut res = "hello this is order detail".to_string(); 7 | res.push_str(&id.to_string()); 8 | res 9 | } 10 | -------------------------------------------------------------------------------- /scala/lists/list_methods.scala: -------------------------------------------------------------------------------- 1 | val a = List(1, 3, 5, 7, 9) 2 | 3 | println(a.length) 4 | 5 | println(a.reverse) 6 | println(a) 7 | 8 | a.map { 9 | v => v * 100 10 | } 11 | 12 | println(a) 13 | 14 | a.filter { 15 | v => v % 3 == 0 16 | } 17 | 18 | println(a) 19 | 20 | // 上面的操作都会生成新的列表,并不会影响到原始的对象 21 | -------------------------------------------------------------------------------- /go/asm/goid/goid.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func getg() uint64 9 | 10 | var offset = map[string]int{} 11 | 12 | func main() { 13 | g := getg() 14 | fmt.Println(g) 15 | go func() { 16 | g := getg() 17 | fmt.Println(g) 18 | }() 19 | time.Sleep(time.Second) 20 | } 21 | -------------------------------------------------------------------------------- /go/asm/is_frame_pointer_on_stack_value_equal_to_directive_FP/global.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | 4 | // func output(int) (int, int) 5 | TEXT ·output(SB),$0-24 6 | MOVQ arg0+0(FP), AX 7 | MOVQ AX, ret1+8(FP) 8 | MOVQ argx+0(SP), BX 9 | MOVQ (BX), AX 10 | MOVQ AX, ret2+16(FP) 11 | RET 12 | 13 | -------------------------------------------------------------------------------- /go/black_magic/linkname.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | _ "runtime" 5 | _ "time" 6 | _ "unsafe" 7 | ) 8 | 9 | //go:linkname throw runtime.throw 10 | func throw(s string) 11 | 12 | //go:nosplit 应该是没啥用 13 | 14 | func main() { 15 | throw("abc") 16 | 17 | // cannot reach here 18 | println("ooo") 19 | } 20 | -------------------------------------------------------------------------------- /go/flowControl/panictest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | var user = os.Getenv("USER") 6 | 7 | func init() { 8 | println("init is automatically called") 9 | if user == "" { 10 | panic("no value for $USER") 11 | } 12 | println("the value of user is " + user) 13 | } 14 | 15 | func main() { 16 | } 17 | -------------------------------------------------------------------------------- /go/race/g.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "runtime" 4 | 5 | var a int 6 | 7 | func calc() { 8 | for i := 0; i < 10; i++ { 9 | go func() { 10 | for { 11 | runtime.RaceDisable() 12 | a++ 13 | runtime.RaceEnable() 14 | } 15 | }() 16 | 17 | } 18 | } 19 | 20 | func main() { 21 | calc() 22 | } 23 | -------------------------------------------------------------------------------- /go/race/g2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "runtime" 4 | 5 | var a int 6 | 7 | func calc() { 8 | for i := 0; i < 10; i++ { 9 | go func() { 10 | for { 11 | runtime.RaceDisable() 12 | a++ 13 | runtime.RaceEnable() 14 | } 15 | }() 16 | 17 | } 18 | } 19 | 20 | func main() { 21 | calc() 22 | } 23 | -------------------------------------------------------------------------------- /js/segmentfault.js: -------------------------------------------------------------------------------- 1 | 2 | function constfuncs() { 3 | var funcs = []; 4 | for (var i = 0; i < 10; i++) { 5 | funcs[i] = function () { 6 | return i; 7 | }() 8 | } 9 | console.log(i) 10 | return funcs; 11 | } 12 | var funcs = constfuncs(); 13 | console.log(funcs[1]); 14 | console.log(funcs[2]); 15 | -------------------------------------------------------------------------------- /python/timedelta.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | yearAgoStr = (datetime.datetime.now() + datetime.timedelta(days = -365)).strftime("%Y-%m-%d 00:00:00") 4 | todayStr = datetime.datetime.now().strftime("%Y-%m-%d 00:00:00") 5 | 6 | cond = "where create_time >= '%s' and create_time < '%s'" %(yearAgoStr, todayStr) 7 | 8 | print cond 9 | -------------------------------------------------------------------------------- /rust/actix/actix_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "actix_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | actix-web = "1.0" 9 | futures = "0.1.25" 10 | http = "0.1.0" 11 | actix-http = "0.2.3" 12 | 13 | [dev-dependencies] 14 | env_logger = "0.6" -------------------------------------------------------------------------------- /rust/load_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "load_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | async-std = "1" 11 | futures = "0.3" 12 | -------------------------------------------------------------------------------- /rust/pest_test/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | var ch = make(chan int) 7 | go func() { 8 | time.Sleep(time.Second) 9 | ch = nil 10 | time.Sleep(time.Second) 11 | ch = make(chan int) 12 | }() 13 | 14 | for { 15 | select { 16 | case v := <-ch: 17 | println(v) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /go/asm/basic_math_ops/math.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func add(a, b int) int 6 | 7 | func sub(a, b int) int 8 | 9 | func mul(a, b int) int 10 | 11 | //func div(a, b int) int 12 | 13 | func main() { 14 | fmt.Println(add(10, 11)) 15 | fmt.Println(sub(99, 15)) 16 | fmt.Println(mul(11, 12)) 17 | } 18 | -------------------------------------------------------------------------------- /go/asm/relative_pos_of_FP_and_SP/global.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func output(int) (int, int, int) 8 | func output2(int) (int, int, int) 9 | 10 | func main() { 11 | a, b, c := output(987654321) 12 | fmt.Println(a, b, c) 13 | a, b, c = output2(98765) 14 | fmt.Println(a, b, c) 15 | } 16 | -------------------------------------------------------------------------------- /go/dataStructs/listtest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "container/list" 4 | import "fmt" 5 | 6 | func main() { 7 | l := list.New() 8 | l.PushBack(1) 9 | l.PushBack(2) 10 | l.PushBack(3) 11 | l.PushBack(4) 12 | for elem := l.Front(); elem != nil; elem = elem.Next() { 13 | fmt.Println(elem.Value) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /go/file/filetest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func exit_this(f os.File) { 9 | f.Close() 10 | println("file closed") 11 | } 12 | 13 | func main() { 14 | f, _ := os.Open("./arrtest.go") 15 | fmt.Printf("%+v\n", f) 16 | fmt.Printf("%+v\n", *f) 17 | defer exit_this(*f) 18 | } 19 | -------------------------------------------------------------------------------- /go/pprof/pprof.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | _ "net/http/pprof" 6 | ) 7 | 8 | var quit chan struct{} = make(chan struct{}) 9 | 10 | func f() { 11 | <-quit 12 | } 13 | 14 | func main() { 15 | for i := 0; i < 10000; i++ { 16 | go f() 17 | } 18 | 19 | http.ListenAndServe(":8080", nil) 20 | } 21 | -------------------------------------------------------------------------------- /rust/maplit/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "maplit" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | maplit = "1.0" 11 | unicorn = "0.9.1" 12 | 13 | -------------------------------------------------------------------------------- /go/1.8/db.go: -------------------------------------------------------------------------------- 1 | //cancelable queries 2 | //visible database types 3 | //multiple result sets 4 | //ping can hit server 5 | //named parameters 6 | //transaction isolation levels 7 | // https://docs.google.com/document/d/1F778e7ZSNiSmbju3jsEWzShcb8lIO4kDyfKDNm4PNd8/edit# 8 | 9 | package main 10 | 11 | func main() { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /go/dependency-experiment/injection_based/codis.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type codisService struct { 6 | connOptions []string 7 | } 8 | 9 | func initCodis() (*codisService, error) { 10 | fmt.Println("init codis") 11 | return &codisService{ 12 | connOptions: []string{"yyy", "zzz"}, 13 | }, nil 14 | } 15 | -------------------------------------------------------------------------------- /go/goroutine/chantest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | import "time" 5 | 6 | func worker(done chan bool) { 7 | fmt.Print("working...") 8 | time.Sleep(time.Second) 9 | fmt.Println("done") 10 | done <- true 11 | } 12 | 13 | func main() { 14 | done := make(chan bool, 1) 15 | go worker(done) 16 | <-done 17 | } 18 | -------------------------------------------------------------------------------- /js/node_modules/fibers/src/libcoro/README: -------------------------------------------------------------------------------- 1 | Configuration, documentation etc. is provided in the coro.h file. Please 2 | note that the file conftest.c in this distribution is under the GPL. It is 3 | not needed for proper operation of this library though, for that, coro.h 4 | and coro.c suffice. 5 | 6 | Marc Lehmann 7 | -------------------------------------------------------------------------------- /python/guolele/scrapy.cfg: -------------------------------------------------------------------------------- 1 | # Automatically created by: scrapy startproject 2 | # 3 | # For more information about the [deploy] section see: 4 | # https://scrapyd.readthedocs.org/en/latest/deploy.html 5 | 6 | [settings] 7 | default = guolele.settings 8 | 9 | [deploy] 10 | #url = http://localhost:6800/ 11 | project = guolele 12 | -------------------------------------------------------------------------------- /scala/lambda/returning_annoymous_function.scala: -------------------------------------------------------------------------------- 1 | def addWithSyntaxSugar(x: Int) = (y: Int) ⇒ x + y 2 | 3 | addWithSyntaxSugar(1).isInstanceOf[Function1[Int, Int]] 4 | 5 | addWithSyntaxSugar(2)(3) 6 | 7 | def fiveAdder = addWithSyntaxSugar(5) 8 | 9 | fiveAdder(5) 10 | 11 | addWithSyntaxSugar(1).isInstanceOf[Function1[_, _]] 12 | -------------------------------------------------------------------------------- /uml/activity.txt: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | scale 1024*768 4 | 5 | start 6 | 7 | if (exec Lazarus?) then (yes) 8 | :find a livable planet; 9 | :save **human beings**; 10 | else (no) 11 | :keep adapting, 12 | __keep farming__ and keep dying; 13 | endif 14 | 15 | stop 16 | 17 | @enduml 18 | 19 | -------------------------------------------------------------------------------- /go/reflect/reflecttest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | import "fmt" 5 | 6 | func main() { 7 | var i = 1 8 | fmt.Println(reflect.TypeOf(i)) 9 | fmt.Println(reflect.ValueOf(i)) 10 | fmt.Println(reflect.ValueOf(i).Type()) 11 | fmt.Println(reflect.ValueOf(i).Kind()) 12 | fmt.Println(reflect.ValueOf(i).Int()) 13 | } 14 | -------------------------------------------------------------------------------- /php/fuck.php: -------------------------------------------------------------------------------- 1 | 1, 4 | "products" => [ 5 | [ 6 | "id" => 42, 7 | "quantity" => 3 8 | ], 9 | [ 10 | "id" => 43, 11 | "quantity" => 2 12 | ] 13 | ] 14 | ]; 15 | echo json_encode($arr); 16 | -------------------------------------------------------------------------------- /rust/programming_rust/ch1/hello/target/rls/debug/deps/hello-361a3be39b79a777.d: -------------------------------------------------------------------------------- 1 | /Users/caochunhui/test/rust/programming_rust/ch1/hello/target/rls/debug/deps/hello-361a3be39b79a777.rmeta: src/main.rs 2 | 3 | /Users/caochunhui/test/rust/programming_rust/ch1/hello/target/rls/debug/deps/hello-361a3be39b79a777.d: src/main.rs 4 | 5 | src/main.rs: 6 | -------------------------------------------------------------------------------- /rust/rustyline_test/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /c++/c++14/decltype.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a = 1, b = 2; 6 | decltype(a) c = a + b; 7 | cout << c << endl; 8 | cout << typeid(c).name() << endl; 9 | auto d = a + c; 10 | cout << d << endl; 11 | cout << typeid(d).name() << endl; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /c/c11/noreturn.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | // c11 增加了 _Alignof _Alignas _Atomic _Generic _Noreturn _Static_assert 4 | // _Thread_local 几个新关键字 5 | 6 | _Noreturn fun() { 7 | printf("in fun\n"); 8 | } 9 | 10 | int main() { 11 | printf("start main\n"); 12 | fun(); 13 | printf("end main\n"); 14 | } 15 | -------------------------------------------------------------------------------- /go/http/httpclient.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "net/http" 7 | ) 8 | 9 | func main() { 10 | resp, err := http.Get("http://baidu.com") 11 | fmt.Println(resp) 12 | fmt.Println(err) 13 | bodyBytes, err := ioutil.ReadAll(resp.Body) 14 | fmt.Println(string(bodyBytes)) 15 | fmt.Println(err) 16 | } 17 | -------------------------------------------------------------------------------- /go/test_with_tags/m.go: -------------------------------------------------------------------------------- 1 | package xxx 2 | 3 | import "fmt" 4 | 5 | var ( 6 | getUserFunc func() bool 7 | validateFunc func() bool 8 | createOrderFunc func() bool 9 | ) 10 | 11 | // Process ... 12 | func Process() { 13 | fmt.Println(getUserFunc()) 14 | fmt.Println(validateFunc()) 15 | fmt.Println(createOrderFunc()) 16 | } 17 | -------------------------------------------------------------------------------- /go/channel/channelLen.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan int, 100) 5 | ch <- 1 6 | ch <- 1 7 | for i := 0; i < 100; i++ { 8 | 9 | go func() { 10 | <-ch 11 | }() 12 | } 13 | ch <- 1 14 | ch <- 1 15 | println(len(ch)) 16 | println(cap(ch)) 17 | <-ch 18 | println(len(ch)) 19 | println(cap(ch)) 20 | } 21 | -------------------------------------------------------------------------------- /go/gomod/vendor/github.com/xwb1989/sqlparser/CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | This project is originally a fork of [https://github.com/youtube/vitess](https://github.com/youtube/vitess) 2 | Copyright Google Inc 3 | 4 | # Contributors 5 | Wenbin Xiao 2015 6 | Started this project and maintained it. 7 | 8 | Andrew Brampton 2017 9 | Merged in multiple upstream fixes/changes. -------------------------------------------------------------------------------- /go/http/handlerLeak.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func main() { 6 | for { 7 | go func() { 8 | req, _ := http.NewRequest("GET", "www.baidu.com", nil) 9 | client := http.DefaultClient 10 | client.Do(req) 11 | // should be resp, _ := client.Do(req 12 | // defer resp.Body.Close 13 | }() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /go/string/string_display_same_but_not_euqal.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = []byte{49, 0, 50} 7 | var b = []byte{49, 50, 0} 8 | fmt.Println(string(a), string(b)) 9 | fmt.Printf("%s\n", a) 10 | fmt.Printf("%s\n", b) 11 | fmt.Println(len(a), len(b)) 12 | fmt.Println(string(a) == string(b)) 13 | } 14 | -------------------------------------------------------------------------------- /go/types/aliasTypeConvert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | type aaa string 9 | 10 | func main() { 11 | var a aaa 12 | a = aaa("oh no") 13 | fmt.Println(a) 14 | var b string 15 | b = string(a) 16 | fmt.Println(b) 17 | fmt.Println(reflect.TypeOf(a)) 18 | fmt.Println(reflect.TypeOf(b)) 19 | } 20 | -------------------------------------------------------------------------------- /rust/future-impl/executor/src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod executor; 2 | 3 | fn main() { 4 | let (executor, spawner) = executor::new_executor_and_spawner(); 5 | 6 | spawner.spawn(async { 7 | println!("hello in async 1"); 8 | println!("world in async 2"); 9 | }); 10 | 11 | drop(spawner); 12 | executor.run(); 13 | } 14 | -------------------------------------------------------------------------------- /c/encapsulation/point.c: -------------------------------------------------------------------------------- 1 | #include "point.h" 2 | #include 3 | 4 | // .c 中定义的结构体,在 .h 中无法访问,且对外部不可见 5 | struct Point { 6 | double x; 7 | double y; 8 | }; 9 | 10 | struct Point * makePoint(double x, double y) { 11 | struct Point * p = malloc(sizeof(struct Point)); 12 | p->x = x; 13 | p->y = y; 14 | return p; 15 | } 16 | -------------------------------------------------------------------------------- /go/asm/what_is_struct_in_asm/t.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | TEXT ·readStruct(SB), NOSPLIT, $0-64 4 | MOVQ arg0+0(FP), AX 5 | MOVQ AX, ret0+32(FP) 6 | MOVQ arg1+8(FP), AX 7 | MOVQ AX, ret1+40(FP) 8 | MOVQ arg2+16(FP), AX 9 | MOVQ AX, ret2+48(FP) 10 | MOVQ arg3+24(FP), AX 11 | MOVQ AX, ret3+56(FP) 12 | RET 13 | -------------------------------------------------------------------------------- /go/file/read_all.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "strings" 7 | ) 8 | 9 | func main() { 10 | contentBytes, err := ioutil.ReadFile("./list.txt") 11 | if err != nil { 12 | println(err) 13 | return 14 | } 15 | lines := strings.Split(string(contentBytes), "\n") 16 | for _, l := range lines { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /go/gopsutil/go.mod: -------------------------------------------------------------------------------- 1 | module t 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect 7 | github.com/go-ole/go-ole v1.2.4 // indirect 8 | github.com/shirou/gopsutil v2.20.5+incompatible 9 | github.com/stretchr/testify v1.6.1 // indirect 10 | golang.org/x/sys v0.1.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /go/grpc/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package helloworld; 4 | // 服务端定义 5 | service Greeter { 6 | // 服务端返馈信息方法 7 | rpc SayHello (HelloRequest) returns (HelloReply) {} 8 | } 9 | 10 | // 包含用户名的请求信息 11 | message HelloRequest { 12 | string name = 1; 13 | } 14 | 15 | // 服务端响应信息 16 | message HelloReply { 17 | string message = 1; 18 | } 19 | -------------------------------------------------------------------------------- /go/hex/decode.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | res, err := hex.DecodeString("ff") 10 | fmt.Println(res, err) 11 | fmt.Println(string(res)) 12 | 13 | ch := 'a' 14 | fmt.Println(int(ch)) 15 | bytes := []byte{123, 123, 11, 23, 0, 23, 12} 16 | fmt.Println(string(bytes)) 17 | } 18 | -------------------------------------------------------------------------------- /go/pprof/producer_consumer_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | _ "net/http/pprof" 5 | "testing" 6 | ) 7 | 8 | func Test_main(t *testing.T) { 9 | tests := []struct { 10 | name string 11 | }{ 12 | // TODO: Add test cases. 13 | } 14 | for range tests { 15 | t.Run(tt.name, func(t *testing.T) { 16 | main() 17 | }) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /rust/traits/src/main.rs: -------------------------------------------------------------------------------- 1 | trait P { 2 | fn println(&self, x: i32); 3 | } 4 | 5 | impl P for i32 { 6 | fn println(&self, x: i32) { 7 | println!("{}", x); 8 | } 9 | } 10 | 11 | fn getP() -> impl P { 12 | return 1; 13 | } 14 | 15 | fn main() { 16 | let mut x = 1; 17 | let mut y = getP(); 18 | y.println(10); 19 | } 20 | -------------------------------------------------------------------------------- /go/closure/closure.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x = func() func() int { 5 | var idx = 0 6 | return func() int { 7 | idx++ 8 | return idx 9 | } 10 | } 11 | var z = x() 12 | println(z()) 13 | println(z()) 14 | println(z()) 15 | y := x() 16 | println(y()) 17 | println(y()) 18 | println(y()) 19 | println(y()) 20 | } 21 | -------------------------------------------------------------------------------- /go/closure/closure2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x = func() func() int { 5 | var idx = 0 6 | return func() int { 7 | idx++ 8 | return idx 9 | } 10 | }() 11 | var z = x 12 | println(z()) 13 | println(z()) 14 | println(z()) 15 | y := x 16 | println(y()) 17 | println(y()) 18 | println(y()) 19 | println(y()) 20 | } 21 | -------------------------------------------------------------------------------- /python/osArgs.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import sys 3 | 4 | def main(): 5 | if len(sys.argv[1:]) == 0: 6 | print "Param number error\n Pleaserun script likt python xxx.py 20150432" 7 | sys.exit() 8 | 9 | dt = datetime.datetime.strptime(sys.argv[1], "%Y%m%d") 10 | print dt 11 | 12 | if __name__ == "__main__": 13 | main() 14 | -------------------------------------------------------------------------------- /rust/net2_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "net2_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | net2 = "0.2.33" 11 | tokio = {version = "0.2", features = ["full"]} 12 | -------------------------------------------------------------------------------- /rust/pest_test/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rocket_complete_project" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | rocket = "0.4.2" 11 | toml = "0.5.3" 12 | 13 | -------------------------------------------------------------------------------- /scala/lambda/returning_function.scala: -------------------------------------------------------------------------------- 1 | def addWithoutSyntaxSugar(x: Int): Function1[Int, Int] = { 2 | new Function1[Int, Int]() { 3 | def apply(y: Int): Int = x + y 4 | } 5 | } 6 | 7 | addWithoutSyntaxSugar(1).isInstanceOf[Function1[Int, Int]] 8 | 9 | def fiveAdder: Function1[Int, Int] = addWithoutSyntaxSugar(5) 10 | 11 | fiveAdder(5) 12 | -------------------------------------------------------------------------------- /shell/download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | servers=("" "" "" "") 4 | yesterday=`date +%Y%m%d --date="-1 day"` 5 | today=`date '+%Y%m%d'` 6 | day=$1 7 | if [ ! $day ]; 8 | then 9 | day=$yesterday 10 | fi 11 | path="/home/logs/x.log" 12 | 13 | 14 | for var in ${servers[*]} 15 | do 16 | 17 | scp -l 30000 $var:$path$day ./$var.$day 18 | 19 | done 20 | 21 | -------------------------------------------------------------------------------- /uml/advanced_activity.txt: -------------------------------------------------------------------------------- 1 | @startuml 2 | scale 512*1024 3 | 4 | |Gateway| 5 | start 6 | repeat 7 | :record data; 8 | :wating; 9 | repeat while (id < 10) 10 | 11 | |#778899|Copper| 12 | :enter the Endurance; 13 | while (not hungry) 14 | :play; 15 | :kick football; 16 | endwhile 17 | 18 | end 19 | 20 | @enduml 21 | -------------------------------------------------------------------------------- /go/algorithm/leetcode/387.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | firstUniqChar("abcdabc") 5 | } 6 | 7 | func firstUniqChar(s string) int { 8 | m := make(map[byte]int) 9 | for i := 0; i < len(s); i++ { 10 | m[s[i]]++ 11 | } 12 | 13 | for i := 0; i < len(s); i++ { 14 | if m[s[i]] == 1 { 15 | return i 16 | } 17 | } 18 | return -1 19 | } 20 | -------------------------------------------------------------------------------- /go/dataStructs/maptest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var m map[string]int 7 | //下面这句是必须的 8 | m = make(map[string]int) 9 | m["one"] = 1 10 | m["two"] = 2 11 | fmt.Printf("%+v", m) 12 | delete(m, "x") 13 | delete(m, "one") 14 | 15 | ma := make(map[string]int) 16 | ma["x"] = 1 17 | fmt.Printf("%+v", ma) 18 | } 19 | -------------------------------------------------------------------------------- /go/map/range.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | m := map[string]string{ 10 | "a": "1", 11 | "b": "2", 12 | "c": "3", 13 | "d": "4", 14 | } 15 | 16 | // 会把所有的 k, v 输出出来 17 | for k, v := range m { 18 | fmt.Println(k, v) 19 | m = nil 20 | } 21 | 22 | time.Sleep(time.Hour) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /go/memmap/memmap.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "sync/atomic" 6 | "unsafe" 7 | 8 | "github.com/bradleyjkemp/memviz" 9 | "github.com/sitano/gsysint" 10 | ) 11 | 12 | func main() { 13 | var gp unsafe.Pointer 14 | 15 | atomic.StorePointer(&gp, gsysint.GetG()) 16 | 17 | gg := (*gsysint.G)(gp) 18 | memviz.Map(os.Stdout, gg) 19 | } 20 | -------------------------------------------------------------------------------- /go/os/ostest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os/exec" 4 | import "reflect" 5 | 6 | import "fmt" 7 | import "bytes" 8 | 9 | func main() { 10 | dateCmd := exec.Command("date") 11 | dateOut, _ := dateCmd.Output() 12 | println(dateOut) 13 | println(string(dateOut)) 14 | buf1 := bytes.NewBufferString("fuck") 15 | fmt.Println(reflect.TypeOf(buf1)) 16 | } 17 | -------------------------------------------------------------------------------- /go/runtime/runtimeCaller.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | ) 7 | 8 | func test() { 9 | if pc, _, _, ok := runtime.Caller(0); ok { 10 | f := runtime.FuncForPC(pc) 11 | fmt.Println(f.Name()) 12 | if f.Name() != "main.test" { 13 | println("inline") 14 | } 15 | } 16 | } 17 | 18 | func main() { 19 | test() 20 | } 21 | -------------------------------------------------------------------------------- /go/sync/structLock.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | type Person struct { 6 | age int 7 | lock sync.Mutex 8 | } 9 | 10 | // 考虑一下这里为什么不能用p Person? 11 | func (p *Person) changeAge(newAge int) { 12 | p.lock.Lock() 13 | p.age = newAge 14 | p.lock.Unlock() 15 | } 16 | 17 | func main() { 18 | p := new(Person) 19 | p.changeAge(5) 20 | } 21 | -------------------------------------------------------------------------------- /python/checkAll.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import requests 3 | import json 4 | 5 | if __name__ == "__main__": 6 | data = {"sid" : "flash", "checkDate" : "2017-05-09", "cityId" : "0"} 7 | headers = {"x-header-id" : "111"} 8 | # post a form 9 | r = requests.post("www.baidu.com", data=data, headers = headers) 10 | print r.text 11 | 12 | -------------------------------------------------------------------------------- /rust/rustyline_test/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /python/guolele/guolele/pipelines.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Define your item pipelines here 4 | # 5 | # Don't forget to add your pipeline to the ITEM_PIPELINES setting 6 | # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html 7 | 8 | 9 | class GuolelePipeline(object): 10 | def process_item(self, item, spider): 11 | return item 12 | -------------------------------------------------------------------------------- /rust/asyncstd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "asyncstd" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | async-std = { version = "1.4.0" , features = ["unstable"] } 11 | futures = "0.3.1" 12 | -------------------------------------------------------------------------------- /rust/rocket_complete_project/src/controller/user.rs: -------------------------------------------------------------------------------- 1 | #![feature(proc_macro_hygiene)] 2 | #![feature(decl_macro)] 3 | 4 | #[get("/info/")] 5 | pub fn get_user_info(id: i64) -> String { 6 | "hello here is Xargin".to_string() 7 | } 8 | 9 | #[get("/info/")] 10 | pub fn get_user_info(id: i64) -> String { 11 | "hello here is Xargin".to_string() 12 | } 13 | -------------------------------------------------------------------------------- /rust/tokio_load_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tokio_runtime" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | tokio = { version = "0.2", features = ["full"]} 11 | futures = "0.3" 12 | -------------------------------------------------------------------------------- /scala/lambda/closure2.scala: -------------------------------------------------------------------------------- 1 | //We can take that closure and throw it into a method and it will still hold the environment: 2 | def summation(x: Int, y: Int ⇒ Int) = y(x) 3 | 4 | var incrementer = 3 5 | def closure = (x: Int) ⇒ x + incrementer 6 | 7 | val result = summation(10, closure) 8 | 9 | incrementer = 4 10 | val result2 = summation(10, closure) 11 | 12 | -------------------------------------------------------------------------------- /go/error/err_print.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type P struct { 6 | Age int 7 | Name int 8 | } 9 | 10 | func (p P) Error() string { 11 | return "fuck" 12 | } 13 | 14 | func main() { 15 | var err P 16 | fmt.Printf("%#v\n", err) // main.P{Age:0, Name:0} 17 | fmt.Printf("%v\n", err) // fuck 18 | fmt.Printf("%s\n", err) // fuck 19 | } 20 | 21 | -------------------------------------------------------------------------------- /rust/channel/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "channel" 3 | version = "0.1.0" 4 | authors = ["xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | tokio = "0.2.0-alpha.6" 11 | futures = { version = "0.3", features = ["async-await"] } 12 | -------------------------------------------------------------------------------- /rust/future-impl/executor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "executor" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | #futures = { version = "0.3.1", features = ["full"] } 11 | futures = "0.3.1" 12 | -------------------------------------------------------------------------------- /rust/iter/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut v = vec![1,2,3]; 3 | v.iter().for_each(|e| { 4 | println!("{}", e); 5 | }); 6 | 7 | (0..10).for_each(|e| { 8 | println!("{}", e); 9 | }); 10 | 11 | println!("{:?}", v.iter().map(|e| e + 1).collect::>()); 12 | v.iter_mut().for_each(|e| {*e = 1}); 13 | dbg!(v); 14 | } 15 | -------------------------------------------------------------------------------- /rust/mio_test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mio_test" 3 | version = "0.1.0" 4 | authors = ["Xargin "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | mio = { git = "https://github.com/tokio-rs/mio" , features = ["os-poll", "tcp"] } 11 | 12 | -------------------------------------------------------------------------------- /uml/ufs.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | 3 | (*) --> "创建工单" 4 | --> "编辑工单" 5 | --> "提交工单" 6 | --> “数据校验” 7 | if "校验通过" then 8 | --> [Yes] "工单审核" 9 | if "审核通过" then 10 | --> [Yes] "创建特征" 11 | --> "创建特征相关数据" 12 | --> "特征发布" 13 | --> (*) 14 | else 15 | --> [No] "编辑工单" 16 | endif 17 | else 18 | --> [No] "编辑工单" 19 | endif 20 | @enduml -------------------------------------------------------------------------------- /go/algorithm/leetcode/27.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(removeElement([]int{3, 2, 2, 3}, 3)) 7 | } 8 | 9 | func removeElement(nums []int, val int) int { 10 | var idx = 0 11 | for i := 0; i < len(nums); i++ { 12 | if nums[i] != val { 13 | nums[idx] = nums[i] 14 | idx++ 15 | } 16 | } 17 | 18 | return idx 19 | } 20 | -------------------------------------------------------------------------------- /go/json/djsontest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //这个库似乎只支持未知json格式的解析 4 | //不支持decode到struct 5 | import ( 6 | "fmt" 7 | 8 | "github.com/a8m/djson" 9 | ) 10 | 11 | type Person struct { 12 | name string 13 | age int 14 | } 15 | 16 | func main() { 17 | //var p Person 18 | x, err := djson.Decode([]byte(`123`)) 19 | fmt.Println(x, err) 20 | fmt.Printf("%q", x) 21 | } 22 | -------------------------------------------------------------------------------- /go/os/sysinfo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/zcalusic/sysinfo" 9 | ) 10 | 11 | func main() { 12 | var si sysinfo.SysInfo 13 | 14 | si.GetSysInfo() 15 | 16 | data, err := json.MarshalIndent(&si, "", " ") 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | 21 | fmt.Println(string(data)) 22 | } 23 | -------------------------------------------------------------------------------- /go/panic/panic_recover_and_return.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func test(output *int) (output2 int) { 6 | defer func() { 7 | if err := recover(); err != nil { 8 | *output = 444 9 | output2 = 23323 10 | } 11 | }() 12 | *output = 2 13 | panic(1) 14 | } 15 | 16 | func main() { 17 | x := 0 18 | y := test(&x) 19 | fmt.Println(x, y) 20 | } 21 | -------------------------------------------------------------------------------- /gomod/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | import "fmt" 3 | 4 | import registry "github.com/apache/dubbo-go/registry" 5 | import zk "github.com/apache/dubbo-go/registry/zookeeper" 6 | import xds "mosn.io/mosn/pkg/xds" 7 | 8 | func main() { 9 | var r registry.Registry 10 | fmt.Println(r) 11 | var z zk.Option 12 | fmt.Println(z) 13 | var x xds.Client 14 | fmt.Println(x) 15 | } 16 | -------------------------------------------------------------------------------- /net/same_port/same_port_outgoing_connections.py: -------------------------------------------------------------------------------- 1 | import socket 2 | s = socket.socket() 3 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) 4 | s2 = socket.socket() 5 | s2.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) 6 | s.bind(('0.0.0.0', 12345)) 7 | s2.bind(('0.0.0.0', 12345)) 8 | s.connect(('220.181.57.217', 80)) 9 | s2.connect(('54.222.60.252', 80)) 10 | -------------------------------------------------------------------------------- /shell/awk/fix.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | counter=0 3 | slCounter=100 4 | while read line 5 | do 6 | mysql -h127.0.0.1 -uroot -p123456 -e "$line" 7 | echo $line 8 | counter=$(($counter+1)) 9 | echo $counter 10 | 11 | if [ $counter -eq $slCounter ] 12 | then 13 | sleep 1 14 | counter=0 15 | echo "oh yes" 16 | fi 17 | done < res.txt 18 | 19 | -------------------------------------------------------------------------------- /go/asm/hardware_or_virtual/where.s: -------------------------------------------------------------------------------- 1 | #include "textflag.h" 2 | 3 | TEXT ·where(SB), NOSPLIT, $8-32 4 | // MOVQ FP, AX 5 | MOVQ -8(SP), AX // this is hardwhere SP 6 | MOVQ x-8(SP), BX // this is the virtual register SP 7 | MOVQ 8(SP), DX 8 | MOVQ x+8(SP), CX 9 | MOVQ AX, ret+0(FP) 10 | MOVQ BX, ret+8(FP) 11 | MOVQ DX, ret+16(FP) 12 | MOVQ CX, ret+24(FP) 13 | RET 14 | -------------------------------------------------------------------------------- /go/net/iptest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net" 4 | import "fmt" 5 | 6 | func main() { 7 | var host = "www.google.com" 8 | var ip = net.ParseIP(host) 9 | var ip2, _ = net.ResolveIPAddr("ip", host) 10 | fmt.Println(ip) 11 | fmt.Println(ip2.Zone) 12 | fmt.Println(ip2.IP) 13 | var ip3, _ = net.ResolveIPAddr("ip", "127.0.0.1") 14 | fmt.Println(ip3.IP) 15 | } 16 | -------------------------------------------------------------------------------- /go_web/chi_with_doc.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/pressly/chi" 7 | "github.com/pressly/chi/docgen" 8 | "io" 9 | ) 10 | 11 | func main() { 12 | r := chi.NewRouter() 13 | r.Get("/", func(w http.ResponseWriter, req *http.Request) { 14 | io.WriteString(w,docgen.JSONRoutesDoc(r)) 15 | }) 16 | http.ListenAndServe(":3000", r) 17 | } 18 | -------------------------------------------------------------------------------- /php/copydata.php: -------------------------------------------------------------------------------- 1 | query("insert into g_service_worksheet (select * from service_worksheet limit {$offset}, 1000)"); 9 | $offset += 100; 10 | print_r($res); 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /go/pkgerror/demo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/pkg/errors" 7 | ) 8 | 9 | func main() { 10 | var err = errors.New("fuck") 11 | err = errors.Wrap(err, "this **** happened here") 12 | fmt.Printf("%+v\n", err) 13 | err = errors.WithStack(err) 14 | fmt.Printf("%+v\n", err) 15 | 16 | x := fmt.Sprintf("%+v", err) 17 | fmt.Println(x) 18 | } 19 | -------------------------------------------------------------------------------- /php/array_column_test.php: -------------------------------------------------------------------------------- 1 | 'a', 5 | 'quantity' => 2 6 | ], 7 | [ 8 | 'id' => 'b', 9 | 'quantity' => 3 10 | ], 11 | [ 12 | 'id' => 'c', 13 | 'quantity' => 5 14 | ] 15 | ]; 16 | $x = array_column($arr, 'id', 'quantity'); 17 | print_r($x); 18 | 19 | -------------------------------------------------------------------------------- /c++/parent.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Father{ 5 | public: 6 | virtual void test(){} 7 | void tt() { 8 | test(); 9 | } 10 | }; 11 | 12 | class Son : public Father{ 13 | public: 14 | void test() { cout << "son test" << endl;} 15 | 16 | }; 17 | 18 | int main() { 19 | Father * a = new Son(); 20 | a->tt(); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /go/algorithm/leetcode/561.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(arrayPairSum([]int{1, 4, 3, 2})) 10 | } 11 | 12 | func arrayPairSum(nums []int) int { 13 | sort.Ints(nums) 14 | l := len(nums) 15 | sum := 0 16 | for i := 0; i < l; i++ { 17 | if i%2 == 0 { 18 | sum += nums[i] 19 | } 20 | } 21 | return sum 22 | } 23 | -------------------------------------------------------------------------------- /go/os/test/www_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | "testing" 8 | ) 9 | 10 | func TestSymbol(t *testing.T) { 11 | cmd := exec.Command("nm", os.Args[0]) 12 | contentBytes, err := cmd.Output() 13 | if err != nil { 14 | println(err) 15 | t.Fail() 16 | } 17 | 18 | fmt.Println(string(contentBytes)) 19 | fmt.Println(os.Args[0]) 20 | } 21 | -------------------------------------------------------------------------------- /go/panic/before_1-9-2-bug.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "reflect" 5 | "runtime" 6 | ) 7 | 8 | func main() { 9 | fv := reflect.ValueOf(func(int) struct{} { return struct{}{} }) 10 | args := []reflect.Value{reflect.ValueOf(0)} 11 | 12 | go func() { 13 | runtime.GC() 14 | }() 15 | 16 | for { 17 | fv.Call(args) 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /go/reflect/time_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "time" 7 | ) 8 | 9 | func main() { 10 | var a time.Time 11 | var struc struct{} 12 | fmt.Println(reflect.TypeOf(a).Kind()) 13 | fmt.Println(reflect.TypeOf(a)) 14 | fmt.Println(reflect.TypeOf(a) == reflect.TypeOf(time.Time{})) 15 | fmt.Println(reflect.TypeOf(a) == reflect.TypeOf(struc)) 16 | } 17 | -------------------------------------------------------------------------------- /go/string/alloc_or_not_alloc/a_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func BenchmarkA(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | TestA() 8 | } 9 | } 10 | 11 | func BenchmarkB(b *testing.B) { 12 | for i := 0; i < b.N; i++ { 13 | TestB() 14 | } 15 | } 16 | 17 | func BenchmarkC(b *testing.B) { 18 | for i := 0; i < b.N; i++ { 19 | TestC() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /go/unicode/encod.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a = "\346\265\213\350\257\225" 5 | var b = []rune(a) 6 | println(a) 7 | println(len(a), len(b)) 8 | for i := 0; i < len(b); i++ { 9 | println(string(b[i])) 10 | } 11 | 12 | var c = []rune("呵呵") 13 | for i := 0; i < len(c); i++ { 14 | println(c[i]) 15 | } 16 | 17 | var d = "\u77e5" 18 | println(d) 19 | } 20 | -------------------------------------------------------------------------------- /uml/activity_icons.txt: -------------------------------------------------------------------------------- 1 | @startuml 2 | scale 2 3 | :Ready; 4 | :next(o)| 5 | :Receiving; 6 | split 7 | :nak(i)< 8 | :ack(o)> 9 | split again 10 | :ack(i)< 11 | :next(o) 12 | on several line| 13 | :i := i + 1] 14 | :ack(o)> 15 | split again 16 | :err(i)< 17 | :nak(o)> 18 | split again 19 | :foo/ 20 | split again 21 | :i > 5} 22 | stop 23 | end split 24 | :finish; 25 | @enduml 26 | -------------------------------------------------------------------------------- /c++/signal/sigaction2.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void handle_sigint(int sig) 5 | { 6 | printf("Caught signal %d\n", sig); 7 | } 8 | 9 | int main() 10 | { 11 | struct sigaction act; 12 | act.sa_handler = handle_sigint; 13 | sigemptyset(&act.sa_mask); 14 | act.sa_flags = 0; 15 | sigaction(SIGINT, &act, NULL); 16 | while (1) ; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /go/map/structmap.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | //map的key可以是string以外的值 6 | //所以也可以用来做指针和对应状态的记录 7 | //不过如果是和json相关的工作时,需要考虑到rfc的json定义里object的key只能是string 8 | //int类型做key的map会出错 9 | 10 | type Node struct { 11 | length int 12 | next *Node 13 | } 14 | 15 | func main() { 16 | var a = make(map[*Node]bool) 17 | n := Node{} 18 | a[&n] = true 19 | fmt.Println(a) 20 | } 21 | -------------------------------------------------------------------------------- /go/trace/trace.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "runtime/trace" 6 | ) 7 | 8 | func main() { 9 | trace.Start(os.Stderr) 10 | defer trace.Stop() 11 | // create new channel of type int 12 | ch := make(chan int) 13 | 14 | // start new anonymous goroutine 15 | go func() { 16 | // send 42 to channel 17 | ch <- 42 18 | }() 19 | // read from channel 20 | <-ch 21 | } 22 | -------------------------------------------------------------------------------- /js/generator.js: -------------------------------------------------------------------------------- 1 | //这个例子的yield和python比较类似 2 | var Fiber = require('fibers'); 3 | 4 | var inc = Fiber(function(start){ 5 | var total = start; 6 | while(true) { 7 | total += start; 8 | Fiber.yield(total); 9 | } 10 | }) 11 | 12 | for(var ii = 0; ii<=10; ii++) { 13 | console.log(inc.run(2)); 14 | } 15 | 16 | for(var ii = 0; ii<=10; ii++) { 17 | console.log(inc.run(1)) 18 | } 19 | -------------------------------------------------------------------------------- /rust/combine/demo/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate combine; 2 | use combine::char::char; 3 | use combine::{Parser, many1}; 4 | 5 | fn main() { 6 | let r = many1::(char('a').or(char('b'))).parse("aaaabbbbabababab"); 7 | match r { 8 | Ok((value, remaining)) => println!("value: {} remaining: {}", value,remaining), 9 | Err(err) => println!("{}", err) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /antlr_practise/grammar_import/LibExpr.g4: -------------------------------------------------------------------------------- 1 | grammar LibExpr; 2 | import CommonLexerRules; // import 已经存在的语法规则 3 | /* 起始规则 */ 4 | prog : stat + ; // 程序由多个 statement 组成 5 | 6 | stat : expr NEWLINE 7 | | ID '=' expr NEWLINE 8 | | NEWLINE 9 | ; 10 | 11 | expr : expr ('*' | '/') expr 12 | | expr ('+' | '-') expr 13 | | INT 14 | | ID 15 | | '(' expr ')' 16 | ; 17 | -------------------------------------------------------------------------------- /go/asm/goid/go_tls.h: -------------------------------------------------------------------------------- 1 | #ifdef GOARCH_arm 2 | #define LR R14 3 | #endif 4 | 5 | #ifdef GOARCH_amd64 6 | #define get_tls(r) MOVQ TLS, r 7 | #define g(r) 0(r)(TLS*1) 8 | #endif 9 | 10 | #ifdef GOARCH_amd64p32 11 | #define get_tls(r) MOVL TLS, r 12 | #define g(r) 0(r)(TLS*1) 13 | #endif 14 | 15 | #ifdef GOARCH_386 16 | #define get_tls(r) MOVL TLS, r 17 | #define g(r) 0(r)(TLS*1) 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /go/epoll/easygo/go.sum: -------------------------------------------------------------------------------- 1 | github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f h1:4+gHs0jJFJ06bfN8PshnM6cHcxGjRUVRLo5jndDiKRQ= 2 | github.com/mailru/easygo v0.0.0-20190618140210-3c14a0dc985f/go.mod h1:tHCZHV8b2A90ObojrEAzY0Lb03gxUxjDHr5IJyAh4ew= 3 | golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= 4 | golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 5 | -------------------------------------------------------------------------------- /go/receiver/normal.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct { 6 | name string 7 | age int 8 | } 9 | 10 | func (t *T) getName() string { 11 | return t.name 12 | } 13 | 14 | func (t T) getAge() int { 15 | return t.age 16 | } 17 | 18 | func main() { 19 | var t T 20 | t.age = 99 21 | t.name = "seth" 22 | fmt.Println(t.getName()) 23 | fmt.Println(t.getAge()) 24 | } 25 | -------------------------------------------------------------------------------- /js/sleep.js: -------------------------------------------------------------------------------- 1 | var Fiber = require('fibers'); 2 | 3 | function sleep(ms) { 4 | var fiber = Fiber.current; 5 | setTimeout(function(){ 6 | fiber.run(); 7 | }, ms); 8 | Fiber.yield(); 9 | } 10 | 11 | Fiber(function(){ 12 | console.log('wait...' + new Date()); 13 | sleep(1000); 14 | console.log('ok...' + new Date()); 15 | }).run(); 16 | 17 | console.log('back in main'); 18 | 19 | 20 | -------------------------------------------------------------------------------- /rust/box_arr/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | struct Solution { 3 | x : Box<[i32]>, 4 | y : [i32;3], 5 | //z : [i32], -> println!("{:?}", s); 6 | // ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time 7 | } 8 | 9 | fn main() { 10 | let s = Solution { 11 | x : Box::new([1,2]), 12 | y : [3,2,1], 13 | }; 14 | println!("{:?}", s); 15 | } 16 | -------------------------------------------------------------------------------- /c/devrandom.c: -------------------------------------------------------------------------------- 1 | #include 2 | void main() { 3 | int dev_random = open("/dev/urandom", O_RDONLY); 4 | printf("%d", dev_random); 5 | int NUMBYTES = 8; 6 | unsigned char rand_data[NUMBYTES]; 7 | int r = read(dev_random, &rand_data, NUMBYTES); 8 | printf("%d\n", r); 9 | for(int i=0;i"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | tokio = { version = "0.2", features = ["full"] } 11 | futures = { version = "0.3", features = ["async-await"] } 12 | -------------------------------------------------------------------------------- /go/dependency-experiment/func_based/test_funcs.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testGetUserID(userID int) int64 { 4 | return 1 5 | } 6 | 7 | func testPushMSG(userID int64) error { 8 | println("push to user(online)", userID) 9 | return nil 10 | } 11 | 12 | func testGetLimited(driverID int64) bool { 13 | return false 14 | } 15 | 16 | func testGetWhiteList(date string) map[int]int64 { 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /go/dependency-experiment/nested_struct_based/user_service.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type userService struct { 4 | UserID func(phone string) int64 5 | } 6 | 7 | type onlineUserService struct{} 8 | 9 | func (ous onlineUserService) UserID(phone string) int64 { 10 | return 1 11 | } 12 | 13 | type testUserService struct{} 14 | 15 | func (tus testUserService) UserID(phone string) int64 { 16 | return 2 17 | } 18 | -------------------------------------------------------------------------------- /go/math/rand.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "math/rand" 4 | import "time" 5 | 6 | func main() { 7 | src := rand.NewSource(time.Now().UnixNano()) 8 | random := rand.New(src) 9 | for i := 0; i < 100; i++ { 10 | // 伪随机 11 | x := rand.Intn(100) 12 | println("fake", x) 13 | 14 | // 真随机 15 | y := random.Intn(100) 16 | println("true", y) 17 | } 18 | 19 | // 如果为 0,会 panic 20 | rand.Intn(0) 21 | } 22 | -------------------------------------------------------------------------------- /go/net/sockettest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | ) 7 | 8 | func main() { 9 | //exit := make(chan bool) 10 | ip := net.ParseIP("127.0.0.1") 11 | port := 81 12 | tcp_addr := net.TCPAddr{ip, port, ""} 13 | udp_addr := net.UDPAddr{ip, port, ""} 14 | fmt.Println(tcp_addr) 15 | fmt.Println(udp_addr) 16 | fmt.Println(tcp_addr.Network()) 17 | fmt.Println(udp_addr.Network()) 18 | } 19 | -------------------------------------------------------------------------------- /php/multisort.php: -------------------------------------------------------------------------------- 1 | 'xlex', 'age' => 44 5 | ], 6 | [ 7 | 'name' => 'aaa', 'age' => 55 8 | ] 9 | ]; 10 | 11 | $names = array_column($arr, 'name'); 12 | $ages = array_column($arr,'age'); 13 | array_multisort($ages, SORT_ASC, $arr); 14 | print_r($arr); 15 | array_multisort($names, SORT_ASC, $arr); 16 | print_r($arr); 17 | -------------------------------------------------------------------------------- /scala/tuple/tuple.scala: -------------------------------------------------------------------------------- 1 | val t = (1, "hello", Console) 2 | 3 | // is short for 4 | 5 | val t3 = new Tuple3(1, "hello", Console) 6 | 7 | val tuple = ("apple", "dog") 8 | val fruit = tuple._1 9 | val animal = tuple._2 10 | 11 | //val tuple5 = ("a", 1, 2.2, new Date(), "five") 12 | 13 | val student = ("Sean Rogers", 21, 3.5) 14 | val (name, age, gpa) = student 15 | 16 | val tuplex = ("apple", 3).swap 17 | 18 | -------------------------------------------------------------------------------- /go/assert/assert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "encoding/json" 4 | import "fmt" 5 | 6 | func main() { 7 | a := `{"a" : {"b" : 1}}` 8 | var b map[string](map[string]interface{}) 9 | json.Unmarshal([]byte(a), &b) 10 | // var bb interface{} 11 | //json.Unmarshal([]byte(a), &bb) 12 | fmt.Println(b) 13 | fmt.Println(b["a"]["b"]) 14 | // var c = bb.(map[string](map[string]interface{})) 15 | // 这样做断言是不行的 16 | } 17 | -------------------------------------------------------------------------------- /go/broadcast/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "broadcast" 5 | "fmt" 6 | ) 7 | 8 | var b = broadcast.NewBroadcaster() 9 | 10 | func main() { 11 | //b.Write("abc") 12 | r := b.Listen() 13 | b.Write("a") 14 | b.Write("b") 15 | b.Write("c") 16 | b.Write("d") 17 | fmt.Println(r.Read()) 18 | fmt.Println(r.Read()) 19 | fmt.Println(r.Read()) 20 | fmt.Println(r.Read()) 21 | fmt.Println(r) 22 | } 23 | -------------------------------------------------------------------------------- /go/dataStructs/typeEqualTest/typetest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "./a" 8 | ) 9 | 10 | type A int 11 | 12 | func main() { 13 | var d A 14 | var f a.A 15 | fmt.Println("reflect.TypeOf d", reflect.TypeOf(d)) 16 | fmt.Println("reflect.TypeOf f", reflect.TypeOf(f)) 17 | fmt.Println("reflect.TypeOf(d) == reflect.TypeOf(f) ?", reflect.TypeOf(d) == reflect.TypeOf(f)) 18 | } 19 | -------------------------------------------------------------------------------- /go/dirty_part/nil_receiver.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "log" 4 | import "reflect" 5 | 6 | type A struct { 7 | value string 8 | } 9 | 10 | func (a *A) Test() string { 11 | log.Print("call Test") 12 | log.Print(reflect.TypeOf(a)) 13 | log.Print(reflect.ValueOf(a)) 14 | return a.value 15 | } 16 | 17 | func getA() *A { 18 | return nil 19 | } 20 | 21 | func main() { 22 | a := getA() 23 | a.Test() 24 | } 25 | -------------------------------------------------------------------------------- /go/dlv.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func dostuff(wg *sync.WaitGroup, i int) { 9 | fmt.Printf("goroutine id %d\n", i) 10 | fmt.Printf("goroutine id %d\n", i) 11 | wg.Done() 12 | } 13 | 14 | func main() { 15 | var wg sync.WaitGroup 16 | workers := 10 17 | 18 | wg.Add(workers) 19 | for i := 0; i < workers; i++ { 20 | go dostuff(&wg, i) 21 | } 22 | wg.Wait() 23 | } 24 | -------------------------------------------------------------------------------- /go/params/demo.go: -------------------------------------------------------------------------------- 1 | // Package main provides tes 2 | package main 3 | 4 | import "fmt" 5 | 6 | type A struct { 7 | a int 8 | } 9 | 10 | func main() { 11 | var m = []A{{1}, {2}} 12 | test(m...) 13 | } 14 | 15 | func test(s ...A) { 16 | //func test(s ...interface{}) { 17 | //cannot use m (type []A) as type []interface {} in argument to test 18 | for k, v := range s { 19 | fmt.Println(k, v) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /rust/nom/basic/readme.md: -------------------------------------------------------------------------------- 1 | ## Warn 2 | 3 | 如果不用 nom 这个内置的 CompleteStr 类型,会导致各种 InComplete,比如 `a=1` parse 就会 InComplete。而必须在 `a=1` 后面加一个空格 `a=1 `。 4 | 5 | 还是挺别扭的。 6 | 7 | https://github.com/Geal/nom/issues/839 8 | 9 | https://github.com/Geal/nom/issues/657 10 | 11 | 看起来是因为 nom 本身可以支持流的场景,所以无法判断用户的输入是不是真的结束了,所以如果用户知道这段输入确实结束了的话,需要显式地告诉 nom 这里已经是完整的 string 了:CompleteStr。 12 | 13 | 这种 parsec 的 parser 似乎也是不能处理左递归的。 14 | -------------------------------------------------------------------------------- /go/dependency-experiment/nested_struct_based/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type dependencyList struct { 4 | orderServiceInstance orderService 5 | pushServiceInstance pushService 6 | } 7 | 8 | // dependency list manager 9 | var exactDependency dependencyList 10 | 11 | var env = "test" 12 | 13 | func main() { 14 | switch env { 15 | case "prod": 16 | normalInit() 17 | case "test": 18 | testInit() 19 | } 20 | } 21 | --------------------------------------------------------------------------------