Skip to content

peng051410/today_i_learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

Command line

打印文本第一行

awk 'NR==1{print}' filename

获取文本最后一列

主要是$NF

awk -F ',' '{print $NF}'

Delete all broken soft link

find -L . -name . -o -type d -prune -o -type l -exec rm {} +

Rotate a image

function ro() {
    szFile=$1
    convert $1 -rotate 90 $(basename "$szFile").png
}

Split image

convert -crop 100%x20% in.png output.png

https://dev.to/ko31/using-imagemagick-to-easily-split-an-image-file-13hb

Nohup to file and console

nohup ./program  > Output.txt | tail -F Output.txt &

检验文件或者文件夹是否存在

判断文件是否存在

if [ -e x.txt ]
then
    echo "ok"
else
    echo "nok"
fi

判断文件夹是否存在

if [ -d folder1 ]
then
    echo "ok"
else
    echo "nok"
fi

判断软链接存在并且可用虽

[ -L ${my_link} ] && [ -e ${my_link} ]

判断文件夹不存在

获取本机ip

ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
# linux only
hostname -i

Delete file expect few files

rm -v !("filname1"|"file2")

Sync file from source to target increment

rsync -av Documents/* /tmp/documents

Scp with port

scp -P 2222 file host@localhost:~/linux-study

Check url exist

Method1

url=http://www.baidu.co
if wget --spider $url 2>/dev/null; then
  echo "File exists"
else
  echo "File does not exist"
fi

Method2

url=http://www.baidu.co
if wget -q --method=HEAD $url;
 then
  echo "This page exists."
 else
  echo "This page does not exist."
fi

Get host ip

curl ipaddy.net

Generate short link

curl -s 'tinyurl.com/api-create.php?url=http://www.baidu.com'

Get weather

curl wttr.in

Pass passphrase to gpg

shell script - gpg asks for password even with –passphrase - Unix & Linux Stack Exchange

gpg -c --batch --passphrase 1234 -o file.gpg

Where xhost

x11 - xhost on MacOS Catalina - Ask Different

/opt/X11/bin/xhost

Display custom date

显示3小时之前的时间

date -d '3 hours ago' +"%Y-%m-%d %T"
# another way
date -d "-3 Hours" "+%Y-%m-%d %T"

Extract filename and extension from file

https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash?page=1&tab=scoredesc#tab-top

fullfile=~/Downloads/main-webapp_log_Onl_jar_backend.yml
filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"
echo "filanme is $filename, file extendsion is $extension"

Truncate file

truncate file only retain 10 line

In-place

sed -i.bak '11,$ d' myfile.txt

New file

head -n10 myfile.txt > myfile.txt.bak

https://stackoverflow.com/questions/19017994/how-do-i-limit-or-truncate-text-file-by-number-of-lines

Cut file

echo "hello world" | cut -b 2-5

ello

Quick rename file name

cd /tmp
touch aa.txt
mv aa.{txt,doc}
ls aa.doc

Use default value for shell

FOO="${VARIABLE:-default}"  # FOO will be assigned 'default' value if VARIABLE not set or null.
# The value of VARIABLE is kept intouched.

FOO="${VARIABLE:=default}"  # If VARIABLE not set or null, set it's value to 'default'.
# Then that value will be assigned to FOO

Captured On: [2023-10-09 Mon 16:50]

export ls result to txt with absolute path

https://unix.stackexchange.com/questions/268474/how-to-list-all-files-in-a-directory-with-absolute-paths

ls -d "$PWD"/* >> ~/work/repos.txt

Export proxy app req to curl

Charles

url -> 右键 -> Copy cURL Request

Fidder

File -> Export -> Selected Sessions -> cURL script

Browser

url -> 右键 -> Copy cURL Request

Maven

How to get Maven project version from cmd

mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:

Maven use alternative repo

mvn -DaltDeploymentRepository=repoid::default::http://ip/nexus/content/repositories/releases clean source:jar-no-fork deploy

Maven download dependency source code

mvn can download all project dependency jar source code by the maven-dependency-plugin , there are two approach to reach the goal.

Run dependency command directly

mvn dependency:sources -Dsilent=true

I prefer this way.

Config on pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.5.0</version>
    <executions>
      <execution>
        <id>download-sources</id>
        <goals>
          <goal>sources</goal>
        </goals>
        <configuration>
        </configuration>
      </execution>
    </executions>
  </plugin>

After add the plugin config, run normal mvn command to download source code

Captured On: [2023-03-16 Thu 16:04]

Maven get settings file location

mvn -X clean | grep "settings"

Captured On: [2023-03-16 Thu 16:35]

Captured On: [2023-10-31 Tue 17:41]

add nonFilteredFileExtensions config works for me.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
        <encoding>UTF-8</encoding>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>db</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

Emacs

给Emacs文档增加目录

给Entry增加标签 =:TOC:=,限定目录层级#+OPTIONS: toc:1

Add command to keyboard macro

https://www.gnu.org/software/emacs/manual/html_node/emacs/Basic-Keyboard-Macro.html C-u f3 能执行macro直接到按下f4

Set major mode on file

https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html

;; set major mode, with this, other set will be ignore
; -*-Lisp-*-

Add minor mode on file

; -*- eval: (rainbow-mode) -*-

Straight use builtin org

将下面的配置加到straight配置前

(straight-use-package '(org :type built-in))

Delete blank line

https://www.masteringemacs.org/article/removing-blank-lines-buffer

M-x flush-lines RET ^$ RET

Insert file contents to org source area

In src area, run C-x i

grep 'cool thing' ~/Donwnloads

Add note to blog

  1. #+STARTUP: logdrawer
  2. 在需要加note的item执行 C-c C-z

Yas add custom style date

Insert current date with yasnippet - Emacs Stack Exchange

`(format-time-string "%Y-%m-%d")`$0

Change org babel export language

How to change the language of a result of ":results output code" in emacs org-mode - Stack Overflow

/Users/tomyli/github/today_i_learn

Ignore error info

(condition-case nil
    (progn
      (message "hello")
    t)
  (error nil)

Org add repeated task for weekday

* TODO Study 09:00-10:00
<%%(memq (calendar-day-of-week date) '(1 2 3 4 5))>

Org babel python output always Nono

Python org-mode source block output is always ': None' - Emacs Stack Exchange Can use return or add :results output

Org add current time

C-u C-c .

Captured On: [2023-05-24 Wed 10:22]

Handle swiper search result

Ctrl+s搜索后,再按 Ctrl+c Ctrl+o 打开处理结果的buffer

Change org reveal font color

org mode - Change font color on a org-reveal slide - Emacs Stack Exchange

  1. Add header

    #+MACRO: color @@html:$2@@

  2. Use macro

    {{{color(red, 基于2019.1版本.)}}}

So-long mode

When a file very big, so-long mode can fixed it

Trim changed line white space

redguardtoo/emacs.d#1014 Emacs has an minor mode called ws-butler-mode can trim white space only with changed line.

Open chrome-extension: prefix url

Copy rectangle area content

It's useful to yank org table cols without additional custom func. img

Insert stuff like vi column mode but with string-rectangle

https://twitter.com/i/status/1620721190536114177

Run region code with command line

I have an request to run curl script with shell, normaly the content is paste from other place, so I think this is any way the emacs can do this, After search emacs doc and request google, I found the 'shell-commond-on-region'. When I run this command, it works, but another issue occurs that the result only shows in the minibuffer which I can't do it more like search or copy. Fortunately, the SO user @xuchunyang give me the perfect anwser, an customed 'shell-command-on-region' which output the result after the request bufer. With this, I can do more imaginable.

Captured On: [2023-03-14 Tue 15:03]

Joint multi lines to one line

Sometimes in develop, we need to convert multi line content to one line, we can realize with Emacs 'join line' command.

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>5.3.23</version>
  <scope>compile</scope>
</dependency>

img

Save all org buffer

Realize with org-save-all-org-buffers command

Org mode search complete task

search previous week done task

TODO="DONE"&CLOSED>="<-1w>"

Search and replace txt in folder

M-x replace-string RET ; RET C-q C-j. C-q for quoted-insert, C-j is a newline.

Captured On: [2023-10-09 Mon 11:02]

Copy url txt only

With evil

yi[

Profile on emacs

  1. M-x profiler-start and select cpu from the prompt
  2. do the thing that is slow
  3. M-x profiler-stop
  4. M-x profiler-report
  5. Look for the cpu hogs and drill down in to them by hitting TAB on them to find what's slowing down your Emacs.

Captured On: [2023-12-14 Thu 20:08]

Run jshell with org mode

jshell
int a[] = {0,1,3,5,8}
a
a[3] = 42
a

https://emacs-china.org/t/emacs-org-mode-jshell/12491/2

Sort org entries

Use org-sort command 支持按字母、数字、优先级、属性、时间等进行排序

img

Org list support alphabetical

(setq org-list-allow-alphabetical t)

Org hugo add shortcode

Hugo支持短代码形式在生成html时填充模板内容,shortcode配置的html文件放在 /layouts/shortcodes 目录下即可,下面的代码就可以实现在博客中嵌入B站的视频

Hugo也支持 begin_myshortcode 方式进行嵌入,使用中发现这种形式都是要成对出现的,类似html的闭合标签,目前的使用方式就是 代码+参数 ,先记住 export hugo 方式就可以了

Captured On: [2023-01-30 Mon 17:16]

Captured On: [2023-01-30 Mon 17:10]

Batch modify file name in emacs

借助库 dired 即可实现,参照 李杀 的教程

img

git

查看git配置的来源

在正常工作中会针对不同的工作目录设置不同的配置,可以根据以下命令来确认当前仓库使用的配置来源

git config --show-origin --get user.email

删除大于指定大小的仓库信息

迁移仓库时遇到异常,提示镜像文件大于了100M,无法操作,经同事帮助找到此工具,减少仓库信息没得说

bfg --strip-blobs-bigger-than 100M some-big-repo.git

Rebase user info

git rebase -i "commit id"
# pick to edit then save change
git commit --amend --author="{username} <{email}>" --no-edit
git rebase --continue
git push

Migrate code to new origin

git clone --mirror <url_of_old_repo>
git remote add new-origin <url_of_new_repo>
git push new-origin --all

Remove untracked file

git clean -xf

交互式的进行删除

git clean -i

How to clone git repo wiki

add .wiki after repo

clone today_i_learn repo

git clone https://github.com/peng051410/today_i_learn

clone today_i_learn repo wiki

git clone https://github.com/peng051410/today_i_learn.wiki

Create new repo from other existing repo branch

git push new_repo_address +old_repo_branch:master

Captured On: [2023-02-23 Thu 14:22]

Clone single branch

git clone <url> --branch <branch-to-clone> --single-branch [folder-to-store]

https://igorstechnoclub.com/my-everyday-git-commands/

Github

Add profile page to github

https://twitter.com/tomylitoo/status/1580396505118441472 Create a repositoy with name same to github name.

Github emoji shortcode

https://github.com/ikatyang/emoji-cheat-sheet

Get repo starts

wget https://api.github.com/repos/emacs-eaf/eaf-rss-reader/stargazers

Authenticate requests can do more req.

Query config file

Search aerospace config files

Search with path:*aerospace.toml

https://github.com/search?q=path%3A*aerospace.toml&type=code

JAVA

How to judge byte[] is compressed with gzip

private boolean isCompressed(byte[] bytes) {
    if ((bytes == null) || (bytes.length < 2)) {
        return false;
    } else {
        return ((bytes[0] == (byte) (GZIPInputStream.GZIP_MAGIC)) && (bytes[1] == (byte) (GZIPInputStream.GZIP_MAGIC
                >> 8)));
    }
}

Jenv export java_home

jenv enable-plugin export

Iterable to list

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
    <version>4.4</version>
</dependency>

IterableUtils.toList(list);

JVM

Show java program jvm params

jcmd 2886 VM.flags

Why set -XX:NativeMemoryTracking=detail got ative memory tracking is not enabled

Os security, must execute with root java - Why JCMD throws "native memory tracking is not enabled" message even though NMT is enabled? - Stack Overflow

Where is the heap dump file created by jcmd?

Java recommand use jcmd instead of jmap to generate heap file, like:

jcmd 271709 GC.heap_dump Myheapdump.hprof

but, where the generated file?

We can use lsof commd to find the output path

lsof -p pid | grep wd

or genrate with an absolute path

jcmd 271709 GC.heap_dump /data/log/Myheapdump.hprof

https://stackoverflow.com/questions/58519663/where-is-the-heap-dump-file-created-by-jcmd

find jvm thread stack size

java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

https://stackoverflow.com/questions/6020619/where-can-i-find-default-xss-stack-size-value-for-oracle-jvm

show jvm loaded class

jcmd <jvm_pid> VM.classloaders show-classes

https://stackoverflow.com/questions/16559430/get-a-listing-of-all-currently-loaded-classes-in-a-given-jvm-instance

Get two date interval days by java8

Calculate days between two Dates in Java 8 - Stack Overflow

LocalDate today = LocalDate.now()
LocalDate yesterday = today.minusDays(1);
Duration.between(today.atStartOfDay(), yesterday.atStartOfDay()).toDays() // another option

Convert Milliseconds to LocalDateTime

long millis = 1614926594000L; // UTC Fri Mar 05 2021 06:43:14
LocalDate dateTime = Instant.ofEpochMilli(millis)
        .atZone(ZoneId.systemDefault()) // default zone
        .toLocalDate(); // returns actual LocalDate object

Convert LocalDate to Milliseconds

ocalDate dateTime1 = LocalDate.of(2021, 3, 5);
long seconds = dateTime1.atStartOfDay(ZoneId.systemDefault())
        .toEpochSecond(); // returns seconds
long millis1 = seconds * 1000; // seconds to milliseconds

com.google.protobuf.GeneratedMessageV3.isStringEmpty not found

need import protobuf-java dependency

<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java</artifactId>
  <version>3.19.1</version>
</dependency>

Get returntype by aspectj joinpoint

Method method = ((MethodSignature) proceedingJoinPoint.getSignature()).getMethod();
Class<?> returnType = method.getReturnType();

//or
Class<?> returnType1 = ((MethodSignature) proceedingJoinPoint.getSignature()).getReturnType();

SpringFlux+Netty config access log

add netty system param

-Dreactor.netty.http.server.accessLogEnabled=true

config log4j for access log

<RollingFile name="RollingFileAccess"
             fileName="${sys:logPath}/access.log"
             filePattern="${sys:logPath}/access.log.%d{yyyy-MM-dd_HH}.gz">
  <ThresholdFilter level="INFO"/>
  <PatternLayout>
    <pattern>%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n</pattern>
  </PatternLayout>
  <Policies>
    <TimeBasedTriggeringPolicy/>
  </Policies>
</RollingFile>

<Logger name="reactor.netty.http.server.AccessLog" level="info" additivity="false">
  <AppenderRef ref="RollingFileAccess"/>
</Logger>

Difference between Class.this and this in java

Class.this used in nested class to resolved ambiguous

Captured On: [2023-11-17 Fri 16:17]

JDK base module not found

Need add vm options to IDEA

--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED

Captured On: [2023-12-28 Thu 16:44]

Change java.util.logging log level

https://stackoverflow.com/questions/6307648/change-global-setting-for-logger-instances

-Djava.util.logging.config.file="logging.properties"

logging.properties

.level = INFO #global
com.xyz.foo.level = SEVERE

Spring

How to get handleMethod from webflux

  1. inject handleMapping

  2. you got it!

    (HandlerMethod) this.handlerMapping.getHandler(serverWebExchange).toProcessor().peek();

Spring profie effect scope

Profiles affect only bean creation, not method.

Captured On: [2023-11-29 Wed 17:43] I want to transfer a value from config to list, and need to set default value, I don't like two write value keys twice, like this:

@Value("#{'${my.list}'.split(',') : T(java.util.Collections).emptyList()}")

Fortunately, I found a beautiful solution to face it. Thanks SO.

@Value("#{T(java.util.Arrays).asList('${my.list:}')}")
private List<String> list;

KM

How to show km error log

tail -f ~/Library/Logs/Keyboard\ Maestro/Engine.log

Python

python with git

pip3 install GitPython

python with clipboard

pip3 install pyperclip

python urldecode

from urllib.parse import unquote
url = unquote(url)

python with cross-platform home directory

python - What is a cross-platform way to get the home directory? - Stack Overflow

from pathlib import Path
home = str(Path.home())
print(home)

python set to string

s = {'a', 'b'}
str = ', '.join(s)
print(str)

python decimal to binary

https://stackoverflow.com/questions/3528146/convert-decimal-to-binary-in-python

abinary = bin(1024)
print(abinary)

Captured On: [2023-12-05 Tue 19:04]

  1. 安装pyenv
  2. set python globel
  3. 修改alfred命令的python路径

我的alfred插件又可以用了

pyenv install 2.7.18
pyenv global 2.7.18

Brew

get installed program path

(brew --prefix go)

handle rebase-apply error

brew update-reset

Make brew python and pyenv togehter

ln -s $(brew --cellar python)/* ~/.pyenv/versions/

fixed font exists in multiple taps

How can I fix Error: font exists in multiple taps ? · Issue #59227 · Homebrew/homebrew-cask

brew untap caskroom/fonts
brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font

Clean brew cache

brew cleanup -s

Cask adoptopenjdk8 exists in multiple taps

Del homebrew cask rb

rm /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions/Casks/adoptopenjdk8.rb

AdoptOpenJDK/homebrew-openjdk#106 (comment)

Brew install with .rb file

brew install qemu-virgl.rb

Brew tap modify

brew tap knazarov/qemu-virgl
brew edit qemu-virgl

MAC

del macOS Xcode CoreSimulator folder

xcrun simctl delete unavailable

Brew mysql install connect issue

因为有老的mysql数据没有清理完全,执行完以下操作后,重新安装即可

sudo rm -rf /usr/local/var/mysql

Mount/unmount smbs

sudo mount -t smbfs '//vagrant:vagrant@localhost:10139/kernel-source' /Volumes
unmont kernel-source

Get running app

osascript -e 'tell application "System Events" to get name of (processes where background only is false)'

Reset macos accessibility

sudo tccutil reset Accessibility

Find app url schema

  1. go to /Application folder
  2. find target app
  3. show package contents
  4. oppen info.plist
  5. search CFBundleURLSchemes

img

Mac dictionary file path

/System/Library/AssetsV2/com_apple_MobileAsset_DictionaryServices_dictionaryOSX

Find ios app data path

open ~/Library/Containers/appNames

Show lunar day in Calendar app

img

Add debug info to app

Add -_NS_4445425547 YES param to app

Linux

Change default program

update-alternatives --set java java-11-openjdk.x86_64

You can issue java path by

update-alternatives --config java

SSH passwordless with public key authentication

Generate key from host

ssh-keygen -t rsa

Scp to dest machine

scp .ssh/id_rsa.pub user@host:.

Add pub key to dest machine auth key

cat id_rsa.pub >> .ssh/authorized_keys

Man with color

Colored `man` pages on OSX

man() {
    env \
        LESS_TERMCAP_mb=$(printf "\e[1;31m") \
        LESS_TERMCAP_md=$(printf "\e[1;31m") \
        LESS_TERMCAP_me=$(printf "\e[0m") \
        LESS_TERMCAP_se=$(printf "\e[0m") \
        LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
        LESS_TERMCAP_ue=$(printf "\e[0m") \
        LESS_TERMCAP_us=$(printf "\e[1;32m") \
        man "$@"
}

Config linux ssh with rsa login

Captured On: [2023-10-24 Tue 10:33]

Show glibc version

ls -l /lib/libc.so.*

Mysql

Show db table create/update time

select table_name, create_time, update_time
from information_schema.TABLES
where information_schema.TABLES.TABLE_SCHEMA = 'yw_cooperate_oppo' and information_schema.TABLES.TABLE_NAME = 'book_mrg';
show table status like 'book_mrg';

Query db size

data size with M.

select table_schema as database_name,
       table_name,
       round(1.0*data_length/1024/1024, 2) as data_size,
       round(index_length/1024/1024, 2) as index_size,
       round((data_length + index_length)/1024/1024, 2) as total_size
from information_schema.tables
where table_schema not in('information_schema', 'mysql',
                          'sys', 'performance_schema')
      -- and table_schema = 'your database name'
order by total_size desc;

https://dataedo.com/kb/query/mysql/list-of-tables-by-the-size-of-data-and-indexes

Partition table

alter table `ugc_ent` PARTITION BY RANGE (TO_DAYS(create_time)) (
  PARTITION p20240210 VALUES LESS THAN (TO_DAYS('2024-02-10')) ENGINE = InnoDB
)

Captured On: [2024-01-08 Mon 16:41]

Change primary key

alter table `ugc_comment` drop primary key, add primary key(`comment_id`,`create_time`);

IDEA

Use alt key quickly on commit window

Alt+i not work, need to use Alt+Ctrl+i

Rm unused code

Just use Analyze | Inspect Code with appropriate inspection enabled (Unused declaration under Declaration redundancy group).

Convert vvt to srt

ffmpeg -i in.vvt out.srt

Save video part stuff

截取视频的特定时间的内容

JACKSON

JsonNode to class

MyClass newJsonNode = jsonObjectMapper.treeToValue(someJsonNode, MyClass.class);

Json to Map

String jsonInput = "{\"key\": \"value\"}";
TypeReference<HashMap<String, String>> typeRef
  = new TypeReference<HashMap<String, String>>() {};
Map<String, String> map = mapper.readValue(jsonInput, typeRef);

Unwarp map

java - Jackson HashMap, ignore map name when writing to String - Stack Overflow

private Map<String, TaskStatusDTO> taskMap;

@JsonAnySetter
public void setTaskMap(String key, TaskStatusDTO value) {
    this.taskMap.put(key, value);
}

@JsonAnyGetter
public Map<String, TaskStatusDTO> getTaskMap() {
    return taskMap;
}

Redis

Batch del key

redis-cli keys "*match" | xargs redis-cli del

Find big key

redis-cli --bigkeys

Set pass

config set requirepass p@ss$12E45

This will be invalid when redis server restart, for permanently valid set in redis.conf

get generated rdb file location

redis-cli config get dir

https://stackoverflow.com/questions/57790483/where-is-redis-installed-on-macos

Read rdb file with hunman readability

od -A x -t x1c -v dump.rdb

Nginx

underscore header issue

Must set underscores_in_headers to tell nginx not drop it.

underscores_in_headers on

apache - Why do HTTP servers forbid underscores in HTTP header names - Stack Overflow

Wexin develop

JS

Get table td content

var table = document.getElementById("mytable");
var rows = table.rows;//获取所有行
console.log("lenth",rows.length) //
for(var i=1; i < rows.length; i++){
  var row = rows[i];//获取每一行
  var id = row.cells[1].innerHTML;//获取具体单元格
  console.log(id)
}

VIM

indent code

= indicate indent

gg
=G

Captured On: [2023-05-18 Thu 19:22]

GCC

Compile c program to assembly language

gcc -S helloworld.c

After run this command, a new file named helloworld.s prevent.

NPM

sh: react-scripts: command not found after running npm start

Project need install dependency package

npm install

Captured On: [2023-06-09 Fri 14:06]

GO

Go compile to assembly language

go build -gcflags=-S main.go

golang/go#58629

https://colobu.com/2018/12/29/get-assembly-output-for-go-programs/

VSCode

Setting go for workspace

https://townsyio.medium.com/how-to-configure-your-go-modules-proxy-in-vscode-fa41f29192fe

  1. run "open setting workspace (json)" command in VSCode

  2. add config

    { "go.toolsEnvVars": { "GOPRIVATE": "townsy.private-github.com", "GOPROXY": "https://athens-proxy.townsy.io", "GONOPROXY": "none;", "GONOSUMDB": "townsy.private-github.com" }, "terminal.integrated.env.linux": { "GOPRIVATE": "townsy.private-github.com", "GOPROXY": "https://athens-proxy.townsy.io", "GONOPROXY": "none;", "GONOSUMDB": "townsy.private-github.com" } }

Pandoc

convert md to docx

pandoc -o output.docx -f markdown -t docx filename.md

Xcode

Captured On: [2023-10-30 Mon 20:12]

xcode-select --install # Install Command Line Tools if you haven't already.
sudo xcode-select --switch /Library/Developer/CommandLineTools # Enable command line tools
# Change the path if you installed Xcode somewhere else.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Chrome

Captured On: [2023-10-31 Tue 11:48]

Close QUIC

  1. chrome://flags/#enable-quic
  2. Experimental QUIC protocol to Disabled

Firfox

Get current tabe url from terminal

osascript -e  'tell application "System Events" to get value of UI element 1 of combo box 1 of toolbar "Navigation" of first group of front window of application process "Firefox"'

https://apple.stackexchange.com/questions/404841/get-url-of-opened-firefox-tabs-from-terminal

Anki

Captured On: [2023-11-22 Wed 11:20]

<iframe width="560" height="315" src="https://www.youtube.com/embed/dmcfsEEogxs?start=30" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Arthas

Modify java file and reload

jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.java

mc /tmp/UserController.java -d /tmp

retransform /tmp/com/example/demo/arthas/user/UserController.class

Captured On: [2023-12-12 Tue 17:22]

Twitter

Search user hot tweets

from:baibanbaonet min_faves:10

Logseq

Install local plugin

Place unpacked plugin folder under ~/.logseq/plugins ,then restart logseq

MAT

Install mat on mac arch m2

版本:Eclipse Memory Analyzer Version 1.15.0,需要JDK17以上版本

打开访达 -> 应用程序 -> 找到mat【右键点击 “显示包内容”】 -> 找到info.plist文件,在其dict节点内,追加下列环境变量:

<string>-vm</string>
<string>/Users/tomyli/.sdkman/candidates/java/17.0.9-jbr/bin</string>

System

Use vcpkg in clion

In clion setting -> CMake options, Add

-DCMAKE_TOOLCHAIN_FILE=[vcpkg root]/scripts/buildsystems/vcpkg.cmake

https://www.cnblogs.com/lancediarmuid/p/17333985.html

Make file rule

prerequisites中如果有一个以上的文件比target文件要新的话,command所定义的命令就会被执行。这就是Makefile的规则

https://blog.csdn.net/haoel/article/details/2886

Clion

Disable clang errors to fixed unknown typename

Go to: Languages & Frameworks -> Clangd Disabled "Show errors and warnings from clangd"

img

img

C

Use compat memory allocate

struct __attribute__ ((__packed__)) sdshdr8 {};

AI

Update all ollama models

ollama list | tail -n +2 | awk '{print $1}' | while read -r model; do
  ollama pull $model
done

ollama/ollama#1890

Releases

No releases published

Packages

No packages published

Languages