This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class BSST | |
def initialize(capacity = 2) | |
@keys = Array.new(capacity) | |
@vals = Array.new(capacity) | |
@n = 0 | |
end | |
def is_empty? | |
@n == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#生成 10_000 个呈正态分布的范围在0-4之间的随机数 | |
#计算他们的平均值 | |
#从中随机抽取100个数 | |
#通过有放回重抽法尝试 10_000 次 | |
#每次抽 100 个数 | |
#计算这100个数的平均值 | |
#计算这 10_000 次的平均值 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/env ruby | |
class BST | |
def initialize | |
end | |
def get key | |
node = _get(root, key) | |
node ? node.val : node | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>particle</title> | |
<style> | |
body { | |
margin: 0; | |
padding: 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
#!/usr/bin/env ruby | |
Dir.chdir('_posts') do | |
Dir.glob('*.markdown') do |filename| | |
File.open(filename, mode: 'r+:UTF-8') do |file| | |
content = file.read(file.size) | |
# date = content.match(/date: (\d+-\d+-\d+)/) | |
# if date.nil? | |
# puts filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isArray(obj){ | |
if(Array.prototype.isArray){ | |
return Array.prototype.isArray(obj) | |
} | |
return Object.prototype.toString.call(obj) === '[object Array]' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatten = (function(){ | |
var result = []; | |
var _innerFlatten = function(arr){ | |
if(arr.length === 0){ | |
return []; | |
} | |
arr.forEach(item => { | |
console.log(item) | |
console.log('>>>') | |
if(isArray(item)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str = 'abc'; | |
var nStr = str.replace(/\w/g,function(m,offset,s){ | |
return (offset ? '-' : '') + m.repeat(offset+1).replace(/(\w)/,(m)=>m.toUpperCase()); | |
}) | |
console.log(nStr); | |
// A-Bb-Ccc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src='test_1.js'></script> | |
</head> | |
<body> | |
<div id="mvvm-app"> | |
<input type="text" v-model="word"> |
OlderNewer