Skip to content

Instantly share code, notes, and snippets.

@kreja
kreja / Values and formulas.yaml
Created December 10, 2018 08:05
Gets and sets values and formulas for a range. - 与Script Lab共享
name: Values and formulas
description: Gets and sets values and formulas for a range.
author: kreja
host: EXCEL
api_set: {}
script:
content: |
$("#setup").click(() => tryCatch(setup));
async function setup() {
@kreja
kreja / delete table rows doesn’t trigger onChanged.yaml
Created November 8, 2018 08:38
delete table rows doesn’t trigger onChanged - 与Script Lab共享
name: delete table rows doesn’t trigger onChanged
description: delete table rows doesn’t trigger onChanged
author: kreja
host: EXCEL
api_set: {}
script:
content: |
$("#create-table").click(createTable);
async function createTable() {
@kreja
kreja / 锁定.yaml
Created November 7, 2018 04:24
lock a range - 与Script Lab共享
name: 锁定
description: lock a range
author: kreja
host: EXCEL
api_set: {}
script:
content: |
$("#setup").click(setup);
async function setup() {
await Excel.run(async (context) => {
@kreja
kreja / compose and curry
Last active March 29, 2016 03:40
mostly-adequate-guide
// https://github.com/MostlyAdequate/mostly-adequate-guide
// https://llh911001.gitbooks.io/mostly-adequate-guide-chinese/content/ch5.html
// this is my practice while reading the book
var compose = function(){
var args = arguments;
return function(x){
var res = x;
@kreja
kreja / getNum.js
Created November 22, 2015 07:49 — forked from shepherdwind/getNum.js
fast way to find path
/* 后端数据 */
var data = {
"10;20;30": {
price: 5,
count: 1
},
"10;20;31": {
price: 10,
count: 2
},
@kreja
kreja / GetOptimizationStatus
Created October 17, 2015 09:32
检测 js 是否被 V8 优化
/**
* 执行语句: node --trace_opt --trace_deopt --allow-natives-syntax test.js
*/
// 包含需要审查的用法的函数 (这里是 with 语句)
function containsHeight() {
return 3;
// with({}) { } // with 注释掉之后,又可以优化了
}
@kreja
kreja / closure-related
Created October 13, 2015 15:54
闭包相关,释放内存
@kreja
kreja / specialString
Created October 7, 2015 05:19
给内置对象增加属性/方法
function specialString(){
var values = new String(arguments[0]);
values.startWith= function(text){
if(values.indexOf(text) == 0){
return true;
}else{
console.log(values,values.indexOf(text));
return false;
}
@kreja
kreja / defineProperties
Last active October 2, 2015 03:35
利用 Object.defineProperty / Object.defineProperties 实现:改变一个属性影响另一个属性的值
var rectangle = {
_h: 1,
_w: 1,
_area: 1
};
Object.defineProperties(rectangle,{
h: {
get: function(){
return this._h;