Skip to content

Instantly share code, notes, and snippets.

@michaelHL
michaelHL / randomwalkover.md
Last active June 6, 2017 08:00
100步随机游走过点10概率

100步随机游走过程中, 经过点10的概率精确值为:

求和式中的项为所谓的「首达概率」.

代码

randWalkOver1 <- function(n, start, stop, p = 0.5, stepf = 1, stepb = 1) {
    out <- 0
@michaelHL
michaelHL / 2017-06-06.md
Last active July 5, 2017 05:27
eclipse配置C/C++编译环境

eclipse配置C/C++编译环境

  1. 下载解压eclipse, 建议直接下载Eclipse IDE for C/C++ Developers, 免去插件安装
  2. 下载解压GCC编译工具链, 比如当前最新的7.1.0

@michaelHL
michaelHL / 2017-06-09-settings.jq
Last active June 9, 2017 03:17
vscodesettings
{
"workbench.iconTheme": "material-icon-theme",
"editor.rulers": [
80
],
"editor.fontSize": 19.6,
"editor.fontFamily": "Inconsolata, 'Microsoft Yahei Mono', Consolas, 'Courier New', monospace",
"editor.lineHeight": 24,
"editor.minimap.enabled": true,
"editor.cursorBlinking": "solid",
// C++ program to find difference of two large numbers.
#include<bits/stdc++.h>
using namespace std;
// Returns true if str1 is smaller than str2.
bool isSmaller(string str1, string str2)
{
// Calculate lengths of both string
int n1 = str1.length(), n2 = str2.length();
@michaelHL
michaelHL / vscode_c.md
Last active August 2, 2017 09:45
利用VSCode搭建简易C&C++编译环境

利用VSCode搭建简易C&C++编译环境

1. MinGW GCC工具链

  • (可参考之前的gist: eclipse配置C/C++编译环境)
  • 老版本MinGW仅有32位的Tool Chain, 若需要编译64位程序, 转至MinGW-w64项目(推荐)
  • MinGW GCC 5.4.0 x86为例, 依次在Files界面选择Toolchains targetting Win32, Personal Builds, mingw-builds, 5.4.0, threads-posix, dwarf, i686-5.4.0-release-posix-dwarf-...进行下载.
@michaelHL
michaelHL / c_dyn_arr.md
Last active July 5, 2017 05:26
C/C++动态分配数组

C语言中动态分配数组

原帖: http://blog.chinaunix.net/uid-11085590-id-2914577.html

如何动态的定义及使用数组呢? 记得一般用数组的时候都是先指定大小的。 当时问老师,老师说是不可以的。 后来又问了一位教C++的老师,他告诉我在C++里用new可以做到, 一直不用C++,所以也不明白。 今天在逛论坛时终于找到了C语言中的用法(看原贴):

采用 times new roman字体应使用 usepackage{txfonts} 宏包。
采用粗体字应使用 usepackage{bm} 宏包。
\bf 转变为罗马族,直立形状,黑体系列的字体属性。
\it 转变为罗马族,斜体形状,中等粗细系列的字体属性。
\rm 转变为罗马族,直立形状,中等粗细系列的字体属性,这是默认的字体。
\sc 转变为罗马族,小型大写形状,中等粗细系列的字体属性。
\sf 转变为无衬线族,直立形状,中等粗细系列的字体属性。
\sl 转变为罗马族,slanted的斜体形状,中等粗细系列的字体属性。
\tt 转变为打字机族,直立形状,中等粗细系列的字体属性。
@michaelHL
michaelHL / translate_youdao.r
Last active July 26, 2023 11:50
有道翻译api(via R), youdao dict
## install.packages(c("RCurl", "rjson", "digest"))
library(RCurl)
library(rjson)
library(digest)
## 老版, 已无法get到新的key
user = "blog125"
key = "21376174"
作者:王晗
链接:https://www.zhihu.com/question/41206352/answer/146930087
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[UTF-8,a4paper, 11pt]{article}
%%%%%% 导入包 %%%%%%
@michaelHL
michaelHL / 2017-06-26_linux.md
Last active June 28, 2017 13:34
2017年6月折腾笔记

history 命令

  1. 可控浏览: history | less
  2. 利用环境变量 HISTTIMEFORMAT 在历史中显示 TIMEPSTAMP(时间戳):
export HISTTIMEFORMAT='%F %T '
  1. 完全清除历史消息:
history -c &amp;&amp; history -w