Skip to content

Instantly share code, notes, and snippets.

View 2niuhe's full-sized avatar
🎯
Focusing

niu_he 2niuhe

🎯
Focusing
View GitHub Profile
@2niuhe
2niuhe / translator.py
Created June 7, 2018 06:28
It's a python translation script which can works on linux shell. 擅长中英互译。http://blog.niuhemoon.xyz/pages/2018/06/06/Python-CommandLine-Translator/
#!/usr/bin/python3
# encoding:utf-8
import requests
import json
import sys
import argparse
from googletrans import Translator
translator = Translator(service_urls=[
@2niuhe
2niuhe / zhdaily.py
Last active June 7, 2018 06:32
It's a python script works on liunx shell,which can help you read zhihu-daily news.可以帮助你在终端下浏览知乎日报。http://blog.niuhemoon.xyz/pages/2018/05/18/zhihu-daily-crawler/
#!/usr/bin/python3
#-*- coding: utf-8 -*-
import requests
import json
headers = {'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
def get_daily():
page = requests.get('http://news-at.zhihu.com/api/3/news/latest', headers=headers).text
response = json.loads(page)
@2niuhe
2niuhe / matplotlib_cn.py
Last active June 28, 2020 16:19
用matplotlib来画二维图,采用中文标签。
#conding:utf-8
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.figure(num=1,figsize=(8,5))
plt.plot([0,1],[3,3],color='red',linewidth=1.0,linestyle='-')
plt.plot([1,3],[3,1],color='red',linewidth=1.0,linestyle='-')
@2niuhe
2niuhe / switch.ino
Created May 22, 2019 09:20
使用arduino nano的串口来控制继电器作为数字开关
#define VCC 2
#define IN 4
const int HEADER = '@';
const char TAIL = '%';
int flag =-1;
void setup() {
@2niuhe
2niuhe / install.md
Last active April 27, 2020 14:21
安装并配置ubuntu的记录

Ubuntu18一些软件配置记录

来自网上的一些内容,做一下整理备用

安装系统

安装时,修改grub 在grub编辑里quiet splash 后添加nomodeset,然后启动,若分辨率过低,可用ALT+F7来移动窗口

换清华源

@2niuhe
2niuhe / win10_config.md
Last active May 30, 2020 10:00
Window10系统软件配置记录

终端

  • bashrc替代
    • 编辑注册表[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor],添加字段"AutoRun",值为脚本或者软件的路径。
  • 代理

同步/网盘/下载

  • Mega用来同步重要文档
  • Onedrive
  • 百度网盘
@2niuhe
2niuhe / raspi.md
Last active June 27, 2019 14:33
树莓派操作指南;instruction on raspberry pi 3B+

系统安装/备份工具

  • window: Disk Manager
  • linux: dd命令
  • 换清华源
# 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib
@2niuhe
2niuhe / bash_basic.md
Created June 2, 2019 20:26
基础的bash脚本语法和技巧,备忘。参考https://devhints.io/bash

变量

#!/usr/bin/bash
NAME="John"
echo "Hello $NAME!"
NAME="John"
echo $NAME
echo "$NAME"
@2niuhe
2niuhe / download_book.py
Created June 10, 2019 11:47
ankidroid_spider,爬取轻松背单词上的单词列表,制作ankidroid单词书。http://book.qsbdc.com
import requests
from bs4 import BeautifulSoup
import json
import re
from lxml import etree
HEADERS = {'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "\
"Chrome/65.0.3325.181 Safari/537.36"}
@2niuhe
2niuhe / termux_mxrig.md
Last active March 30, 2024 12:45
install XMRig on termux

Monero XMR mining via termux ;ubuntu

  1. install ubuntu in termux command; (ubuntu is optional)
pkg install update && upgrade
apt install git
apt install wget
apt install proot