Skip to content

Instantly share code, notes, and snippets.

@yelban
yelban / script.sh
Created November 10, 2024 06:54
A bash script for recursively finding and replacing text in files while respecting directory exclusions. Specially optimized for macOS with UTF-8 support.
#!/bin/bash
# 遞迴搜尋並取代字串,支援預設排除目錄與預覽模式
# 使用方式: ./script.sh [-p|--preview] "要尋找的字串" "要替換的字串"
# 預設排除的目錄清單
DEFAULT_EXCLUDES=(
"node_modules"
".git"
".next"
"dist"
@yelban
yelban / ss.sh
Created November 10, 2024 06:11
File content search utility: recursive search, default ignores (node_modules/.git/.next), colorized output, line numbers, and match statistics
#!/bin/bash
# 顯示使用說明
usage() {
echo "使用方法: $0 [-d 目錄] [-i] [-e 排除目錄] 搜尋字串"
echo "選項:"
echo " -d 指定搜尋目錄 (預設: 當前目錄)"
echo " -i 忽略大小寫"
echo " -e 額外排除的目錄 (用逗號分隔)"
echo " -a 顯示所有目錄 (不使用預設排除清單)"
<script type="text/javascript">
function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
@yelban
yelban / addmysqluser.sh
Created November 10, 2024 05:08 — forked from nateflink/addmysqluser.sh
A bash script that adds a mysql user, and creates a database with the same name as the user and echos the generated password
#!/bin/bash
#By Nate Flink
# Adds a mysql user, and creates a database with the same name as the user and echos the generated password
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: ./$0 [mysql db username] [mysql user password] [new identifier] [optional password]"
exit 1
fi
#!/bin/bash
#by Nate Flink
mysqldump -u $2 -p$3 --extended-insert=false -h $4 $1 > $5
MINSIZE=3
ACTSIZE=$(du -k $5 | cut -f 1)
if [ $ACTSIZE -le $MINSIZE ]; then
echo "Error: the database backup is ${ACTSIZE} kilobytes, needs to be at least ${MINSIZE}"
exit 1
#!/bin/bash
#By Nate Flink
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "Usage: ./$0 [path to files] [find string] [replace string]"
exit 1
fi
DIRPATH=$1
FIND=$2
#!/bin/bash
#By Nate Flink
#Invoke on the terminal like this
#curl -s https://gist.github.com/nateflink/9056302/raw/findreplaceosx.sh | bash -s "find-a-url.com" "replace-a-url.com"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ./$0 [find string] [replace string]"
exit 1
fi
@yelban
yelban / bitwarden_duplicate_cleaner.py
Created February 22, 2024 08:51 — forked from jwmcgettigan/bitwarden_duplicate_cleaner.py
Identifies and removes duplicate 'items' and 'folders' from your Bitwarden vault. 🎃
#!/usr/bin/env python3
# Copyright © 2023 Justin McGettigan
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the “Software”), to deal in the Software without
# restriction, including without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@yelban
yelban / gist:693be4fff2813cba997f8b0da5462464
Created February 7, 2023 01:58 — forked from JT5D/gist:a2fdfefa80124a06f5a9
Google translate language codes
Eg. URL translating en page to es
http://translate.google.com/translate?hl=en&sl=en&tl=es&u=http://about.com
Define the web interface language to be English by adding
hl=en to the end of the URL and after the change the URL will look
like this:
http://www.google.com/search?hl=en
When you use more than one setting code in the URL, you need to use
@yelban
yelban / For Mac 4.2.6 unlimited trial.md
Created December 8, 2022 01:58 — forked from rise-worlds/For Mac 4.2.6 unlimited trial.md
Beyond Compare 4 license for Windows, Mac, Linux

for 4.2.4 or higher,4.2.5,4.2.6,4.3.7,it's works , this is the way which makes Always in evaluation mode 。

  1. open Terminal, go to the dir : cd /Applications/Beyond Compare.app/Contents/MacOS
  2. change the name BCompare to BCompare.bak: mv BCompare BCompare.bak
  3. touch a file name BCompare , and chmod a+u BCompare : touch BCompare && chmod a+u BCompare
  4. open BCompare with text editor, insert the script :
#!/bin/bash
rm "/Users/$(whoami)/Library/Application Support/Beyond Compare/registry.dat"
"`dirname "$0"`"/BCompare.bak $@