Skip to content

Instantly share code, notes, and snippets.

View yorkie's full-sized avatar
🎯
Focusing

Yorkie Makoto yorkie

🎯
Focusing
View GitHub Profile
@yorkie
yorkie / buggyCodes_000.c
Last active December 11, 2015 18:38
无符号数与有符号数常常出现在程序中的代码失误(一)
/*
* code来自《深入理解计算机系统》Page-52
* The below function which called within sum_element(arr, 0) will occur a RAM's trouble to you
* should be invoked within 2 arguments, an array and a unsigned integer "length".
*
* Analysis:
* If the argument length is assigned with ZERO, namely return 0.0 under human's comprehension.
* As an opposite ending, however in fact, length is unsigned. Such that length-1 will be treated
* as length+((unsigned)(-1)), UMax. Even worse is the logical operator "<", whose operands are the
* unsigned integer UMax and an integer i, it always return true - !
@yorkie
yorkie / bitmap.c
Last active December 11, 2015 20:59
运用位级运算实现如下函数:even_ones[具体功能见注释]
// 来自 @颜闽辉
int bitmap(unsigned in, char out[])
{
unsigned count = 0;
unsigned size = sizeof(in) * 8;
out[size] = '\0';
do {
if (in & 1) {
@yorkie
yorkie / main.c
Created April 7, 2013 13:47
计算1-100能被7整除的整数的和
#include "stdio.h"
int main(int argc, char const *argv[])
{
int i = 1;
int sum = 0;
while (i <= 100) {
if (i % 7 == 0) sum += i;

移动应用API设计理念10条

原文地址:http://u.10-tips-designing-your-mobile

在移动开发中,客户端通常需要一个基于Web云的API服务(Service)来实现C/S通信。最简化这些API的用例通常是获取(Read/Retrieve)云端数据,但并非局限于此,向云端发送数据、用户认证与管理等都可以基于该Web云服务实现。

你若想在你的移动端应用程序中,使用Web云API服务的话,下面10个坑是你应该知道的:

1.为你的每个API加入版本号

@yorkie
yorkie / Log Everything All The Time.md
Last active December 17, 2015 17:49
原文摘录

This JoelOnSoftware thread asks the age old question of what and how to log. The usual trace/error/warning/info advice is totally useless in a large scale distributed system. Instead, you need to log everything all the time so you can solve problems that have already happened across a potentially huge range of servers. Yes, it can be done.

To see why the typical logging approach is broken, imagine this scenario: Your site has been up and running great for weeks. No problems. A foreshadowing beeper goes off at 2AM. It seems some users can no longer add comments to threads. Then you hear the debugging deathknell: it's an intermittent problem and customers are pissed. Fix it. Now.

So how are you going to debug this? The monitoring system doesn't show any obvious problems or errors. You quickly post a comment and it works fine. This won't be easy. So you think. Commenting involves a bunch of servers and networks. There's the load balancer, spam filter, web server, database server, caching server, file server, a

@yorkie
yorkie / Basic Stuff.md
Last active December 17, 2015 21:48
linux command list.

List of open ports

netstat -plten

Type netstat -h for more details on netstat

A sample Mac OS X Bash startup file (.bash_profile)

# aliases
alias cd..="cd .."
@yorkie
yorkie / Notes.md
Last active December 17, 2015 21:49
MongoDB Best Practices
  1. Preparing for a MongoDB deployment is: schema design, document model, dynamic schema, collections, indexed, transactions and schema enforcement.
  2. The maximum BSON document size in MongoDB is 16MB.
  3. free(NULL) is correct thing in C.

Start nginx

$ sudo /usr/local/nginx/sbin/nginx

Stop

$ sudo /usr/local/nginx/sbin/nginx -s stop
@yorkie
yorkie / nodejs-stuffs.md
Last active December 18, 2015 20:58
nodejs stuffs

ENOENT

ENOENT error code explaination

ECONNRESET

It would appear that ECONNRESET means that the other side has closed the connection without reading outstanding data that has been sent to it, and can be triggered on both read() and write(). But the exact behavior depends on the operating system.

TIPS

tail -f [logpath]
@yorkie
yorkie / invite.ics
Last active December 23, 2015 15:59
invite.ics
BEGIN:VCALENDAR
PRODID:-//SeedMail Inc//SeedMail Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130826T153000Z
DTEND:20130826T163000Z
DTSTAMP:20130826T150411Z
ORGANIZER;CN=Yorkie Neil:mailto:yazhong@seedmail-inc.com