Skip to content

Instantly share code, notes, and snippets.

View lexdene's full-sized avatar

Elephant Liu lexdene

  • 中国北京 Beijing China
  • 00:45 (UTC +08:00)
View GitHub Profile
@lexdene
lexdene / bigInt.cpp
Last active August 29, 2015 14:08 — forked from masquevil/bigInt.cpp
#include<iostream>
#include<string>
#include<time.h>
#include "bigInt.h"
using namespace std;
BigInt::BigInt(){ //构造函数
head = tail = temp = NULL;
symbol = '+';
length = 0;
@lexdene
lexdene / zhihu_26161075.cpp
Created October 22, 2014 10:40
zhihu question 26161075 code by lexdene
#include <iostream>
using namespace std;
class Date
{
public:
Date(int y=0, int m=0, int d=0):year(y), month(m), day(d){}
friend bool operator>(const Date& da, const Date& db);
int getyear()const;
int getmonth()const;
@lexdene
lexdene / calc_823.js
Last active August 29, 2015 14:04
calc 823
var i,j;
var result = '';
for(i=2000; i<2100; ++i){
[1, 3, 5, 7, 8, 10, 12].forEach(function(j){
d = new Date(i, j - 1);
if(d.getDay() == 5){
result += d.getFullYear() + '年' + (d.getMonth() + 1) + '月 ';
}
});
@lexdene
lexdene / test_let_variable.el
Created April 3, 2014 07:33
let variable in emacs lisp
(setq elephant "elephant form global")
(defun print-elephant ()
(message elephant)
)
(defun test-let-variable ()
(print-elephant)
(message elephant)
(let ((elephant "elephant from let"))
@lexdene
lexdene / test.md
Created January 23, 2014 03:15
test markdown by gist

test ?

code
@lexdene
lexdene / mysql.index.txt
Last active January 3, 2016 20:19
add an index in mysql
优化前:
+----+-------------+------------+--------+---------------+---------+---------+------------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+--------+---------------+---------+---------+------------------------+------+----------------------------------------------+
| 1 | SIMPLE | ttb | ALL | NULL | NULL | NULL | NULL | 10 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | dt | ALL | PRIMARY | NULL | NULL | NULL | 5 | Using where; Using join buffer |
| 1 | SIMPLE | tc | eq_ref | PRIMARY | PRIMARY | 4 | tp_db.ttb.topic_id | 1 | |
| 1 | SIMPLE | last_reply | eq_ref | PRIMARY | PRIMARY | 4
@lexdene
lexdene / single_instance.java
Last active January 3, 2016 18:29
single instance
class User{
static public function instance(){
static my_user = User()
return my_user;
}
public function setToken(token){
this.token = token
}
for file_path in $(find . -name '*.cpp');do clean_file_path=${file_path:2} ;mv -v $file_path ${clean_file_path//\//_} ; done
# 第1版
for file_path in $(find Images);do clean_file_path=$file_path ;mv -v $file_path ${file_path%/*}/${clean_file_path//\//_} ; done
@lexdene
lexdene / copy_contructor.cxx
Created December 11, 2013 04:12
在C++中,Foo a = Foo()是否会调用复制构造函数。
#include<iostream>
using namespace std;
class Foo{
public:
Foo(){
cout << "Foo constructor" << endl;
}
args = {
'_id': 'xxx',
'group': 123
}
cursor = db.table.find(args)
args.pop('_id')
data = list(cursor)
# 这样得到的data是没有_id = 'xxx'这个条件的查询结果