Skip to content

Instantly share code, notes, and snippets.

View ZPVIP's full-sized avatar

Peng Zhang ZPVIP

  • Boise, ID, USA
  • 07:47 (UTC -06:00)
View GitHub Profile
@JimLiu
JimLiu / ChatGPT-Translate-Long-Text.js
Last active April 8, 2024 07:26
使用ChatGPT自动分页翻译长文
// WARNING:此脚本仅做学习和演示用途,在不了解其用途前不建议使用
// 本脚本的用途是将输入内容分页,每次提取一页内容,编辑第二条消息,发送,然后收集结果
// 使用前,需要有两条消息,参考模板 https://chat.openai.com/share/17195108-30c2-4c62-8d59-980ca645f111
// 演示视频: https://www.bilibili.com/video/BV1tp4y1c7ME/?vd_source=e71f65cbc40a72fce570b20ffcb28b22
//
(function (fullText) {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const groupSentences = (fullText, maxCharecters = 2800) => {
const sentences = fullText.split("\n").filter((line) => line.trim().length > 0);
@mieko
mieko / marching_squares.rb
Created September 29, 2014 05:09
Marching Squares in Ruby (with Inline C implementation)
class MarchingSquares
STATE = { "0000" => :r, "1100" => :r, "0011" => :l, "1110" => :r,
"0100" => :r, "1000" => :u, "1011" => :u, "1001" => :u,
"0101" => :d, "1010" => :u, "0111" => :l, "0110" => :l,
"0001" => :d, "0010" => :l, "1101" => :d, "1111" => :r }
def self.find_shape(grid, w, h)
edge_pos = grid.index('1')
return nil if edge_pos.nil?
@mieko
mieko / marching_squares.cc
Created September 29, 2014 05:07
Marching Squares in C++
#include "marching-squares.hh"
#include "point.hh"
#include "polygon.hh"
#include "douglas-peucker.hh"
#include <ps/canvas/canvas.hh>
#include <cstring>
#include <vector>
@nightire
nightire / Changes in Rails 4_1.md
Last active September 28, 2025 09:55
拥抱 Rails 4 —— 详述 Rails 4 的新变化

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb
@jhjguxin
jhjguxin / Rakefile
Created June 20, 2012 05:26
how to resque
#No such file to load -- devise/confirmations_controller
#resque worker devise not eager loading
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'resque/tasks'
Askjane::Application.load_tasks
task "resque:setup" => :environment do
@alotaiba
alotaiba / google_speech2text.md
Created February 3, 2012 13:20
Google Speech To Text API

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English