Skip to content

Instantly share code, notes, and snippets.

@goldengrape
goldengrape / constrain_tools
Created April 19, 2023 20:29
a resource constrained tools for AutoGPT
from langchain.agents import load_tools, initialize_agent, AgentType
from langchain.chat_models import ChatOpenAI
from functools import wraps
# 设置全局资源量
autogpt_resources = 50
# 资源限制器修饰器
def resource_limiter(resource_cost):
global autogpt_resources
def time_threshold():
t = 60
tmin=5
tmax=120
while True:
value = yield t
if value:
t = max(t/2,tmin)
else:
t = min(t+10,tmax)
@goldengrape
goldengrape / huff_cough.srt
Created December 28, 2022 22:58
Chinese translation sub of "huff cough demonstration for kids" in https://www.youtube.com/watch?v=c-myXK9NJWQ
1
00:00:01.600 --> 00:00:05.640
今天艾米丽将向你展示她huff咳嗽的技巧
2
00:00:06.080 --> 00:00:09.320
huff咳嗽是清除肺部粘液的一种方法
3
from sympy import *
a,b, x = symbols('b a x') # here, swap a and b, bug
f = a*x**2 + b*x
sub_dict={a:1,b:2,x:3}
print(f)
print(f.subs(sub_dict))
print(eval(f.__str__()).subs(sub_dict))
# output:
TargetInvocationException: 调用的目标发生了异常。
在 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
在 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
在 System.Activator.CreateInstance(Type type, Boolean nonPublic)
在 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
在 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
在 System.Activator.CreateInstance(Type type, Object[] args, Object[] activationAttributes)
在 ZOSAPI.ZOSAPI_Connection.CreateApp(ZOSAPI_Connection connection, Int32 processId, Boolean wrap, Object[] args)
在 ZOSAPI.ZOSAPI_Connection.ConnectToAppByProcess(Int32 processId, Boolean wra
//
// main.cpp
// crop_video
//
// Created by GoldenGrape on 2020/6/6.
// Copyright © 2020 goldengrape. All rights reserved.
//
#include <iostream>
#include <algorithm>
#!/usr/bin/env python
# coding: utf-8
import pysubs2
import re
from stardict import DictCsv
# depend on https://github.com/skywind3000/ECDICT/
dict_filename="ecdict.csv"
sub_filename="01sub.srt"
##| 经典house节奏
##| 根据learningmusic.ableton.com课程
##| https://learningmusic.ableton.com/zh/make-beats/make-beats.html
use_random_seed 10
open_hat_beat=
[0,0,1,0,
0,0,0,0,
0,0,0,0,
0,0,0,0].ring
##| modify from
# Band Example 2
# Mehackit 2016
##| http://sonic-pi.mehackit.org/exercises/chs/11-templates/03-band-example.html
use_bpm 120
live_loop :rummut do
sample :drum_heavy_kick
sleep 1
##| 五线谱字典
##| 低音谱号数得恼火
def look_up_staff(clef,pos)
ns=["C","D","E","F","G","A","B"].ring
s_T=scale(:C4,:major,num_octaves: 2)
if clef.downcase == "treble" or clef.downcase=="t"
idx=((pos-(-1))*2).to_i
octave=(idx/7).to_i+4
name=ns[idx]+octave.to_s