Skip to content

Instantly share code, notes, and snippets.

View earthday's full-sized avatar
🔋
Power~!

Bright Chen earthday

🔋
Power~!
View GitHub Profile
/*
*
* 此问题源自于BinarySearch中的求中数的小陷阱。
* 查看了微软的源代码,在1.x时代是如line01所示的方案,显然是有错的。
* 在2.0后改为line03,无错。
* 由于疏忽,我上来写成了line02,于是也出错了,一查看原来是优先级没搞混了。
*
*/
using System;
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
<title>Index Page</title>
<style type="text/css">
.yui-skin-sam .yui-dt-liner { white-space:nowrap; }
</style>
<script type="text/javascript">
YAHOO.example.Data = {
bookorders: [
@earthday
earthday / SimpleVimrc
Created January 19, 2016 05:16
Simple vimrc for server
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
@earthday
earthday / app.cpp
Created September 22, 2016 09:28
Run it online from http://cpp.sh/77sn5
#include <iostream>
#include <thread>
using namespace std;
int _id = 1;
class Person
{
public:
static void Main(string[] args)
{
using (SvnClient client = new SvnClient())
{
SvnInfoEventArgs serverInfo;
SvnInfoEventArgs clientInfo;
SvnUriTarget repos = new SvnUriTarget("http://svn.test.com/demo");
SvnPathTarget local = new SvnPathTarget(@"d:\Work\Code\demo");
client.GetInfo(repos, out serverInfo);
@earthday
earthday / SnowFlakeIdWorker.java
Last active November 1, 2016 08:38
Copied from the internet. And maybe the twepoch should be 1288834974657L.
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;
@earthday
earthday / 上海长城宽带右下角广告代码.html
Last active April 16, 2018 12:37
上海长城宽带右下角广告代码
<script language="javascript">
<!--
var ua = navigator.userAgent;
var $IE = (navigator.appName == "Microsoft Internet Explorer");
var $IE5 = $IE && (ua.indexOf('MSIE 5') != -1);
var $IE5_0 = $IE && (ua.indexOf('MSIE 5.0') != -1);
var $Gecko = ua.indexOf('Gecko') != -1;
var $Safari = ua.indexOf('Safari') != -1;
var $Opera = ua.indexOf('Opera') != -1;
var $Mac = ua.indexOf('Mac') != -1;
# https://stackoverflow.com/questions/13484206/cherrypy-url-dispatcher
import cherrypy
class City:
def __init__(self, name):
self.name = name
self.population = 10000
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__)
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)
{