Skip to content

Instantly share code, notes, and snippets.

View shukebeta's full-sized avatar
🎯
Focusing

David Wei shukebeta

🎯
Focusing
View GitHub Profile
@shukebeta
shukebeta / replace.sh
Created April 16, 2024 01:35
Replace specific string with another string in a directory
#!/bin/bash
# Check if the required arguments are provided
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: $0 <directory> <target_string> [<replacement_string>]"
exit 1
fi
# Assign arguments to variables
directory="$1"
@shukebeta
shukebeta / custom.ad.block.txt
Created October 8, 2020 01:48
my custom ad blocker list
# ximalaya vip check
127.0.0.1 mwsa.ximalaya.com
@shukebeta
shukebeta / markdown_in_nginx.md
Created August 11, 2020 05:55 — forked from H2NCH2COOH/markdown_in_nginx.md
Markdown in Nginx

Markdown in Nginx

Nginx config

location ~ /.*\.md {
    root /www/;
    default_type text/html;
    charset UTF-8;
    add_before_body /strapdown/prepend;

add_after_body /strapdown/postpend;

@shukebeta
shukebeta / Model.tmpl.sql
Last active August 11, 2020 02:10 — forked from pdwetz/gist:5368441
Outputs a POCO for a given MySql table. Based on http://stackoverflow.com/a/13918084/21865 with mild formatting changes and additional types added.
select '%TABLE_NAME%'
into @table;
select '%DB_NAME%'
into @schema;
select concat(' public class ', @table)
union
select ' {'
union
select concat(' public ', tps.dest, ' ', column_name, ' { get; set; }')
@shukebeta
shukebeta / TextEncryption.cs
Last active September 27, 2021 08:07
a short & complete class for text encryption, grapped from https://stackoverflow.com/questions/165808/simple-insecure-two-way-data-obfuscation#comment1320154_212707 in Ashkan Sirous' answer
using System;
using System.Security.Cryptography;
using System.Text;
namespace xxx.ClassLibrary
{
public static class TextEncryption
{
private static TripleDESCryptoServiceProvider GetCryproProvider(string keyStr)
{
@shukebeta
shukebeta / g
Created June 17, 2020 11:49
g for grep, s for substitute. One script, two functions. Download this file then `ln -s g s`
#!/bin/bash
#set -ex
# 搜索关键字要么不用引号包裹,要么使用双引号包裹。请不要使用单引号包裹
pname=`basename $0`
if [ $pname = "g" -a $# -lt 1 ];then
echo "Usage: $pname 'keyword' [-i]"
exit
fi
@shukebeta
shukebeta / mysql_secure.sh
Last active June 9, 2020 05:14 — forked from coderua/mysql_secure.sh
This is a CentOS8 version for MySQL8
#!/bin/bash
#
# Automate mysql secure installation for Redhat/CentOS systems
#
# - You can set a password for root accounts.
# - You can remove root accounts that are accessible from outside the local host.
# - You can remove anonymous-user accounts.
# - You can remove the test database (which by default can be accessed by all users, even anonymous users),
# and privileges that permit anyone to access databases with names that start with test_.
@shukebeta
shukebeta / .vimrc
Last active June 22, 2020 10:50
my .vimrc
"curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
set nocompatible
let g:XkbSwitchEnabled = 1
let g:XkbSwitchLib = '/usr/local/lib/libg3kbswitch.so'
function! BuildComposer(info)
if a:info.status != 'unchanged' || a:info.force
if has('nvim')
@shukebeta
shukebeta / g
Created May 20, 2020 02:41
one script supports both grep and substitute. download this file and save it to your bin dir then run `ln -s ~/bin/g ~/bin/s`
#!/bin/bash
#set -ex
pname=`basename $0`
if [ $pname = "g" -a $# -lt 1 ];then
echo "Usage: $pname 'keyword' [-i]"
exit
fi
if [ $pname = "s" -a $# -lt 3 ];then
@shukebeta
shukebeta / import-user-secrets.php
Last active March 15, 2020 04:38
We sometimes need to import user-secrets from one project to another, especially in the same solution. Though it may be not a good practice, requirements are requirements.
#!/usr/bin/php
<?php
if (sizeof($_SERVER['argv']) != 3) {
exit("Usage: {$_SERVER['argv'][0]} from_project_path to_project_path");
}
$pwd = getcwd();
if (!chdir($_SERVER['argv'][1])) {
exit("cd {$_SERVER['argv'][1]} failed");
}