Skip to content

Instantly share code, notes, and snippets.

@rswofxd
rswofxd / ST2插件开发.py
Created October 13, 2012 04:31
Python://sublim text 2插件开发实例.py
######################################
开发步骤
Sublime text 2 的插件开发使用的是 Python 。具体接口可以参考 API Reference。而 How to Create a Sublime Text 2 Plugin 提供了一个很好插件开发例子。
使用插件模板
使用 Sublime 菜单 Tools->New Plugin... ,即可创建新的插件:
import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, 0, "Hello, World!")
@rswofxd
rswofxd / PySqlite3.py
Created July 17, 2012 07:40
Python://PySqlite3/Python对于Sqlite3数据库操作
#coding:utf-8
"""
Python-Sqlite3数据库操作
自定义数据类型存储
"""
import sqlite3
try:
import cPickle as pickle
except :
import pickle
@rswofxd
rswofxd / IIC.v
Created June 26, 2012 03:40
Verilog:串行数据总线协议IIC
////////////////////////////////////////////////////////////////////////////////
//串行数据总线协议IIC
////////////////////////////////////////////////////////////////////////////////
`timescale 1ns/1ns
module i2c_wr (clk,rst_n,wr,rd,addr,data_w,data_r,ack,scl,sda);
input clk; //clock
input rst_n; //reset
input wr,rd; //write,read command
input [10:0] addr; //write,read eeprom address
@rswofxd
rswofxd / PySched.py
Created June 23, 2012 10:45
Python:任务调度,定时执行
#coding=utf-8
import time
import sched
import os
import threading
"""
sched模块,准确的说,它是一个调度(延时处理机制),每次想要定时执行某任务都必须写入一个调度。
使用步骤如下:
(1)生成调度器:
s = sched.scheduler(time.time,time.sleep)
@rswofxd
rswofxd / py_cmd.py
Created June 22, 2012 03:58
Python:实现python与cmd交互
#coding:utf-8
"""
实现python操作cmd
以及与windows系统交互
"""
import os, sys, subprocess
def pyCmd(cmd):
cmd = 'dir'
os.system(cmd)
@rswofxd
rswofxd / thread_Queue.py
Created June 21, 2012 12:22
Python:线程,队列运用
#coding=utf-8
import threading, Queue
import time, random
"""
线程,队列同步运用
"""
##############
# Producer thread
##############
class Producer(threading.Thread):
@rswofxd
rswofxd / CodeCut.py
Created June 10, 2012 09:15
Python://CodeCut.py/生命很短暂,精简就是生命
#coding:utf-8
###########################################
#生命很短暂,精简就是生命
###########################################
#交换变量避免使用临时变量
#########################
#M1
temp = x
x = y
y = temp
@rswofxd
rswofxd / Decorater.py
Created June 8, 2012 08:43
Python:基于装饰器函数实现函数Debug跟踪
#coding:utf-8
#############################
#装饰器:在函数体前后插入执行代码,并完成封装
#利用装饰器函数实现对函数跟踪
#添加装饰器实现Debug调试
#///////////////////////////////////////////////////////////
#from Decorater import trace_func as trace
#///////////////////////////////////////////////////////////
import profile
@rswofxd
rswofxd / VMode.v
Created May 25, 2012 10:24
Verilog:硬件描述语言verilog常用总结
//Verilog硬件设计最高境界:胸中有沟壑,清晰明白每一条语句所代表硬件电路
`timescale 1ns/100ps //0.1ns is allowed
module gray_counter(d_in,
clk,
rst,
ld,
q
);
//input and output
@rswofxd
rswofxd / neurNet.py
Created May 25, 2012 10:23
Python:神经网络模块训练实例
#coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import random
import math
from pyneurgen.neuralnet import NeuralNet
from pyneurgen.nodes import BiasNode, Connection