Skip to content

Instantly share code, notes, and snippets.

View wxianfeng's full-sized avatar
🎯
Focusing

xianfeng wang wxianfeng

🎯
Focusing
View GitHub Profile
@wxianfeng
wxianfeng / infer.py
Created March 28, 2018 07:06
tensorflow 使用模型检测照片物体
# python demo/infer.py 原始图片路径 模型文件 结果输出文件
# python demo/infer.py /data/photos/car_trash.jpeg demo/output/frozen_inference_graph.pb demo/result.json
import sys
sys.path.append('..')
import os
import time
import tensorflow as tf
import numpy as np
import json
@wxianfeng
wxianfeng / cfg
Last active December 14, 2015 10:18
自动更新redmine已指派到已解决.
由于git pull,push慢,一般我是多次commit,一次push. 并且在 commit 中填写 fix #xxx, 随手把pm上 issue的状态改为已解决. 不手动关的话,不够实时,没人点击版本库,测试人员看不到已解决.
手动关的话,带来一个问题,状态已解决, 测试人员就开始验证了,但是代码没push.
我写了个脚本自动化完成这个任务.
>vi .git/config
[push]
default = current
[alias]
xpush = !git push && .git/hooks/post-push
@wxianfeng
wxianfeng / god.md
Created June 14, 2012 11:22
ruby God monitor process

如果god用到新的gem,需要重启god

help

god -h

config

god -c config/god/resque.god

load

>god load config/god/resque.god # if god has running, u can do this

@wxianfeng
wxianfeng / update.rb
Created June 12, 2012 15:37
ruby update wordpress wp_posts table
#!/usr/bin/env ruby
# 修改 www.vic360.com中图片链接错误问题
# localhost/~w/projects/vic360 => www.vic360.com
# http://stackoverflow.com/questions/2693862/how-do-i-require-a-specific-version-of-a-ruby-gem
# TIP:
#localhost:wxianfeng_com wangxianfeng$ ruby script/tools/07_update_vic360_image_url.rb
#/Users/wangxianfeng/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.3/lib/active_record/relation/batches.rb:68:in `find_in_batches': undefined method `gteq' for nil:NilClass (NoMethodError)
# from /Users/wangxianfeng/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.3/lib/active_record/relation/batches.rb:20:in `find_each'
# from /Users/wangxianfeng/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.3/lib/active_record/base.rb:440:in `find_each'
@wxianfeng
wxianfeng / my.cnf
Created June 7, 2012 08:24
mysql 配置两个实例
# 单台机器配置两个mysql实例,UBUNTU
# 把原先的mysqld变成mysqld1,然后新建一个mysqld2
>vim /etc/mysql/my.cnf
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user=root
password=root
@wxianfeng
wxianfeng / slave.cnf
Created June 7, 2012 08:13
mysql 主从复制
# mysql主从复制,两台机器
# 主: 192.168.10.107 UBUNTU
# 从: 192.168.10.105 UBUNTU
# 主配置
>vim /etc/mysql/my.cnf
[mysqld]
log-bin=mysql-bin // 启用二进制日志
server-id=107 // 服务器唯一ID,一般取IP最后一段
bind-address=192.168.10.107
@wxianfeng
wxianfeng / send_mail.rb
Created June 6, 2012 02:17
ruby net/smtp send mail
#encoding: utf-8
#!/usr/bin/env ruby
require 'net/smtp'
FROM = 'noreply@entfield.com'
TO = 'kd-wangxf@chinaunicom.cn'
value = ["[www.entfield.com]请激活您的帐号"].pack("M").gsub(/=\n/, "")
subject = "=?UTF-8?Q?#{value}?="
@wxianfeng
wxianfeng / init.sh
Created May 31, 2012 16:45
centos 开机自启动服务
# http://www.centos.bz/2011/09/centos-setup-process-startup-boot/
one method:
>chkconfig httpd on
生成了 /etc/rc.d/init.d/httpd
another method:
>vi /etc/rc.local
see list:
@wxianfeng
wxianfeng / gist:2646221
Created May 9, 2012 16:26
benchmark mysql 普通索引,唯一索引 性能比较
# 表结构
users(login)
# 生成 一千万 条数据
#!/usr/bin/env ruby
require 'uuid'
uuid = UUID.new
File.open("./data.txt","a+") do |f|
@wxianfeng
wxianfeng / gist:2642059
Created May 9, 2012 05:22
db:create 报kgio_ext 错误
wxianfeng@wxianfeng:/data/projects/entos$ RAILS_ENV=development rake db:create --trace
rake aborted!
no such file to load -- kgio_ext
fixed:
upgrade kgio 2.7.2 -> 2.7.4