View cherrypy_routing.py
import logging | |
import cherrypy | |
from cherrypy.process import plugins | |
class ADPHttpFacetPlugin(plugins.SimplePlugin): | |
def __init__(self, bus): | |
plugins.SimplePlugin.__init__(self, bus) | |
self.logger = logging.getLogger(__name__) |
View cherrypy_RoutesDispatcher.py
# https://stackoverflow.com/questions/13484206/cherrypy-url-dispatcher | |
import cherrypy | |
class City: | |
def __init__(self, name): | |
self.name = name | |
self.population = 10000 |
View SnowFlakeIdWorker.java
public class SnowFlakeIdWorker { | |
private final long workerId; | |
private final static long twepoch = 1390838400000L; | |
private Long sequence = 0L; | |
private final static long workerIdBits = 4L; | |
public final static long maxWorkerId = -1L ^ -1L << workerIdBits; | |
private final static long sequenceBits = 10L; | |
private final static long workerIdShift = sequenceBits; | |
private final static long timestampLeftShift = sequenceBits + workerIdBits; |
View app.cpp
#include <iostream> | |
#include <thread> | |
using namespace std; | |
int _id = 1; | |
class Person | |
{ | |
public: |
View SimpleVimrc
set nu | |
set autochdir | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set ai | |
set si | |
set ts=4 | |
set st=4 | |
set sw=4 | |
set et |
View self-signed-ssl-certificate.txt
# Become root first ! | |
$ mkdir /etc/ssl/self-signed && cd /etc/ssl/self-signed | |
$ openssl genrsa -des3 -out server.key 1024 | |
$ openssl rsa -in server.key -out server.key.insecure | |
$ mv server.key server.key.secure && mv server.key.insecure server.key | |
$ openssl req -new -key server.key -out server.csr | |
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt |
View convert_to_int_with_default_zero.js
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })() | |
// undefined | |
// 0 | |
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })(45) | |
// 45 | |
// 45 | |
(function(priority) {console.log(priority); return priority && + priority | 0 || 0; })('a') | |
// a |
View dynamic_font_size_in_qlabel_based_on_text_length.cpp
int fit = false; | |
this->testLabel->setText(""); | |
QLabel *myLabel = this->testLabel; | |
QFont myFont = myLabel->font(); | |
QString str = "this is the new string. this is the new string. this is the new string. super long. don't fit. please please please overflow the box"; | |
while (!fit) | |
{ |
View html5.html
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>KISSY MINI Mobile Demo Template</title> | |
<!-- | |
width=device-width:让文档的宽度与设备的宽度保持一致,且文档最大的宽度比例是1.0 | |
initial-scale=1:初始的缩放比例 | |
maximum-scale=1:允许用户缩放到的最大比例(对应还有个minimum-scale) | |
user-scalable=no:不允许用户手动缩放 |
View tox_example.ini
# Tox (http://tox.testrun.org/) is a tool for running tests | |
# in multiple virtualenvs. This configuration file will run the | |
# test suite on all supported python versions. To use it, "pip install tox" | |
# and then run "tox" from this directory. | |
[tox] | |
skipsdist = True |
NewerOlder