Skip to content

Instantly share code, notes, and snippets.

View liruqi's full-sized avatar

Ruqi liruqi

View GitHub Profile
@liruqi
liruqi / 4x4.py
Created August 28, 2012 15:39
一个4x4的矩阵,从左上到右下走,可以左右上下走,但是不能走走过的点,有多少种走法?
gCnt = 0
def main():
squre = []
for i in range(4):
squre.append([0,0,0,0])
print squre
@liruqi
liruqi / kth.py
Created November 4, 2012 17:12
interviewstreet 4e769c33164d9
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import copy
testcases = int( raw_input() )
for i in range(testcases):
nk = raw_input().split(" ")
n = int(nk[0])
k = int(nk[1])
data = []
@liruqi
liruqi / send_ack.scapy
Created November 27, 2012 00:25
send_ack.scapy
packet1 = IP(dst='106.187.39.23')/TCP(dport=9999,flags=0x18)
packet1.payload = 'GET / HTTP\r\nUser-Agent: curl/7.28.1\r\nHost: liruqi.com\r\nAccept: */*\r\n\r\n'
send(packet1)
@liruqi
liruqi / center2views.m
Created January 20, 2016 07:24
Put to adjacent view in the horizontal middle of screen
// No working anyway
CGSize screenSz = [UIScreen mainScreen].bounds.size;
CGSize leftSz = [self.haveAccountLabel intrinsicContentSize];
CGSize rightSz = [self.signInButton intrinsicContentSize];
CGFloat contentWidth = leftSz.width + rightSz.width + 8;
CGFloat x = (screenSz.width - contentWidth) / 2;
if (x < 0) {
NSLog(@"Text overflow %lf > %lf", contentWidth, screenSz.width);
@liruqi
liruqi / ipset-gen.py
Last active February 6, 2016 08:34
shadowsocks server config
# copied from: http://code.google.com/p/chnroutes/source/browse/trunk/chnroutes.py
import re
import urllib2
import sys
import argparse
import math
import json
def fetch_ip_data():
@liruqi
liruqi / NSPZeroMarginCell.m
Last active February 23, 2016 21:55
Zero content margin UITableViewCell
// Hide separator for specific cell is extremely hard in iOS 9.
// None of these worked or good enough for me:
// http://stackoverflow.com/questions/8561774/hide-separator-line-on-one-uitableviewcell
@interface NSPZeroMarginCell : UITableViewCell
@property (nonatomic, assign) BOOL separatorHidden;
@end
== iOS ==
===Build guide===
* https://github.com/actorapp/actor-bootstrap/tree/master/docs/server
== Configuration ==
===File Storage===
AWS S3 or file system on actor server
* AWS S3: https://github.com/actorapp/actor-bootstrap/blob/master/docs/server/configure-s3.md
* Steps: [http://roomchat-cn.azurewebsites.net/oss/actor/aws-s3-cors1.jpg],[http://roomchat-cn.azurewebsites.net/oss/actor/aws-s3-cors2.jpg]
ALTER TABLE beijing_house add column `usage` varchar(16) default NULL;
ALTER TABLE `beijing_house` add column `createtime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
/*
249 / 282 test cases passed.
Status: Wrong Answer
Input:
[-2,0,5,-1,-5,5,3]
-2
Output:
[[-5,-2,0,5],[-2,-1,0,1]]
Expected:
@liruqi
liruqi / gist:c0d15fa2950864b61282700063278a9c
Created March 7, 2017 12:12 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt