Home - 9dian/Index GitHub Wiki

cygwin

./setup-x86_64 -q -P wget -s https://mirrors.aliyu

./setup-x86_64 -q -L -l "D:\cygwin-packages" -R "d:\cygwin64" -s "file:///D:/cygwin-packages" -P cron

参数解释
-q:静默模式(无需用户交互)。
-L:强制使用本地包目录中的文件,而不是从网络上下载。
-l "D:\cygwin-packages":指定本地包目录路径(注意这里使用的是Windows路径格式)。
-R "C:\cygwin64":指定Cygwin的安装路径。
-s "file:///D:/cygwin-packages":指定包的本地源(URI格式)。 
-P cron:指定要安装的包名称,这里是cron。
其他注意事项
确保本地源目录(例如D:\cygwin-packages)中包含cron包的相关文件及所有依赖。
如果安装过程中遇到依赖问题,请确保本地源中包含这些依赖包,或将依赖包也一并添加到安装命令中。
运行上述命令后,setup-x86_64.exe将从本地源安装cron包并确保其依赖项满足。

cygrunsrv --install cron --path /usr/sbin/cron --args -n
*** There are a lot of web posts that say you should use cygrunsrv -I cron -p /usr/sbin/cron -a -D (See Errors #1 & #2).
# rm bg color
color=$( convert filename.png -format "%[pixel:p{0,0}]" info:- )
convert filename.png -alpha off -bordercolor $color -border 1 \
    \( +clone -fuzz 30% -fill none -floodfill +0+0 $color \
       -alpha extract -geometry 200% -blur 0x0.5 \
       -morphology erode square:1 -geometry 50% \) \
    -compose CopyOpacity -composite -shave 1 outputfilename.png

curr

Token indices sequence length is longer than the specified maximum sequence length for this model (2346 > 2048). Running this sequence through the model will result in indexing errors

按照"codelibs fess: JSON Data Store for Fess 的示例"的回答创建Data Store, 执行后报错 org.codelibs.fess.exception.DataStoreException: files and directories are blank.

一种提升自然语言查询结构化数据准确性的方法 重建领域prompt(保留字、同义词、相似度向量库),再输入模型。查询车型配置的方法和装置

ImportError: attempted relative import with no known parent package

https://cloud.tencent.com/developer/article/1838550

(本文翻译自《The Art of Asking ChatGPT for High-Quality Answers A Complete Guide to Prompt Engineering Techniques》这本书,本文的翻译全部由ChatGpt完成,我只是把翻译内容给稍微排版了一下。做完了才发现这个工作早就有人做过了...下面是我以此事件让New Bing编写的一个小故事,希望大家喜欢)

他终于画完了他的画,心满意足地把它挂在了墙上。他觉得这是他一生中最伟大的作品,无人能及。他邀请了所有的朋友来欣赏,期待着他们的赞美和惊叹。 可是当他们看到画时,却没有一个人说话。他们只是互相对视,然后低头咳嗽,或者假装看手机。他感到很奇怪,难道他们都不懂艺术吗?难道他们都没有眼光吗? 他忍不住问其中一个朋友:“你觉得我的画怎么样?” 朋友犹豫了一下,说:“嗯……其实……这个画……我以前在哪里见过。” “见过?你在哪里见过?”他惊讶地问。 “就在……就在那边啊。”朋友指了指墙角的一个小框架,“那不就是你上个月买回来的那幅名画吗?你怎么把它照抄了一遍? ——New Bing

`

static void Main(string[] args)
{
    CcdImgClient currInstance = CcdImgClient.Instance;
    currInstance.InitPythonEnv();

    // This delegate will be called when the thread is done executing.obj/Program.cs
    Bitmap image1 = new Bitmap(@"E:\Cnt_1_相机2_平台30_原始_时间码2023082115410830.0.bmp", true);

    byte[] img_buff = ImageToByteArray(image1);
    // byte[] img_buff = GetRGBValues(image1);
    Console.WriteLine(img_buff.Length);
    string ret = pythonModule.evaluate_bin_img(img_buff);

    Console.WriteLine(ret);

}

public static byte[] ImageToByteArray(Bitmap bmap)
{
        using (var ms = new MemoryStream())
        {
            bmap.Save(ms, bmap.RawFormat);
            return ms.ToArray();
        }
}

`

d etl

select domoy, i_cnt, speech_source , category_no, classifier, domain from ( select *, row_number() over (partition by domoy,speech_source, category_no, classifier, domain order by domoy) rn from ac_ods.device_domain ) t where rn = 1;

insert into ac_ods.appliance_domain select  regexp_replace('2020-03-01', '-', '')  as domoy, count(1) dicnt, speech_source, category_no, nlu_l1, nlu_l2 from aipdc.intent where year_month=202003 and to_date(time)  =  '2020-03-01' group by speech_source, category_no, nlu_l1, nlu_l2 ;
insert into aipdc.speaker_domain select 20200501, count(1), 'speaker', '1C', get_json_object(action_vod, '$.domain') as domain from tmp.ods_smart_speaker_reportdata_state where part_dt = '2020-05-01' group by get_json_object(action_vod, '$.domain') ;

insert into ac_ods.slient60 select regexp_replace('2020-05-01', '-', '') as domoy, count(distinct sn) c60_silent, case when speech_source is null then 'Total' else speech_source end as speech_source from aipdc.intent t where to_date(t.time) < date_sub('2020-05-01', 60) and not exists ( select 1 from aipdc.intent n where to_date(n.time) > date_sub('2020-05-01', 60) and to_date(n.time) <= '2020-05-01' and n.sn = t.sn) group by speech_source with rollup ;

insert into aipdc.device_domain_stage partition(year_month=202008) select 20200802, sum(i_cnt),  speech_source, category_no, classifier, domain from ac_ods.appliance_domain where domoy <= 20200802 group by speech_source, category_no, classifier, domain order by speech_source , category_no, classifier, domain;
insert into aipdc.device_domain_stage partition(year_month=202008) select 20200802, sum(i_cnt), speech_source, category_no, 'publicDomain', domain from ac_ods.speaker_domain where domoy <= 20200802 group by speech_source, category_no, domain order by speech_source , category_no, domain;

``


-- curr
insert overwrite table ac_ods.device_base
select domoy, new_cnt, accumulate_cnt , active_cnt, active2_cnt, speech_source , category_no  from (
select *, row_number() over (partition by domoy,speech_source, category_no order by domoy) rn from  aipdc.device_base_stage 
) t where rn = 1;
insert overwrite table aipdc.device_base_stage select * from  ac_ods.device_base;

insert overwrite table ac_ods.speaker_domain
select domoy, i_cnt, speech_source , category_no, domain from (
select *, row_number() over (partition by domoy,speech_source, category_no, domain order by domoy) rn from  aipdc.speaker_domain
) t where rn = 1;
insert overwrite table aipdc.speaker_domain select * from ac_ods.speaker_domain;

-- alter table  aipdc.device_domain_stage drop if exists partition(year_month=202008);
insert overwrite table ac_ods.device_domain
select domoy, i_cnt, speech_source , category_no, classifier, domain from (
  select *, row_number() over (partition by domoy,speech_source, category_no, classifier, domain order by domoy) rn from aipdc.device_domain_stage
  where i_cnt is not null and year_month=202008 
) t where rn = 1;
insert overwrite table aipdc.device_domain_stage partition(year_month=202008) select * from ac_ods.device_domain where domoy >=20200801

-- insert into table aipdc.device_domain_stage partition(year_month=202008) select domoy, i_cnt, speech_source , category_no, classifier, domain from ac_ods.device_domain where domoy >=20200801 and domoy < 20200824


insert overwrite table ac_ods.device_accumulate 
select domoy, newdevice_cnt, device_cnt, speech_source, province, city  from (
select domoy, newdevice_cnt, device_cnt, speech_source, province, city , row_number() over (partition by domoy, speech_source order by domoy) rn from aipdc.device_accumulate_stage
) t where t.rn = 1;
insert overwrite table aipdc.device_accumulate_stage  select * from  ac_ods.device_accumulate;

insert overwrite table ac_ods.device_retention
select domoy, cnt1d, cnt2d_excluding_end, cnt3d_excluding_end, cnt7d_excluding_end, c60_silent, speech_source, province, city from (
select domoy, cnt1d, cnt2d_excluding_end, cnt3d_excluding_end, cnt7d_excluding_end, c60_silent, speech_source, province, city, row_number() over (partition by domoy, speech_source order by domoy) rn from aipdc.device_retention_stage) t where  t.rn = 1;
insert overwrite table  aipdc.device_retention_stage select * from  ac_ods.device_retention;

Toos/MISC

vscode

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            //配置名称,将会在启动配置的下拉菜单中显示
            "name": "Python: Current File",
            //配置类型
            "type": "python",
            //请求配置类型,可以为launch(启动)或attach(附加)
            //launch: VSCode 会打开这个程序然后进入调试
            //attach:你已经打开了程序,然后接通内部调试协议进行调试
            "request": "launch",
            "stopOnEntry": false,
            "justMyCode": true,
            "python": "/data/datasets/stable-diffusion21-webui/stable-diffusion-webui/venv/bin/python",
            //将要进行调试的程序的路径
            "program": "${file}",
            //调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
            "cwd": "${workspaceRoot}",
            "console": "internalConsole",
            "env": {"CUDA_VISIBLE_DEVICES": "1"},
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                // "WaitOnAbnormalExit",
                // "WaitOnNormalExit",
                "RedirectOutput"
            ],
            "args": [
                "--xformers",
                "--api-log",
                "--nowebui"
            ]
        }
    ]
}

Maven

mvn archetype:generate -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.11.1 -DinteractiveMode=false -DarchetypeCatalog=local -Dpackage=ai -DartifactId=rtflow -DgroupId=ai

...
[DEBUG] -- end configuration --
[INFO] Generating project in Interactive mode
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
... 

禁用Interactive mode,避免网络不好时连接时间过长。

maven在pom文件里引用本地jar

<dependency> 
    <groupId>org.apache</groupId> 
    <artifactId>common</artifactId> 
    <version>3.1</version> 
    <scope>system</scope> 
    <systemPath>d:/apacheXXX-common.jar</systemPath> 
</dependency>

mvn archetype:generate -DarchetypeCatalog=internal

mvn deploy:deploy-file \
    -DgroupId=com.yourname.jgoodies \
    -DartifactId=jgoodies-forms \
    -Dversion=1.50 \
    -Dfile=/path/to/jgoodies-1.50.jar \
    -Dpackaging=jar \
    -Durl=file://path/to/your/local/repository 
	
mvn install:install-file \
    -DgroupId=org.python \
    -DartifactId=jython-standalone \
    -Dversion=2.7.1 \
    -Dfile=/home/ubuntu/Downloads/jython-standalone-2.7.1.jar \
    -Dpackaging=jar \
#    -Durl=/home/ubuntu/.m2/repository/ 

