Coder Social home page Coder Social logo

dzyong / misc Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.88 MB

Shell 2.70% Emacs Lisp 10.91% Lua 1.68% Makefile 0.05% C 0.59% C++ 5.95% Python 7.12% Vim Script 62.70% Jupyter Notebook 7.91% Go 0.27% HTML 0.11% CSS 0.01% JavaScript 0.01%

misc's Introduction

misc stuff

misc's People

Contributors

dangsiper avatar dzyong avatar

Watchers

 avatar  avatar

misc's Issues

Script

Bash:
gpg-connect-agent /bye
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
if [ ! -S $(realpath $HOME/.ssh/agent.sock) ]; then
  ln -s -f ${SSH_AUTH_SOCK} $HOME/.ssh/agent.sock
fi
SSH_AUTH_SOCK="$HOME/.ssh/agent.sock"
:<<COMMENT
SSH_AGENT_ENV="/tmp/.${USER}@${HOSTNAME}.ssh-agent"
if [ -z ${SSH_AUTH_SOCK} ];then
    pgrep -U ${UID} ssh-agent
    if [ $? -ne 0 ];then
        ssh-agent > ${SSH_AGENT_ENV}
    fi
    if [ ! -e ${SSH_AGENT_ENV} ];then
        ssh-agent > ${SSH_AGENT_ENV}
    fi
    source ${SSH_AGENT_ENV}
fi
if [ ! -e "/proc/${SSH_AGENT_PID}/maps" ];then
    ssh-agent > ${SSH_AGENT_ENV}
    source ${SSH_AGENT_ENV}
fi
if [ ! -e ${SSH_AUTH_SOCK} ];then
    if [ -e "/proc/${SSH_AGENT_PID}/maps" ];then
        ssh-agent -k
    else
        pkill -U ${UID} ssh-agent
    fi
    ssh-agent > ${SSH_AGENT_ENV}
    source ${SSH_AGENT_ENV}
fi
COMMENT

PS1="\e[31m${debian_chroot:+($debian_chroot)}\u@\h:\w\e[0m\n\$ "

auto commit:
#!/usr/bin/env bash

function git_commit() {
  git pull --rebase
  if [ $? -ne 0 ];then
    exit
  fi
  git add .
  git commit -m "auto commit"
  if [ $? -eq 0 ];then
    git push
  fi
}

PROJECTPATH=.
COMMITCYCLE=60
if [ $# -gt 0 ];then
  PROJECTPATH=$1
fi
if [ $# -gt 1 ];then
  COMMITCYCLE=$2
fi
cd ${PROJECTPATH}
if [ ! -d .git ];then
  echo "Not git repo"
  exit 128
fi
trap "git_commit;exit" SIGINT
trap "git_commit" SIGHUP

while true;do
  git_commit
  sleep ${COMMITCYCLE}m
done

DISPLAY=localhost:0.0 ssh -CAXY <user>@<ip1> -D 7071 -R 5555:<ip2>:5555 -R 9999:<ip3>:9999

tf=`mktemp`;find|xargs md5sum 2>/dev/null > ${tf};IFS=$'\n';lf="";for i in `cat ${tf}|sort|awk '{print $2" "$1}'|uniq -f 1 -D`;do name=${i% *};hash=${i##* };if [ "${lf}" != ${hash} ];then lf=${hash};else rm -rf $name;fi;done;unset $IFS;rm -rf ${tf}

.ssh/config:
Host *
    Compression yes
    ServerAliveInterval 10
    ServerAliveCountMax 6
    AddKeysToAgent yes
    ForwardAgent yes
    User xyz
    Hostname baidu.com
    IdentityFile ~/.ssh/xyz
    ForwardX11 yes
    Port 29418
    CheckHostIP no
    GatewayPorts yes
    RemoteForward 2222 127.0.0.1:2222
    LocalForward 2222 localhost:2222

nohup bash -c "while true;do ssh -CAXY <user>@<ip> -R 2222:<inter IP>:22 -N;sleep 60;done" > /dev/null&

nano:
include "~/.local/share/nano/*.nanorc"
set suspend

vim:
shell:
mkdir -p ~/.vim/bundle
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
.vimrc:
if filereadable(expand("~/.vim/plugin.vim"))
  source ~/.vim/plugin.vim
endif
plugin.vim:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'Valloric/YouCompleteMe'
call vundle#end()
let g:ycm_confirm_extra_conf = 0
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
vim:
:PluginInstall
shell:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clangd-completer
.ycm_extra_conf.py:
def Settings( **kwargs ):
  return {
    'flags': [
      '-Wall',
      '-Werror',
      '-std=c++11',
      '-isystem',
      '/usr/include',
      '-isystem',
      '/usr/local/include',
      '-isystem',
      '/usr/include/c++/5',
      '-isystem',
      '/usr/include/x86_64-linux-gnu/c++/5'
    ]
  }

sync:
inotifywait -mrq -e modify,create,delete,move --format '%Xe %w%f' .
rsync -z

tmux:
set -g history-limit 100000
set -g mode-keys vi
set -ag status-right " #{pane_pid}"
set -g update-environment "SSH_AUTH_SOCK"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.