Swift直接调用Python函数库

{% github PerfectlySoft Perfect-Python 63589be width = 30% %}

Perfect - Python

本项目提供了在Swift服务器应用上直接引用Python 2.7函数库的简便方法。

本项目采用Swift Package Manager 软件包管理器编译,是Perfect 项目的一部分,但是也可以独立运行

批量压缩png图片工具

{% github it-boyer width = 30% %}

pngquant

使用pngquant批量压缩png

  1. 编写批量处理脚本 vi compresspng.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

import os
import sys
## 参考https://www.jianshu.com/p/bfa29141437e
# 执行文件路径:
    # os.path.realpath(__file__)
    # sys.argv[0]
# 当前图片目录:os.getcwd()
# 文件目录:sys.path[0]

# 获取终端参数
#   sys.argv[1]
# 用法
# pngTo imgDir 默认目录路径

def GetFileFromThisRootDir(dir, ext = None):
    allfiles = []
    needExtFilter = (ext != None)
    for root,dirs,files in os.walk(dir):
        for filespath in files:
            filepath = os.path.join(root, filespath)
            extension = os.path.splitext(filepath)[1][1:]
            if needExtFilter and extension == ext in ext:
                allfiles.append(filepath)
    return allfiles

if __name__ == '__main__':
    rootDir=sys.path[0]
    PngquantExe = rootDir + "/pngquant"
    print(len(sys.argv))
    if len(sys.argv) == 1:  #当没有传目录参数时,默认获取当前目录
        srcDir = os.getcwd()
    else:
        srcDir=sys.argv[1]  #获取用户指定的目录路径
    print(srcDir)
    imgFiles=GetFileFromThisRootDir(srcDir, 'png')
    suffix="_temp.png"
    for f in imgFiles:
        cmd = "\"" + PngquantExe + "\"" + " --ext " + suffix + " --force --speed=3 "+ f
        os.system(cmd)
        os.remove(f)
        newfile=f.replace(".png", suffix)
        os.rename(newfile, f)
print("压缩完成")

用法

Zsh插件之github使用

github插件

This plugin supports working with GitHub from the command line. It provides a few things:

  • Sets up the hub wrapper and completions for the git command if you have hub installed.
  • Completion for the github Ruby gem.
  • Convenience functions for working with repos and URLs.

Functions

  • empty_gh - Creates a new empty repo (with a README.md) and pushes it to GitHub
  • new_gh - Initializes an existing directory as a repo and pushes it to GitHub
  • exist_gh - Takes an existing repo and pushes it to GitHub
  • git.io - Shortens a URL using git.io

Android安装BusyBox

大家是否有过这样的经历,在命令行里输入adb shell,然后使用命令操作你的手机或模拟器,但是那些命令都是常见Linux命令的阉割缩水版,用起来很不爽。是否想过在Android上使用较完整的shell呢?用BusyBox吧。不论使用adb连接设备使用命令行还是在手机上直接用terminal emulator都可以。

了解手机处理器ARM

Arm处理器,因为其低功耗和小尺寸而闻名,几乎所有的手机处理器都基于arm,其在嵌入式系统中的应用非常广泛,它的性能在同等功耗产品中也很出色。

package_json文件配置说明

npm 与 package.json 快速入门教程 每个项目的根目录下一般都有一个package.json文件,定义项目所需要的各种模块,以及项目的配置信息。npm install则是根据这个配置文件,自动下载所需要的模块,也就是配置项目所需的运行和开发环境。 package.json文件可以手工编写,也可以用npm init命令自动生成,除了项目名称和项目版本是必填的,其他都是选填的。

opkg在小米路由器的使用

{% github openwrt openwrt 759f111 width = 30% %} openwrt.io 小米路由器固件信息

路由器read-only file system怎么改权限

1
mount -o remount,rw /

新建配置

  1. 备份初始conf
1
mv /etc/opkg.conf /etc/opkg.conf.bak
  1. 开始配置 vim /etc/opkg.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
src/gz attitude_adjustment_base http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base
src/gz attitude_adjustment_packages http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/packages/
src/gz attitude_adjustment_luci http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/luci/
src/gz attitude_adjustment_management http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/management/
src/gz attitude_adjustment_oldpackages http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/oldpackages/
src/gz attitude_adjustment_routing http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/routing/
src/gz openwrt_dist http://openwrt-dist.sourceforge.net/releases/ramips/packages
src/gz openwrt_dist_luci http://openwrt-dist.sourceforge.net/releases/luci/packages
dest root /data
dest ram /tmp
lists_dir ext /data/var/opkg-lists
option overlay_root /data
arch all 100
arch ramips 200
arch ramips_24kec 300
  1. 更新库
1
2
3
$ opkg update
Downloading http://downloads.openwrt.org/..../generic/packages/packages/Packages.gz.
Updated list of available packages in /data/var/opkg-lists/attitude_adjustment.

注:如果下载失败,请确认是否是http而非https。另外如果链接失效可能是更新了包,可以到https://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base/搜索libc_找到最新下载地址。