Skip to content

Instantly share code, notes, and snippets.

View browser_speak.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
@yiyizym
yiyizym / textarea_auto_height.html
Last active Oct 29, 2017
textarea_auto_height
View textarea_auto_height.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style>
textarea{
padding: 5px;
font-size: 14px;
height: 14px;
line-height: 1;
@yiyizym
yiyizym / index.html
Created May 25, 2017
一个能用的简单 mvvm 实现
View index.html
<!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">
@yiyizym
yiyizym / formatString.js
Created May 25, 2017
一道字符串面试题
View formatString.js
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
View isArray.js
function isArray(obj){
if(Array.prototype.isArray){
return Array.prototype.isArray(obj)
}
return Object.prototype.toString.call(obj) === '[object Array]'
}
@yiyizym
yiyizym / flatten_array.js
Created Feb 17, 2017
flatten array in javascript
View flatten_array.js
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)){
View deep_merge.js
'use strict';
function deepMerge(){
let args = [].slice.call(arguments);
let target = args.shift();
let sources = args;
if(sources.length == 0){
return target;
}
else {
@yiyizym
yiyizym / migrate.rb
Created Feb 3, 2017
migrate from hexo to jekyll
View migrate.rb
# 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
View particle_system.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>particle</title>
<style>
body {
margin: 0;
padding: 0;
}
@yiyizym
yiyizym / bst.rb
Last active Dec 19, 2016
binary search tree
View bst.rb
#!usr/bin/env ruby
class BST
def initialize
end
def get key
node = _get(root, key)
node ? node.val : node
end