• 2020-02-20

    Docker镜像常用操作

    Views: 8185 | 1 Comment

    Docker 导出镜像:

    docker export container_id -o abc.tar
    docker import abc.tar rep:tag
    

    image 只能用 import 导入, 不能用 load 导入. image 不包含 docker 的配置文件? 例如用哪个用户登录?

    减少镜像体积

    启动一个新的 container, 在 container 内删除数据, export(体积变大), 然后 import(体积变小).

    保存运行中的 container:

    docker commit $container_id repo_name
    docker save repo_name_or_tag -o abc-i.tar
    docker load -i abc-i.tar
    

    tag 和 untag

    docker tag $TAG $repo:$tag
    docker rmi $image_id
    

    用某个用户运行镜像, 登录后进入某个目录. 相当于用哪个用户登录虚拟机.

    docker run -it -v ~/Works:/root/work -p 22:22 --workdir /root --hostname dev --name dev dev bash
    

    重启容器

    docker start $container
    
    Posted by ideawu at 2020-02-20 20:06:05
  • 2015-09-18

    MySQL binlog查看和清理

    Views: 17063 | No Comments

    显示 binlog 文件列表

    show binary logs;
    

    清理 binlog 文件

    purge binary logs to 'mysql-bin.000001';
    

    查看 binlog 内容

    show binlog events in 'mysql-bin.000001' limit 1000, 10;
    

    或者SHELL命令行

    sudo mysqlbinlog mysql-bin.000001
    
    Posted by ideawu at 2015-09-18 17:08:42 Tags:
  • 2015-03-06

    清除Xcode静态链接库中的路径信息

    Views: 20679 | 1 Comment

    默认用 Xcode 生成的静态链接库(.a)文件中, 会带有路径信息, 如 /Users/youname/path 等等, 事实上, 这些其实是调试信息. 但是, 这些信息暴露了你的系统信息, 包括你的用户名, 你的文件目录结构, 等等.

    如果你想清除这些信息, 可以这样做:

    [ref]
    In LLVM code generation, set Generate debug symbols to No and Symbols hidden by default to Yes. For some reason, even if you tell it to strip symbols, it's not going to do it unless these are set.

    Posted by ideawu at 2015-03-06 11:59:54 Tags: ,
  • 2015-02-28

    Nginx 限速模块简单配置

    Views: 18824 | No Comments

    Nginx 的限速模块, 也即 ngx_http_limit_req_module.

    http {
        limit_req_zone $binary_remote_addr zone=zone_1rps:10m rate=1r/s;
        limit_req_zone $binary_remote_addr zone=zone_3rps:10m rate=3r/s;
        limit_req_zone $binary_remote_addr zone=zone_5rps:10m rate=5r/s;
    
        server {
            location ~ ^/index.php$ {
                limit_req_status 403;
                limit_req zone=zone_1rps burst=5;
            }
        }
    }
    
    Posted by ideawu at 2015-02-28 15:52:28 Tags:
  • 2015-02-25

    TextMate 2 常用配置

    Views: 24336 | No Comments

    修改主题:

    菜单 - View - Theme

    修改字体(不包括颜色):

    菜单 - View - Font - Show Fonts

    修改字体颜色:

    Bundles - Edit Bundles... - Theme 然后选中你要修改的主题

    Posted by ideawu at 2015-02-25 15:47:49 Tags:
  • 2013-11-07

    git 常用操作

    Views: 21458 | 1 Comment

    创建分支

    git branch abc
    

    切换分支

    # 本地
    git checkout abc
    # 远端
    git fetch
    git checkout abc
    或者
    git branch abc origin/abc
    

    删除分支(本地)

    git branch -d abc
    

    删除服务器上的分支(远端)

    #git push origin :abc
    #或
    #git push origin --delete abc
    然后, 其它人必须调用 git fetch -p 同步状态
    

    合并分支到主干

    git checkout master
    git pull
    git merge --no-ff abc
    

    对比分支

    git diff master abc
    

    列出远程分支

    git branch -a
    

    修改 commit log

    git commit --amend
    

    查看文件变动历史

    git log --name-status
    

    git 回滚

    # 查看历史
    git log
    git reset --hard comit_id
    git push -f origin branch_name
    

    如果遇到类似 "The requested URL returned error: 401 Unauthorized while accessing" 的错误提示.

    Instead of:
    git clone https://github.com/org/project.git
    do:
    git clone https://username@github.com/org/project.git
    or
    git clone https://username:password@github.com/org/project.git
    

    git diff 忽略掉新文件

    --diff-filter=M
    

    分支覆盖

    用 dev 分支覆盖 master 分支(删除 master, 然后重建).

    git checkout dev
    git merge --strategy=ours master    # keep the content of this branch, but record a merge
    git checkout master
    git merge dev             # fast-forward master up to the merge
    

    git tag

    git tag abc
    git push origin abc
    
    git tag -d abc
    git push origin :refs/tags/abc
    

    git log

    git log
    git log -p file
    

    git diff

    git diff origin/master
    git diff commit_1 commit_2 file
    

    清除密码保存

    # 明文保存密码
    git config credential.helper store
    # macOS 保存密码
    git config credential.helper osxkeychain
    
    Posted by ideawu at 2013-11-07 13:39:48 Tags:
|<<<123456789>>>| 1/15 Pages, 86 Results.