wupanhao / wupanhao.github.io

10 stars 3 forks source link

Some useful scripts #3

Open wupanhao opened 7 years ago

wupanhao commented 7 years ago

powershell 禁止运行脚本

set-executionpolicy remotesigned

https://gist.github.com/Lewiscowles1986/fecd4de0b45b2029c390#file-rpi3-ap-setup-sh

https://github.com/doraemonext/wechat-python-sdk

前端书籍整理

https://www.gitbook.com/book/mnichangxin/fe-book/details

我的新浪博客

http://weibo.com/u/3478765953?refer_flag=1005055010_&is_all=1

python打印

pip install python-escpos pip install pyusb 树莓派只需要者两项就可以了 香橙派貌似还需要 apt-get install python-dev && pip install Pillow 或 apt-get install python-imaging

挂载网络文件夹

#mount -t nfs 172.16.188.50:/home/hao /root/hao -o proto=tcp -o nolock
#mount -t cifs -o username="hao",password="hao123789" //172.16.188.50/Hao /mnt

nfs server

vim /etc/exports
/home/hao   *(rw,sync,no_subtree_check,all_squash,anonuid=1000,anongid=1000)

samba server

vim /etc/samba/smb.conf
[Hao]
path = /home/hao
read only = no
valid users = hao
sudo smbpasswd -a hao

lubuntu远程桌面

sudo apt-get install xrdp
vim /etc/xrdp/startwm.sh
. /etc/X11/Xsession
vim ~/.xsession
lxsession -e LXDE -s Lubuntu

docker删除所有容器(慎用)

docker ps -a | awk '{print $1}' | xargs docker rm

docker启动特殊容器

docker run -idt --name="xiaobai2" --privileged --net=host -v /root/rapiro:/root/rapiro wupanhao/xiaobai-assistant:v0.1 /bin/bash

ffmpeg下载532视频

fmpeg -i http://aisylive.oss/xxxxxxx/xxxx/180209c001_3.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4

pip

import sys
from pip import __main__
if __name__ == '__main__':
     sys.exit(__main__._main())
wupanhao commented 7 years ago

sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT

ip -6 route add default via fe80::eda:41ff:feac:3ba0 dev eth0.2

git仓库瘦身

参考GitHub官网: https://help.github.com/articles/removing-sensitive-data-from-a-repository
 # 查看对象文件记录
git rev-list --objects --all 
例如, 我的jekyll博客代码库提交了大量mp3文件, 使用下面命令清除后代码库由233M缩小为1.3M, 提交到GitHub部署博客轻快飞速
# 清除垃圾文件(大量无用的mp3文件)
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch *.mp3' --prune-empty --tag-name-filter cat -- --all

# 提交到远程仓库(如GitHub, 我再次从git clone GitHub代码库会变小为1.3M)
git push origin --force --all

# 必须回收垃圾,本地仓库才变小
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin    
git reflog expire --expire=now --all
git gc --prune=now

rm -rf .git/refs/original
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

转自:https://blog.csdn.net/weixin_33762321/article/details/87208418 

更改nodejs global包安装路径,解决EACESS ERROR

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
wupanhao commented 7 years ago

!/bin/bash

@author : haoyi

@date : 2016.08.11

@for : my config

export http_proxy="http://172.16.122.21:8118"

export https_proxy="http://172.16.122.21:8118"

sudo apt-get update sudo apt-get install -y lrzsz sudo apt-get install -y zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

sudo apt-get install -y vim

sudo apt-get install -y ttf-wqy-zenhei sudo apt-get install -y fcitx fcitx-pinyin

sudo apt-get install -y samba sudo apt-get install -y samba-common-bin

sudo apt-get install -y tightvncserver sudo apt-get install -y xtightvncviewer

xtightvncviewer -listen -fullscreen

listenning on 5500 port

sudo pip install shadowsocks

sudo apt-get install -y espeak

espeak -v zh " 你好你好你好,nice to meet you"

sudo apt-get install -y festival

sudo apt-get install -y nginx sudo apt-get install -y php5-fpm

git clone https://github.com/wupanhao/useful-php-scripts.git /var/www/html

echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules

usermod -aGvideo www-data

sudo apt-get install -y git

sudo apt-get install -y curl

sudo apt-get install -y pip

sudo apt-get install -y nmap

wupanhao commented 7 years ago

树莓派关闭屏保 http://ju.outofmemory.cn/entry/103897

https://my.oschina.net/yangyanxing/blog/159215 http://jayveehe.github.io/2015/01/26/nginx-flask/

树莓派aria2 远程下载配置 http://mkitby.com/2016/01/15/raspberry-pi-nas-remote-download-aria2/

挂载samba sudo mount -t cifs -o username=xxxx,password=xxxx //192.168.31.189/kugou /mnt/kugou

虚拟键盘 http://bbs.ickey.cn/community/forum.php?mod=viewthread&tid=44694

