夜记 3/21/2016

这几天一直在计划事情,可是很多事情都没完成,这个星期一定抓紧每一分每一秒。
不过最近心态转暖,可能是春暖花开的原因吧。很长时间之前我还是一个喜欢秋天的男生,金色的季节里视野和声音都变得格外的清晰,事情也慢慢的水落石出。
其实有些事情没必要弄得那么明白,或者说弄明白了反而更加难受。我一度简直是个自虐狂,知道有些事情不能看,可还是忍不住,受伤了后又忍不住再一探究竟。直到发现自己越是受伤,越是难受越可能带给周围人负能量,结果后知后觉的更加难受。
直到摔倒了才明白还有多远的路还在脚下。
我曾说,我来到这个世界就是为了拿回本来就属于我的东西。
口气好大。
现在发现这世间本来没有什么事物本来就属于我们的,以后也未必。
我开始庆幸每一个相遇,感激每一次重逢,慢慢的适应每一次离别。
我开始会说不,开始爱自己。
我开始学着欣赏做的每一件事,品位每一种体验。
慢慢的我不怕了
因为得到和失去都是无关紧要的
远不及在你和在我心理留下的印记。

Springboot: controller access files through Resource Interface

Access files through classpath.

Springboot will  scan /META-INF/resources/; /resources/; /static/ and/public/ folders when you tell it find something in the “Classpath”. 