For the sources:

mvn deploy:deploy-file \
    -DgroupId=com.yourname.jgoodies \
    -DartifactId=jgoodies-forms \
    -Dversion=1.50 \
    -Dfile=/path/to/jgoodies-sources.jar \
    -Dpackaging=jar \
    -Durl=file://path/to/your/local/repository \
    -Dclassifier=sources

For the javadoc:

mvn deploy:deploy-file \
    -DgroupId=com.yourname.jgoodies \
    -DartifactId=jgoodies-forms \
    -Dversion=1.50 \
    -Dfile=/path/to/jgoodies-javadoc.jar \
    -Dpackaging=jar \
    -Durl=file://path/to/your/local/repository \
    -Dclassifier=javadoc

Note that this will generate a standard POM, so you won't have the dependencies of 

JGoodies (if any) pulled automatically but have to specify them manually in your project.

Some tips

[root@centos-01 yum.repos.d]# cat init/local.repo
[InstallationMedia]
name=CentosLocalInstallation
#baseurl=file:///media/cdr
baseurl=file:///media/CentOS_6.6_Final
enabled=1
gpgcheck=0
#CentOS_6.6_Final
说明 Redhat Debian
更新缓存 yum makecache apt-get update
更新包 yum update apt-get upgrade
检索包 yum search apt-cache search
检索包内文件 yum provides apt-file search
安装指定的包 yum install apt-get install
删除指定的包 yum remove apt-get remove
显示指定包的信息 yum info apt-cache show
显示包所在组的一览 yum grouplist -
显示指定包所在组的信息 yum groupinfo -
安装指定的包组 yum groupinstall -
删除指定的包组 yum groupremove -
参考库的设定文件 /etc/yum.repos.d/* /etc/apt/sources.list
安装完的包的列表 rpm -qa dpkg-query -l
显示安装完的指定包的信息 rpm -qi apt-cache show
安装完的指定包内的文件列表 rpm -ql dpkg-query -L
安装完的包的信赖包的列表 rpm -qR apt-cache depends
安装完的文件信赖的包 rpm -qf dpkg -S

Command/Tools

wget

同步Ubuntu清华源noble(24.04)版本的dists

for p in "${1:-noble}"{,-{security,updates,backports}}
do
echo $p;
# -np 与 -nH --cut-dirs一起使用时, -np貌似不生效, GNU Wget 1.21.4(@ubuntu24.04)
wget -c -r -e robots=off -np -R "index.htm*" "https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/$p/"
done

awk

排除某些列

awk '{$3=""; print $0}' FILE
# 排除多列
awk '{$1=$2=""; print $0}' FILE

排除某些列2

Print a range of columns from the first till the fourth:

$ awk -v f=2 -v t=4 '{for(i=f;i<=t;i++) printf("%s%s",$i,(i==t)?"\n":OFS)}' FILE

Exclude a column range from the second till the fourth and print the rest:

$ awk -v f=2 -v t=4 '{for(i=1;i<=NF;i++)if(i>=f&&i<=t)continue;else printf("%s%s",$i,(i!=NF)?OFS:ORS)}' FILE

https://phoenixnap.com/kb/awk-command-in-linux#special-expression-patterns

sed

匹配换行符

sed -i -e ':a' -e 'N' -e '$!ba' -e 's#trans-log-table>\n\s\+<connection />\n\s\+<schema />\n\s\+<table />\n#trans-log-table> <connection>payment_dwh</connection> <schema>public</schema> <table>audit_trans_log</table>#g' -e s'#channel-log-table>\n\s\+<connection />\n\s\+<schema />\n\s\+<table />\n#channel-log-table> <connection>payment_dwh</connection> <schema>public</schema> <table>audit_channel_log</table>#g' -e s'#job-log-table>\n\s\+<connection />\n\s\+<schema />\n\s\+<table />\n#job-log-table> <connection>payment_dwh</connection> <schema>public</schema> <table>audit_job_log</table> #g' -e s'#jobentry-log-table>\n\s\+<connection />\n\s\+<schema />\n\s\+<table />\n#jobentry-log-table> <connection>payment_dwh</connection> <schema>public</schema> <table>audit_job_entry_log</table>#g' load_dim_payer\ -\ 副本.ktr | grep xxx

sed -i -e ':a' -e 'N' -e '$!ba' -e 's#trans-log-table>\n\s+\n\s+\n\s+

\n#trans-log-table> payment_dwh public audit_trans_log
#g'
-e s'#channel-log-table>\n\s+\n\s+\n\s+
\n#channel-log-table> payment_dwh public audit_channel_log
#g'
-e s'#job-log-table>\n\s+\n\s+\n\s+
\n#job-log-table> payment_dwh public audit_job_log
#g'
-e s'#jobentry-log-table>\n\s+\n\s+\n\s+
\n#jobentry-log-table> payment_dwh public audit_job_entry_log
#g'
load_dim_payer\ -\ 副本.ktr | grep xxx
⚠️ **GitHub.com Fallback** ⚠️