树莓派连wifi http://www.jianshu.com/p/b42e8d3df449

wupanhao commented 7 years ago

https://github.com/doraemonext/wechat-python-sdk

wupanhao commented 7 years ago

nginx https配置

openssl req -new -newkey rsa:2048 -sha256 -nodes -out wupanhao_top.csr -keyout wupanhao_top.key -subj "/C=CN/ST=BeiJing/L=BeiJing/O=Ekinghao Inc./OU=Web Security/CN=wupanhao.top"

openssl x509 -req -days 1024 -in wupanhao_top.csr -signkey wupanhao_top.key -out wupanhao_top.crt

server {

ssl参数

listen              443 ssl;
server_name         lc.wupanhao.top;
#证书文件
ssl_certificate     /home/cist/wupanhao_top.crt;
#私钥文件
ssl_certificate_key /home/cist/wupanhao_top.key;
ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers         HIGH:!aNULL:!MD5;
#...
root        /home/cist/samples;
index index.html;

}

wupanhao commented 7 years ago

mariadb

远程访问授权

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
wupanhao commented 6 years ago

魔镜DIY

树莓派旋转270度 sudo nano /boot/config.txt

display_rotate=1  # 1 90 ,2 180 , 3 270
avoid_warnings=1 
hdmi_force_hotplug=1 #允许HDMI热插拔

香橙派 sudo nano /etc/X11/xorg.conf.d/01-armbian-defaults.conf

    Section "Device"
    Identifier "default"
    Driver "fbdev"
    Option "Rotate" "CCW"        #The supported values are "CW" (clockwise,
90 degrees), "UD" (upside down, 180 degrees) and "CCW" (counter clockwise,
270 degrees)
    EndSection
wupanhao commented 6 years ago

sudo apt-get purge libappstream3

wupanhao commented 6 years ago

龙芯9s2a一体机 debian6 键鼠驱动解决方案

cp -r /lib/modules/2.6.27.59-lynloong-2f-9003 /lib/modules/2.6.27.59-loongson-2f

vsftpd 共享目录

权限需要改为755

anonymous_enable=YES
anon_root=/home/hao/Public
wupanhao commented 6 years ago

xgettext -d test header.php --from-code=utf-8

wupanhao commented 6 years ago

python2的安装方法:

pip install opencv-python

python3的安装方法:

网上很多人都是用源码编译的方式。也可通过pip方式安装。

pip3 install opencv-python
sudo apt install libatlas3-base libjasper1 libgst7 python3-gst-1.0 libqtgui4 libqt4-test

其实使用python3后,再import cv2从错误信息中就能知道缺少什么库,再使用sudo apt-cache search相关包就能查询到名称,最后使用apt安装即可。

wupanhao commented 6 years ago

jupyter notebook 支持conda多python环境

conda install nb_conda_kernels conda install -n tensorflow ipykernel

wupanhao commented 6 years ago

树莓派wpa配置WiFi连接

/etc/wpa_supplicant/wpa_supplicant.conf country=CN ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1

network={ priority=3 ssid="zhanting" psk="xxxx" } network={ ssid="Xiaomi_R3G" scan_ssid=1 psk="xxxxxx" priority=2 } network={ ssid="hao" psk="xxxxx" priority=5 }

wupanhao commented 6 years ago

C语言测运行时间

#include<stdio.h>
#include<sys/time.h>

int main()
{
    /* 定义两个结构体 */
    struct timeval start;
    struct timeval end;
    unsigned long timer;
    /* 程序开始之前计时start */
    gettimeofday(&start, NULL);
    printf("hello world!\n");
    /* 程序块结束后计时end */
    gettimeofday(&end, NULL);
    /* 统计程序段运行时间(unit is usec)*/
    timer = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
    printf("timer = %ld us\n", timer);
    return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    clock_t begin, end;
    double cost;
    //开始记录
    begin = clock();
    /*待测试程序段*/
    printf("hello world!\n");
    //结束记录
    end = clock();
    cost = (double)(end - begin)/CLOCKS_PER_SEC;
    printf("constant CLOCKS_PER_SEC is: %ld, time cost is: %lf secs", CLOCKS_PER_SEC, cost);
}

转自https://blog.csdn.net/AdmireLinux/article/details/62237834

wupanhao commented 5 years ago

树莓派自动连WiFi

sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN

network={
    ssid="BNU"
    key_mgmt=NONE
}

network={
    ssid="Xiaomi_R3G"
    psk="1234567890"
    key_mgmt=WPA-PSK
}

network={
    ssid="Xiaomi_HAO"
    psk="wph123789"
    key_mgmt=WPA-PSK
}
wupanhao commented 5 years ago

解决树莓派采样率16k报错

[Service] BusName=org.pulseaudio.Server ExecStart=/usr/bin/pulseaudio Restart=always

[Install] WantedBy=session.target


- 然后重启应该就能正常运行了