Skip to content

Instantly share code, notes, and snippets.

View kenkangxgwe's full-sized avatar
🗂️
分类爱好者

康小广 kenkangxgwe

🗂️
分类爱好者
  • Google LLC
  • Mountain View, CA
View GitHub Profile
@kenkangxgwe
kenkangxgwe / client.js
Last active August 30, 2022 08:42
ZeroMQLink Server read message issue
const net = require('node:net');
const serverPort = 7570;
const host = "127.0.0.1";
function connectServer() {
const client = net.connect(serverPort, host);
client.on('error', (err) => {
setTimeoutInterval(connectServer, 1000);
});
return client;
==19487== Memcheck, a memory error detector
==19487== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19487== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info
==19487== Command: ./test_sub
==19487==
==19487== Invalid read of size 8
==19487== at 0x10D75E: boost::subgraph<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_color_t, int, boost::no_property>, boost::property<boost::edge_index_t, unsigned long, boost::property<boost::edge_weight_t, int, boost::no_property> >, boost::no_property, boost::listS> >::global_to_local(boost::detail::edge_desc_impl<boost::bidirectional_tag, unsigned long>) const (in /home/kenkangxgwe/graph/test_sub)
==19487== by 0x10DB13: void global_local_convertion_test<boost::subgraph<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_color_t, int, boost::no_property>, boost::property<boost::edge_index_t, unsigned long, boost::property<boost::
@kenkangxgwe
kenkangxgwe / WalkD.wl
Created February 8, 2017 12:54
Step-by-Step Differentiation by J.M. http://mathematica.stackexchange.com/a/152
Format[d[f_, x_], TraditionalForm] := DisplayForm[RowBox[{FractionBox["\[DifferentialD]",
RowBox[{"\[DifferentialD]", x}]], f}]];
SpecificRules = {d[x_, x_] :> 1, d[(f_)[x_], x_] :> D[f[x], x],
d[(a_)^(x_), x_] :> D[a^x, x] /; FreeQ[a, x]};
ConstantRule = d[c_, x_] :> 0 /; FreeQ[c, x];
LinearityRule = {d[f_ + g_, x_] :> d[f, x] + d[g, x],
d[c_ f_, x_] :> c d[f, x] /; FreeQ[c, x]};
@kenkangxgwe
kenkangxgwe / Multi-CurveDrawing.wl
Last active February 8, 2017 12:54
Drawing More than one curves on one figure and save them (includes their legends) to disk.
(* ::Package:: *)
ExportDir="ExportDir.pdf";
Figure=PlotFunc[Data,PlotRange->{}(*,PlotMarkers\[Rule]{}*),
PlotLegends->(Style[#,FontSize->18]&/@{"Curve A","Curve B"}),Frame->{True,True,False,False},FrameLabel->(Style[#,FontSize->18]&/@{"X axis","Y axis"})]
Export[ExportDir,Figure]
@kenkangxgwe
kenkangxgwe / LeastSquaresMethod.wl
Created February 5, 2017 02:54
Using Least Square Method for a X-Y 2D array.
(* ::Package:: *)
Targetdir1 = "%Yourdir%\\*.txt"
(*For the table having two demensions.*)
Data=Import[Targetdir1,"Table"];
Model = LinearModelFit[Data, x, x]
Show[ListPlot[Data, AxesOrigin -> {0, 0}, AxesLabel -> {"x", "y"}],
Plot[Normal[Model], {x, First[First[Data]], First[Last[Data]]}]]
Model["ParameterTable"]
@kenkangxgwe
kenkangxgwe / Interpolation.wl
Created February 5, 2017 02:52
Interpolation and its plot for a X-Y 2D array
(* ::Package:: *)
Targetdir1 = "%Yourdir%\\*.txt"
(*For the table having two demensions.*)
Data=Import[Targetdir1,"Table"];
Curve=Interpolation[Data,Method->"Spline"(*,Method\[Rule]"Hermite"*)];
Show[ListPlot[Data,AxesLabel->{"x","y"}],Plot[Curve[x],{x,First[First[Data]],First[Last[Data]]}]]