Skip to content

Instantly share code, notes, and snippets.

@cnsoft
cnsoft / SXGauge.h
Created November 20, 2012 08:20 — forked from PrimaryFeather/SXGauge.h
This Sparrow extension class displays a texture, trimmed to its left side, depending on a ratio. This can be used to create a progress bar or a rest-time display.
#import <Foundation/Foundation.h>
#import "Sparrow.h"
/// An SXGauge displays a texture, trimmed to its left side, depending on a ratio.
/// This can be used to display a progress bar or a time gauge.
@interface SXGauge : SPSprite
{
@private
SPImage *mImage;
float mRatio;
From: http://snipt.net/yonishin/about-xcode-4-project-template
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
Examples:
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate
@cnsoft
cnsoft / mox_demo1.py
Last active December 17, 2015 09:39
how to use pymox mock bigworld module
import mox
import stubout
#test function tearup
m = mox.Mox()
BigWorld = m.CreateMockAnything()
m.StubOutWithMock(BigWorld,"entities")
m.StubOutWithMock(BigWorld,"singleton")
#Great,prepare clientside input data for function be called.
BigWorld.entities.get(100).AndReturn(None)
@cnsoft
cnsoft / Pexpect_demo2.py
Created May 17, 2013 03:56
I collect this examples. maybe you will need it soon.
#!/usr/bin/python
#
#Notice:Please close domain lookup on your router or switch.
__author__="ring0"
__date__ ="$2011-6-5 16:00:00$"
__version__ ="0.3"
import sys
try:
@cnsoft
cnsoft / Pexpect_demo3.py
Last active December 17, 2015 10:49
Auto Start or Shutdown Testing Server
child = pexpect.spawn('su 3028')
child.expect(".word")
child.sendline("3028")
child.expect(".$")
child.sendline('cd ~')
child.sendline('/home/exe/mf204/bigworld/tools/server/control_cluster.py check')
r = child.expect([".not run",".run",pexpect.EOF])
if r == 0:
child.sendline('/home/exe/mf204/bigworld/tools/server/control_cluster.py load simple')
print 'try load server'
import os
filters = ['.cpp','.h','.py','.hpp','.ipp','.sln','.vcproj','.mak']
filters.extend(['.c','python','Makefile','php'])
#filters = ['python']
#filters = ['*']
if os.name == 'posix':
FOLDER_FIX = '/'
else:
FOLDER_FIX = "\\"
@cnsoft
cnsoft / Demo_exportRev.py
Created May 24, 2013 09:48
export rev files only.. used to create hot fix..
#!/usr/bin/env python
#svn log -v -r 20146:20150 svn://192.168.1.230/tjspaces
#Author cnsoft 2011-09
svncmd = "svn log -v -r %d:%d %s"
#Test
svnurl = "svn://192.168.1.230/tjspaces/"
#
outputpath = "d:\\packagetools"
@cnsoft
cnsoft / VpsMate_intall.py
Created May 31, 2013 08:10
VPSMate - A Host Panel Written by python
#!/usr/bin/env python
#-*- coding: utf-8 -*-
#
# Copyright (c) 2012, VPSMate development team
# All rights reserved.
#
# VPSMate is distributed under the terms of the (new) BSD License.
# The full license can be found in 'LICENSE.txt'.
""" Install script for VPSMate """
@cnsoft
cnsoft / yum_163.sh
Created June 5, 2013 03:08
yum update with 163 mirror site.
#!/bin/sh
#****************************************************************#
# ScriptName: yum_update.sh
# Author: baoqing.guobq
# Create Date: 2011-07-21
# Modify Author:
# Modify Date: 2011-07-21
# Function:
#***************************************************************#
mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak
@cnsoft
cnsoft / monitor_process.py
Created June 7, 2013 03:52
Check whether a process is running or not.
import os
import subprocess
import re
def findThisProcess( process_name ):
ps = subprocess.Popen("ps -eaf | grep "+process_name, shell=True, stdout=subprocess.PIPE)
output = ps.stdout.read()
ps.stdout.close()
ps.wait()