Skip to content

Instantly share code, notes, and snippets.

View Guaidaodl's full-sized avatar
🎯
Focusing

Guaidaodl Guaidaodl

🎯
Focusing
View GitHub Profile
@Guaidaodl
Guaidaodl / rename.py
Created July 5, 2016 15:35
Python 批量重命名文件
import os
import re
file_name_pattern = re.compile("^(.*)\\s\\(\\d\\)(\\..*)$")
for file_name in os.listdir("."):
matcher = file_name_pattern.match(file_name)
if matcher is not None:
new_file_name = matcher.group(1) + matcher.group(2)
os.rename(file_name, new_file_name)
@Guaidaodl
Guaidaodl / simple_status.rb
Last active August 11, 2016 16:39
快速查看repo的状态, 然后还加了没有用的 interactive 模式
#! /usr/bin/ruby
require 'colorize'
require 'optparse'
class FileStatus
attr_accessor :file_name, :status
def initialize(file_name, status)
@file_name = file_name
@status = status
@Guaidaodl
Guaidaodl / 3to4.rb
Last active August 12, 2016 05:27
将3个空格缩进的文件转换成4个空格的文件. 3个空格真的是异端啊.
#!/usr/bin/ruby
# 将用三个空格缩进的变成四个空格缩进
file_name = ARGV[0]
lines = File.read(file_name)
lines.split("\n").each do |line|
sp_count = 0
while line[count] == " " do

标题里的效果