Skip to content

Instantly share code, notes, and snippets.

@ppdouble
ppdouble / find_char_in_jars.sh
Last active April 28, 2023 08:55
find specific characters in jar files
# the paths of jar files are listed in a text file named "files"
find $(cat files) -print -exec zipgrep "the-characters-needed-to-be-searched" '{}' \;
# search jar files recursively in path the-folder-path
find the-folder-path -name "*.jar" | xargs -I{} sh -c 'echo searching in "{}"; zipgrep "the-characters-needed-to-be-searched" {}'
@ppdouble
ppdouble / curlPOST.sh
Last active April 14, 2023 09:55
curl POST pass payload via JSON file
curl -vX POST 127.0.0.1:8888/my/api?para1=123 -H 'Content-Type: application/json' -d @/home/path/to/mydata.json
# mydata.json
# {
# "para": "m",
# "data": {
# "d1": "111",
# "d2": "222"
# }
# }
@ppdouble
ppdouble / search_strings.sh
Last active December 8, 2022 07:21
search files which contains a specific string
grep -nr --include '*.cpp' "Aggregated" ./source
find ./source -type f -print0 | xargs -0 grep -rHinbo "AggregatedDiscoveryService.StreamAggregatedResources"
find ./source -type f -print0 | xargs -0 grep -rHino "AggregatedDiscoveryService.StreamAggregatedResources"
find ./source -type f -print0 | xargs -0 grep -n "AggregatedDiscoveryService.StreamAggregatedResources"
find ./source -type f -print0 | xargs -0 grep "ads.pb.h"
@ppdouble
ppdouble / highlight-sample.sh
Created December 6, 2022 18:43
Highlight log information using awk. Match format like: xxxx [debug] xxxxx xxxx xxxx
black=30m
red=31m
green=32m
yellow=33m
blue=34m
magenta=35m
cyan=36m
white=37m
blacklog="\"\033[$black\" \$0 \"\033[39m\""
@ppdouble
ppdouble / docker_run_neo4j.sh
Created April 29, 2022 15:35
Neo4j in docker
CUSTOMIZE_FOLDER=/home/software/neo4j/mygraphdb/
docker run \
--name mygraphdb \
--publish=7474:7474 --publish=7687:7687 \
--detach \
--volume=$CUSTOMIZE_FOLDER/data:/data \
--volume=$CUSTOMIZE_FOLDER/conf:/var/lib/neo4j/conf \
--volume=$CUSTOMIZE_FOLDER/logs:/logs \
--volume=$CUSTOMIZE_FOLDER/import:/import \
--volume=$CUSTOMIZE_FOLDER/plugins:/plugins \
@ppdouble
ppdouble / webcam_capture.cpp
Created September 4, 2021 09:45 — forked from mik30s/webcam_capture.cpp
Simple C++ program to capture a webcam frame in Linux
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/v4l2-common.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <fcntl.h>
#include <unistd.h>
@ppdouble
ppdouble / printcolorsinbash.sh
Created September 4, 2021 08:48
Shell 中输出带颜色的文本
#!/bin/bash
# 打印所有的颜色和颜色代码
# 在 fedora 上 gnome-terminal 3.30.1 中已测试
printf "\e\033[4;31m 浅 色\033[0m \t\t\033[1;4;31m 深 色\033[0m\n"
printf "\e[0;30;47m 黑 \e[0m 0;30m \t\e[1;30;40m 深 灰 \e[0m 1;30m\n"
printf "\e[0;31;47m 红 \e[0m 0;31m \t\e[1;31;40m 深 红 \e[0m 1;31m\n"
printf "\e[0;32;47m 绿 \e[0m 0;32m \t\e[1;32;40m 深 绿 \e[0m 1;32m\n"
printf "\e[0;33;47m 黄 \e[0m 0;33m \t\e[1;33;40m 亮 黄 \e[0m 1;33m\n"
@ppdouble
ppdouble / textonemptyplot-label4lines.R
Last active July 8, 2018 03:49
Show text on an empty plot. 画图的时候把文本显示在指定位置。Add label to lines instead of legend when plotting. 不使用 legend, 给所画的线加上标签。
dev.new()
par(mfrow=c(1,2))
# Add label to lines instead of legend when plotting.
plot(1:100, 1:100,xaxt="n",yaxt="n",bty="n",pch="",ylab="",xlab="", main="", sub="")
lines(1:20, rep(2,20), col="blue")
text(x=mean(c(1:20)), y=2, labels=sprintf("%d", 1), col="blue")
lines(1:10, 1:10, col="red")
text(x=100, y=100, pos=1, labels=sprintf("%d", 21), col="red")
text(x=100, y=100, pos=2, labels=sprintf("%d", 22), col="red")
@ppdouble
ppdouble / update_gfwlist.sh
Created November 15, 2016 12:39 — forked from VincentSit/update_gfwlist.sh
Automatically update the PAC for ShadowsocksX. Only tested on OS X.
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
#
# Example usage
#
# ./whatever-you-name-this.sh
#
# Task Scheduling (Optional)
I came across this issue using the following code file
the error message is ReferenceError: weakly-referenced object no longer exists
reason is in the mysql/connector/cursor.py file
see these lines:
def _set_connection(self, connection):
"""Set the connection"""
try: