This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// SlideView | |
// | |
// Created by 余森彬 on 2017/3/10. | |
// Copyright © 2017年 余森彬. All rights reserved. | |
// | |
import CoreGraphics | |
import CoreText |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func showSlideView() { | |
let parentFrame = self.view.frame | |
let leftframe = CGRect(x: 0, y: 0, width: 0, height: parentFrame.height) | |
let rightframe = CGRect(x: parentFrame.width * 0.8, y: 0, width: parentFrame.width * 0.2, height: parentFrame.height) | |
let slideView = UIView(frame: leftframe) | |
let rightView = UIView(frame: rightframe) | |
let singleFingerTap = UITapGestureRecognizer(target: self, action: #selector(self.closeSlide)) | |
rightView.addGestureRecognizer(singleFingerTap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def param_schema(**schema): | |
""" | |
请求参数检查装饰器, 使用参数如下: | |
key为请求参数,value可以说单个的类型值、(类型值,默认值)元组 | |
from tornado import web | |
class ExampleRequestHandler(web.RequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
session_engines = {} | |
def get_new_session(connection=None, autocommit=None): | |
connection = connection or 'default' | |
connection_settings = settings.DATABASES[connection] | |
connection_autocommit = ValueUtils.none_or( | |
connection_settings.get('autocommit'), False) | |
autocommit = ValueUtils.none_or(autocommit, connection_autocommit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tornado http request duration histogram | |
awk '$1 == "[I" && $5 == 200 {sum += 1; duration = int(substr($10, 0, length($10) - 2)); if(duration < 100) r100 +=1; else if(duration < 200) r200 += 1; else if(duration < 500) r500 += 1; else r1000 += 1;} END {print "总请求量", "100ms以内", "200ms以内", "500ms以内", "500ms以外"; print sum, r100, r200, r500, r1000, (r100 + r200) / sum}' /path/app.log | |
# tornado http request top ten qps time | |
awk '$1 == "[I" && $5 == 200 {split($3, time, ","); second = $2" "time[1]; agg[second] += 1} END {for(second in agg) print second, agg[second]}' /path/app.log | sort -nr -k 3 | head | |
# nginx top ten qps time | |
awk '{second = substr($4, 2, length($4) - 1); agg[second] += 1} END {for(second in agg) print second, agg[second]}' logs/access.log | sort -nr -k 2 | head | |
# tornado http request duration greater than 100ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Check how epoll works.""" | |
import click | |
import errno | |
import os | |
import select | |
import socket | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
#include "unistd.h" | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <sys/epoll.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps -fp `netstat -tnp|awk '$2 > 0'|awk '{split($NF, a, "/"); print a[1]}'|awk '/^[0-9]/'|sort -n|uniq` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for host in `echo 'google.com facebook.com twitter.com youtube.com' | cut -d ' ' -f 1-`; do ping -c 64 $host | tail -3; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _AddPropertiesForNonRepeatedScalarField(field, cls): | |
"""Adds a public property for a nonrepeated, scalar protocol message field. | |
Clients can use this property to get and directly set the value of the field. | |
Note that when the client sets the value of a field by using this property, | |
all necessary "has" bits are set as a side-effect, and we also perform | |
type-checking. | |
Args: | |
field: A FieldDescriptor for this field. | |
cls: The class we're constructing. |
OlderNewer