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 / README.md
Created December 7, 2017 01:44 — forked from brandt/README.md
Creates a loopback alias with IP 127.0.0.2 at startup on Mac OS X

Loopback Alias

Creates an alias on the loopback interface (lo0) with the IP 127.0.0.2 on macOS.

Installation

  1. Install the plist to: /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  2. Set mode: sudo chmod 0644 /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  3. Set owner: sudo chown root:wheel /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
  4. Load: sudo launchctl load /Library/LaunchDaemons/com.runlevel1.lo0.127.0.0.2.plist
@shukebeta
shukebeta / git.md
Last active March 20, 2024 08:57 — forked from suziewong/git.md
github的多人协作?how to 贡献代码?

github的多人协作

在 github 上,用别人的代码,直接 git clone 。可是如何把你的改进贡献出去回馈社会,就没那么多人会了。 这篇文章尝试解决这一问题。

Fork

从别人的项目中fork一个到你自己的仓库 这个时候这个仓库就是你的了,要删除这个仓库到设置-admin 那里,像你删除你自己创建的repo一样删除,(因为这个库就是你的了,你现在可以任意修改这个库,除非你pull request被接受否则你 不会对原作者的库产生任何影响)

@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");
}
@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 / .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 / 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 / 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 / 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 / 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 / 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;