Skip to content

Instantly share code, notes, and snippets.

@ambar
ambar / 0.README.md
Last active March 23, 2024 04:31
Copilot Pair Programming

Copilot

品牌

  • GH Copilot
    • Copilot Chat (Editor/Github.com)
    • Copilot in the CLI
    • Copilot Enterprise (Github.com 聊天/PR 摘要)
  • MS Copilot
    • Bing Chat -> Copilot
@ambar
ambar / nospm.user.js
Last active March 16, 2024 01:44
nospm 移除虾米、淘宝和 Bilibili 网址中的 spm 参数(包括地址栏和页面中的链接),推荐使用 Tampermonkey 或者 Violentmonkey 安装,UserScript 安装地址 https://gist.github.com/ambar/9706385/raw/nospm.user.js
// ==UserScript==
// @name nospm
// @version 1.4.0
// @run-at document-start
// @updateURL https://gist.github.com/ambar/9706385/raw/nospm.user.js
// @downloadURL https://gist.github.com/ambar/9706385/raw/nospm.user.js
// @description 移除 Bilibili、淘宝、天猫、优酷网址中的 spm 参数(包括地址栏和页面中的链接)
// @include https://*.bilibili.com/*
// @include https://*.taobao.com/*
// @include https://*.tmall.com/*
@ambar
ambar / react.js
Last active November 6, 2023 05:40
jupyter deno react
import React from 'npm:react';
import ReactDOM from 'npm:react-dom/server';
// https://docs.jupyter.org/en/latest/reference/mimetype.html
const inspect = (obj: any) => {
if (React.isValidElement(obj)) {
return {
[Symbol.for('Jupyter.display')]() {
return {
'text/html': ReactDOM.renderToString(obj),
@ambar
ambar / gist:1534274
Created December 29, 2011 14:15 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@ambar
ambar / browser_client.html
Created July 6, 2011 03:08
websocket的node实现笔记,http和tcp两版
<html>
<head>
<title>WebSocket Demo</title>
</head>
<style type="text/css">
textarea{width:400px;height:150px;display:block;overflow-y:scroll;}
#output{width:600px;height:400px;background:whiteSmoke;padding:1em .5em;color:#000;border:none;}
button{padding:.2em 1em;}
</style>
<link href="layout.css" rel="stylesheet" type="text/css" />
/**
* 将 CacheStorage 转换为简单的 key/value 存储
*/
export const createStore = (name: string) => {
const cacheP = caches.open(name)
const encodeKey = (str: string) => `/?key=${encodeURIComponent(str)}`
const decodeKey = (str: string) => str.match(/key=([^;]+)/)?.[1] || ''
async function get(key: string) {
const cache = await cacheP
@ambar
ambar / ie6_crash.html
Created December 21, 2011 12:32
如何改善百度统计引入代码
<html>
<head>
<title></title>
</head>
<body>
<div>
<script>
document.body.appendChild( document.createElement('script') )
</script>
@ambar
ambar / throttle.js
Created October 23, 2011 04:55
throttle and debounce
/*
* 频率控制 返回函数连续调用时,action 执行频率限定为 次 / delay
* @param delay {number} 延迟时间,单位毫秒
* @param action {function} 请求关联函数,实际应用需要调用的函数
* @param tail? {bool} 是否在尾部用定时器补齐调用
* @return {function} 返回客户调用函数
*/
var throttle = function(delay,action,tail,debounce) {
var now = Date.now, last_call = 0, last_exec = 0, timer = null, curr, diff,
ctx, args, exec = function() {
@ambar
ambar / about.md
Last active January 29, 2021 16:48
deep merge

Comparison

name immutable concat dedupe clone multiple parameters recommended
merge-deep@3.0.2 true true true true yes yes
deepmerge@3.0.0 true true false false(option) no
lodash/mege false false false true yes
lodash/megeWith false false false true yes yes
// ==UserScript==
// @name Disguise Surfing
// @namespace anonymous
// @description 伪装上网模式
// @version 0.1
// @include *
// ==/UserScript==
// make array
var $A = function(obj) { return [].slice.call(obj) }