Skip to content

Instantly share code, notes, and snippets.

View chunpu's full-sized avatar
🎯
Focusing

chunpu chunpu

🎯
Focusing
  • 360
  • China
View GitHub Profile
@chunpu
chunpu / chatgpt-long-text.js
Last active May 14, 2023 02:55
ChatGPT Long Text
!(function () {
// ai.com console input
// 使用方法 q(`long text`)
var $ = function (val) {
return document.querySelector(val)
}
window.q = q
async function q(longStr) {
var sendIndex = 0
var maxOnce = 300 // 每次最多300个中文
@chunpu
chunpu / blend.html
Last active April 21, 2021 08:13
blend color with alpha 层叠混合带透明度的颜色, 支持任意层叠数
<canvas width="800" height="600" style="border: 1px solid red"></canvas>
<script>
var canvas = document.querySelector('canvas')
var ctx = canvas.getContext("2d")
var color1 = [255, 152, 0, 0.5]
var color2 = [76, 175, 80, 0.5]
var color3 = [33, 150, 243, 0.5]
var blended = blend(color1, color2, color3)
console.log({ blended })
@chunpu
chunpu / macYear.js
Created July 14, 2016 06:17
get mac version with year
// https://browser.primatelabs.com/mac-benchmarks
Object.keys($('#mac32').find('tr').map(function() {return $(this).find('.name a').text()}).toArray().map(function(x) {return (/\w+ \d{4}/.exec(x) || [])[0]}).filter(function(x) {return x}).reduce(function(prev, val, key) {prev[val] = 1; return prev}, {})).map(function(x) {return x.split(' ')}).sort(function(x, y) {return x[1] - y[1]}).map(function(arr) {return arr[1] + ' ' + arr[0]}).join('\n')
@chunpu
chunpu / debug.as
Created October 24, 2014 05:58
copy TJ's debug to as3
package {
import flash.external.ExternalInterface;
public class Log {
public static var logs:Array = [];
private static const INHERIT:String = 'color:inherit';
private static const PREFIX:String = '';
private static const LS_KEY:String = 'debug';
!function(fn) {
window.$ = fn()
}(function() {
var $ = function(selector, context) {
return new $.fn.init(selector, context)
}
// var
@chunpu
chunpu / demo.lua
Created August 14, 2014 07:57
a koa style lua sample
-- koa style downstream and upstream
local thread1 = coroutine.create(function(down)
print('thread1-down')
coroutine.yield(down)
print('thread1-up')
end)
local thread2 = coroutine.create(function(down)
print('thread2-down')
@chunpu
chunpu / jquery-animate.js
Last active August 29, 2015 14:04
jQuery css3 animate, if browser support css3 transition, use it. (ps: however, the performance is not obvious improved, and it is not in promise queue, so just for simplest situation)
!function($, doc) {
if (!$ || !$.fn) return
var css3 = function() {
var style = doc.body.style
var test = ['transition', 'webkitTransition', 'MozTransition', 'msTransition']
for (var i = 0, x; x = test[i++];) {
if (x in style) {
return x
}
@chunpu
chunpu / socks.js
Created June 24, 2014 11:21
useful socks!
// copy from https://github.com/gvangool/node-socks
// it is useful but shit code style
// save and one day pretty it
var net = require('net'),
util = require('util'),
log = function(args) {
//console.log(args);
},
info = console.info,
errorLog = console.error,
<script type='x' id='markdown'>
title
===
> blockquote
code
code2
### head
<script type='x' id='markdown'>
title
===
> blockquote
code
code2
### head