Skip to content

Instantly share code, notes, and snippets.

View oldratlee's full-sized avatar
🐥
Hello world!

李鼎 oldratlee

🐥
Hello world!
View GitHub Profile
@startuml
Bob->Alice : hello
@enduml
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
条件概率公式:
P(A|B) = P(AB)/P(B)
P(AB) = P(A)P(B|A) = P(B)P(A|B)
P(A|B) = P(A)P(B|A)/P(B)
全概率公式:
P(A) = P(B1)P(A|B1) + P(B2)P(A|B2) + ... // B1,B2...是全集
@oldratlee
oldratlee / colorful-lines.sh
Created October 7, 2014 10:15
colorful-lines
#!/bin/bash
colorEcho() {
local color="$1"
shift
if [ -c /dev/stdout ] ; then
# if stdout is console, turn on color output.
echo -ne "\033[1;${color}m"
echo -n "$@"
echo -e "\033[0m"
else
@oldratlee
oldratlee / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@oldratlee
oldratlee / vcs-reading-list.md
Last active August 29, 2015 14:16
程序员必读书单-VCS

VCS看起来在“专业的软件开发素养”这个分类中。

VCS

VCS是软件开发生命线。首选git,让开发者主动感知仓库管理,生命周期才完整灵动。

所有不以VCS为一等公民的软件流程都是耍流氓!都会被遗忘而僵死!

使用VCS管理代码、发布/版本管理,在VCS上工作流展开有效的项目流程管理和高效的开发协同。

@oldratlee
oldratlee / CalcDwsMonths.py
Created November 14, 2012 10:02
Get the months which First day is monday
# find the months which First day is monday
# My related Blog: http://oldratlee.com/post/2012-11-13/1-st-day-is-monday-month-count
dayCountOfMonthOfYear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
dayCountOfMonthOfLeapYear = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
print "Day count of non-leap year: ", sum(dayCountOfMonthOfYear)
# 365, day count of non-leap year
print "Day count of leap year: ", sum(dayCountOfMonthOfLeapYear)
# 366, day count of Leap year
@oldratlee
oldratlee / war-extra-resources.md
Last active December 17, 2015 02:59
download file and add it to war file via maven

How to Activate

Activate

mvn install -P Profile-Download-Extra-Resources
@oldratlee
oldratlee / sl
Last active December 20, 2015 14:59
application starter in terminator under mac
#!/bin/bash
# open -a '/Applications/Sublime Text 2.app' "$@"
open -a 'Sublime Text 2' "$@"
import org.junit.Test;
import java.math.BigInteger;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author ding.lid
*/
@oldratlee
oldratlee / Candy.java
Last active December 24, 2015 18:49
陈利人微博题的实现代码:http://weibo.com/1915548291/AcqqPxnEp #面试题#N个孩子站成一排,每个人分给一个权重。按照如下的规则分配糖果: 每个孩子至少有一个糖果;所分配权重较高的孩子,会比他的邻居获得更多的糖果。 问题是,最少需要多少个糖果?关注微信公众账号“待字闺中”,了解更多。 http://oj.leetcode.com/problems/candy/。 PS: 现在代码移到了 https://github.com/oldratlee/leetcode/blob/master/src/main/java/candy/Solution.java
/** 通过的UT Case:
assertEquals(0, Candy.calcCandyCount(new int[]{}));
assertEquals(1, Candy.calcCandyCount(new int[]{1,}));
assertEquals(1, Candy.calcCandyCount(new int[]{100,}));
assertEquals(2, Candy.calcCandyCount(new int[]{1, 1,}));
assertEquals(3, Candy.calcCandyCount(new int[]{1, 2,}));
assertEquals(3, Candy.calcCandyCount(new int[]{2, 1,}));