This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if both parameters are provided | |
if [ $# -ne 2 ]; then | |
echo "Usage: $0 <target_directory> <comma_separated_word_list>" | |
exit 1 | |
fi | |
target_dir="$1" | |
word_list=$(echo "$2" | tr ',' ' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to print usage | |
print_usage() { | |
echo "Usage: $0 <github-repo> [branch]" | |
echo "Example: $0 go-gorm/gorm main" | |
echo "If branch is not specified, 'master' will be used as default." | |
} | |
# Check if at least a repository is provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package attachable | |
import ( | |
"fmt" | |
"strings" | |
"sync" | |
) | |
// valuesAttached is a concurrent map to store values associated with pointer instances | |
var valuesAttached = sync.Map{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PDF to Image Grid Conversion | |
magick convert -density 150 "your-pdf.pdf" -alpha remove -alpha off -background white -resize 1000x page_%d.png | |
magick montage page_*.png -tile 3x3 -geometry 1000x+10+10 -background gray output.png | |
# Some fun ... | |
magick convert -density 150 "your-pdf.pdf" -resize 1000x page_%d.png | |
magick convert -density 150 "your-pdf.pdf" -background white -resize 1000x -flatten output.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MustConvertType converts an instance of type A to type B using JSON marshal and unmarshal. | |
// Both types A and B should have the same structure and JSON tags. | |
// In case of error, it panics. | |
func MustConvertType[A any, B any](input A) B { | |
var output B | |
// Marshal the input type A to JSON | |
data, err := json.Marshal(input) | |
if err != nil { | |
panic(fmt.Errorf("failed to marshal input: %w", err)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"net" | |
"net/http" | |
"net/url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"github.com/golang/glog" | |
"github.com/spf13/cobra" | |
"github.com/spf13/pflag" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias setp="export http_proxy=127.0.0.1:1087 && export https_proxy=127.0.0.1:1087" | |
alias unsetp="export http_proxy= && export https_proxy=" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# crontab: | |
# 30 */8 * * * /root/backup/mysql.sh | |
databases=(db1 db2 db3) | |
basepath='/root/backup/mysql/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 如果$_REQUEST中出现可能导致sql注入的字符,就返回400。 | |
* 需要在程序一开始的时候就运行。 | |
* | |
* 注意:本方法只对默认的html表单类型(application/x-www-form-urlencoded)有效 | |
* 如果有文件上传类型的(enctype="multipart/form-data"),则不能执行本方法 | |
*/ | |
function guardAgainstBadCharactersInRequest() |
NewerOlder