Using Resource interface to instantiate an ClassPathResource. 

		Resource resource =new ClassPathResource("RelativePathOfYourFile, root of  /META-INF/resources/; /resources/; /static/ or /public/");
		
		try {
			String path =resource.getFile().getAbsolutePath();
			
		} catch (IOException e) { 
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

古刹边残月映竹柏,中庭下秋水照闲人

“你有一种特殊的品质,那就是不管多困难,你都回去尝试,坚持不懈。这是你的优点,不要失去他,总有一天你会变得更加成功。”

这是结项时教授跟我说的,是我大学四年来第二次被这样的肯定。

第一次是软工的教授为我写了一封推荐信,我捧着这封推荐信毛遂自荐,发了100多封简历最终拿到了一家公司的实习。那一年我大二,那一年我遇到了她,那一年我买了车出去旅游,那一年禹哥来到了东部跟我一起过生日。现在想想大二可真是我最幸福的一年,虽然生活非常非常的窘迫,但生活本身总是给我意想不到的惊喜。

一转眼,自己大四了,做得项目越来越多,校园里我也能算是最有资历的那波人了。新生都叫我学长,呵呵,其实我并不喜欢这个称呼,每次都说让他们叫我名字。年龄越来越大,有的新生和我差了将近6岁。打住,我此刻要自恋一下,我越来越成熟了。

这四年遇到很多长者,每次遇到他们我都会想起我的祖父,他们如同他一样仁慈,善良,严格甚至苛刻。但是每当我遇到问题,百思不得其解的时候他们都会默默的陪在我身边,度过那段痛苦的成长。有天晚上可笑的想起小的时候我曾经认为身边的老师都是我家人化妆变得,但笑着笑着,一滴眼泪不自觉的从眼角流了下来。想家么?三年没回了。

那天正是我大三暑假低落的时候,感觉各种不被人理解,各种自我否定,心碎,心累,每天晚上把自己喝醉才能入睡。就像禹哥说过的一样,我从一步一步往前爬,变成一步一步走,然后开始跑。跌倒了再爬起来,坚持不懈,精诚之至乃金石为开。这一次就是摔得疼了些,想想当年在北京的痛苦岁月不也是扛过来了么,这次也是一样。这一次,我擦干眼泪继续前行,原谅别人原谅自己。

我18岁的时候曾经在北京哭过两次,第一次是学习工作生活变得各种不稳定,某人失约,自己变成散人,何去何从自己需要自己调理。禹哥问我,你认为你能扛过去么,我装着胆子硬着嘴说能。自从那天起他就各种帮助这个嘴硬的我。第二次是我想上大学,但是前途面临各种困难。拿到大学offer的时候,那天给家打电话,通话内容从每天的剪短两句报平安,变成很严肃的谈未来的去向,看着西操场的夕阳,心里回想起迎着朝阳上班,披着落日自修托福的岁月,不甘的泪如泉涌,歇斯底里得宣泄和怒吼。为什么,为什么我付出了这么多还是不得安宁。祖父淡淡的说,孩子这就是人生啊。

 

这一路走过来的梦,过去的自己看到会很欣慰吧。可是,当初我在高中教室里写下这句歪诗时,微笑着的大家现在都到了哪里呢。我,想你们。

我,还是那个一直说要追梦的我。

我,以及过去所有的我,齐心合力一定要把这次项目做好,给我此阶段的学生生涯画上一个圆满的句号。

“硬是百折千磨也要依自己心意而活,不管经历多少挫折苦难,仍然一往无前,永不言悔!”

 -古剑奇谭                            

Fix delete()function

Let’s have a look on the code in DataStore class (in the core).

 /**
         * Deletes the given object and returns the object if successful
         * @param The object to be deleted
         * @return The object being deleted
         */
        public <T> T delete(T aTNG){
                // Please see Wiki for more information on the ServerConfiguration.
                ClientConfiguration config = Db4oClientServer.newClientConfiguration();
                config.common().reflectWith(new JdkReflector(Thread.currentThread().getContextClassLoader()));

                logger.log(Level.FINE, "Database Delete Attempt...");
                //ObjectContainer client = server.openClient();
                ObjectSet<T> result = theDB.queryByExample(aTNG);
                T found = (T) result.next(); //<--- will send out exception:java.lang.IllegalStateException
                                                             //if "result" is empty.
                theDB.delete(found);
                theDB.commit();

                logger.log(Level.FINE, "Database Delete Success!");
                //return "Deleted "+aTNG;
                return found;

        }

Problem Analysis: 

In this term, many groups used Calendar object to store date information. However, it seems that calendar(or say GregorianCalendar) cannot be parsed and compared in db4o database.This makes queryByExample() method cannot locate the data we find. So if we pass a commitment, which we wanna delete from the database, to this method the  ObjectSet<T> result = theDB.queryByExample(aTNG);, it cannot find the one in the database and return an empty result collection. Then when we use .next() method on an empty collection, we will get errors. This is the reason why we pass the thing we wanna delete to the database, and the database can’t delete it and give us an error.

Solution: 

Since CalendarItem have a unique id. We just make a null CalendarItem(eg. CalendarItem(null,null,null)) and set it’s id to the one we wanna delete, and pass it to the delete method in the DataStore.

e.g:

public boolean deleteEntity(Session s, String id) throws WPISuiteException{

ensureRole(s, Role.ADMIN);

Commitment oldComm = new Commitment(null,null,null);

oldComm.setId(Integer.parseInt(id));

Commitment deletedComm = db.delete(oldComm);

if (deletedComm != null){

System.out.println("Here is deletEntity method. ---> delete Succesfull");

return true; // the deletion was successful

}   

System.out.println("Here is deletEntity method. ---> delete Fail");

return false; // The deletion was unsuccessful

}

 

Details:

1.queryByExample is the same as get() (deprecated) method  in the db4o.

Reference: http://www.db4o.com/about/productinformation/resources/db4o-6.3-tutorial-java.pdf

CSS基本笔记(CSS Memo)

1. Reasons to use CSS: DRY, Clean

Examles: 1.

<h1 style="color: #98c7d4;"> Hellow World! </h1>
2.
<head>
<style>
h1 { color: #98c7d4; }
</style>
</head>

This two way maybe will repeat numerous times, so the paragraph of code will be large. The best way is making a External sheet in the following way:

<head>
<title>CSS Cross Country</title>
<link rel="stylesheet" href="styles.css" />
</head>

This will make your codes DRY(Don’t Repeat Yourself)


2.Cascade Order(something about the code priority)

 

Using !important < Inline style arttribute  < In the <head>  < External <link>

 


3.Primary DOM selectors

Example:

<h1 class="intro" id="header">Hello World!</h1>

-Element selector
h1{
 color:#aba4ac;
 margin-bottom:10px;
}
-Class selector
.intro{
  color:#abc4ac;
  margin-bottom:10px;
}
-ID selector
#header{
  color:#abc4ac;
  margin-bottom:10px;
}

4.Float <float: left/right/none;>

when we put pictures and paragraphs in a container, we could us Float to deal with their relation.

*Floated elements stack up to the parent edge, then move down to the next available edge. 

*Take care with elements that have differing heights-the first available edge isn’t always below.

 

Clearfix

/*Originally developed by Tony Aslett and Refined by Nicholas Gallagher */
.group:before
.group:after{
  content:"";
  display:table;
}
.group:after{
  clear:both;
}
.group{
  zoom:1;/*IE6&7*/
}

 

5. Inheritance & Specificity

Override parent properties: nested selector

    0      ,0     ,0     ,0

inline style     #if ID       #of class   #of element

 

 6.BOX

Total box width = content width + padding width +border width

 

Box overflow:

overflow: visible /auto/hidden /scroll

↑when content beyond the container boundaries;

 

Positioning:<position: static/relative/absolute/fixed;>

 

Z-index:

z-index:1;

↑Overlaping

Example:

<article>

  <img class="Green" src="Green.jpg" alt="Ski!"/>

  <img class="sled" src="sled.jpg" alt="Sled!"/>

</article>
.Green, .Brown{

  z-index:1;

}
.Brown{

  z-index:1;

}

In these case the Brown class should be above the Green class

 

7. Display Types:<display: block/inline/inline block;>

block:<div><p><ul><ol><li>

inline:<span><a><em><img>

 

8.Horizontal Centering

In block level:

margin: 0 auto;

in inline block level:

text-align:center;

 

9. Image Cropping

Solutions:

Overflow:hidden;

Or we could

.cropping img {

  height: 300px;

  width:auto;

}

 

To see a world in a grain of sand

To see a world in a grain of sand

To see a world in a grain of sand
And a heaven in a wild flower,
Hold infinity in the palm of your hand
And eternity in an hour.

                                          -William Blake

SSS:SCIENTIFIC AMERICAN 60-SECOND SCIENCE 科学美国人60秒『PDF+内嵌音频』

科学美国人60秒:

科学美国人60秒是Scientific American(《科学》的姊妹)下的一个60秒科学趣味播报专栏,语速快且清晰,精炼且经典。平时有时间每天听上一段,日积月累听力就会大大提升。本人在备考托福的路上很喜欢拿这个练听力,每次听完这个再听TPO就感觉TPO的语速慢了很多很多。 继续阅读“SSS:SCIENTIFIC AMERICAN 60-SECOND SCIENCE 科学美国人60秒『PDF+内嵌音频』”

成功不在于坚持了多久,而在于你能否继续坚持

遇到你之前,我以为爱是惊天动地,爱是轰轰烈烈抵死缠绵;我以为爱是荡气回肠,爱是热血沸腾幸福满满;我以为爱是窒息疯狂,爱是炙热的火炭。婚姻生活牵手走过酸甜苦辣温馨与艰难,我开始懂得——爱是经得起平淡的流年。 ——《全世爱》苏小懒 继续阅读“成功不在于坚持了多久,而在于你能否继续坚持”