Skip to content

Instantly share code, notes, and snippets.

//
// ContentViewController.m
//
// Created by Johnnie Walker on 07/06/2013.
//
#import "ContentViewController.h"
@interface ContentViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, weak) UITableView *tableView;
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
@wangyangkobe
wangyangkobe / UIView+UITableViewCell
Created August 12, 2014 13:57
根据UITableViewCell的元素来获取UITableViewCell.(兼容ios7和ios6).
@implementation UIView (KLCPopupExample)
- (UITableViewCell*)parentCell {
// Iterate over superviews until you find a UITableViewCell
UIView* view = self;
while (view != nil) {
if ([view isKindOfClass:[UITableViewCell class]]) {
return (UITableViewCell*)view;
} else {
@wangyangkobe
wangyangkobe / copyfile.py
Created November 7, 2014 09:03
对SBG的source code打包。
#!/bin/python
import os
import sys
import shutil
import multiprocessing
'''os.system("cleartool setview elqstux_ki_ppb")'''
ftPath = "/vobs/mgwblade/PPB/SBG_HSD10196_1/test/auto"
sgcPath = "/vobs/mgwblade/SGC/SGC_CSA10105_4/SGC_CRA1190962"
@wangyangkobe
wangyangkobe / fibonacci.go
Created November 16, 2014 08:31
Go语言的“斐波纳契闭包”
import "fmt"
// fibonacci 函数会返回一个返回 int 的函数。
func fibonacci() func() int {
a := -1
b := 1
return func() int {
a, b = b, a+b
return b
}
@wangyangkobe
wangyangkobe / Pmw.EntryField.py
Last active August 29, 2015 14:15
The exercise for Pmw.EntryField.
from Tkinter import *
import time, string
import Pmw
class EntryValidation:
def __init__(self, master):
now = time.localtime(time.time())
self._date = Pmw.EntryField(master, labelpos='w', label_text='Date (mm/dd/yy):', value = "%d%d%d" % (now[1], now[2], now[0]),
validate={'validator':'date', 'format':'mdy', 'separator':'/'})
@wangyangkobe
wangyangkobe / extract.js
Last active August 29, 2015 14:16
extract *.tar.gz for SBG code.
var path = require('path');
var fs = require('fs');
var tarball = require('tarball-extract');
var rimraf = require("rimraf");
var srcDir = "C:\\Users\\elqstux\\Desktop"
var dstDir = "C:\\Users\\elqstux\\Desktop\\SBG Code\\src";
var files = ["SOM_CRA1190221.tar.gz", "SYF_CRA1190070.tar.gz", "auto.tar.gz", "SGC_CRA1190962.tar.gz"];
@wangyangkobe
wangyangkobe / cba_build_package
Last active August 29, 2015 14:18
cba_build_package
#!/vobs/ims/common/tools_root/cdfrt/dist/unitprep/TDP-Python-CXS1040058-R2A01/contained/DT_Python/bin/python
import os
from subprocess import Popen, PIPE
import traceback
import threading
import time
import sys
AIT_DIR = r"/vobs/ims/sbg/src/delivery/sgcPSR/SiteConfigurationPackage/AIT"
@wangyangkobe
wangyangkobe / waterline_mongo.js
Last active August 29, 2015 14:25
How to use waterline for MongoDB.
var express = require('express');
var app = express();
var Waterline = require('waterline');
var sailsMongoAdapter = require('sails-mongo');
var orm = new Waterline();
var bodyParser = require('body-parser');
var bcrypt = require('bcrypt');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json())
@wangyangkobe
wangyangkobe / tcp_server.erl
Created September 6, 2015 09:05
The tcp server of Erlang.
-module(tcp_server).
-compile(export_all).
start(Port) ->
Pid = spawn_link(fun()->
{ok, ListenSocket} = gen_tcp:listen(Port, [binary, {active, false}]),
spawn(fun() -> acceptor(ListenSocket) end),
timer:sleep(infinity)