↓ Skip to main content
  1. Categories/

工程

2017

cpp vector学习笔记

·785 words·2 mins
起因是百度实习二面的时候被问了一道类似这样的题: 给我下面的代码,问有没有什么问题。 1/* *********************************************** 2Author :111qqz 3Created Time :2017年02月28日 星期二 14时49分37秒 4File Name :vector.cpp 5************************************************ */ 6#include <cstdio> 7#include <vector> 8#include <ctime> 9using namespace std; 10int func( int x ) //此处函数的条件是不单调...这样才可以触发问题. 11{ 12 return (x-50)*(x-50)+1; 13} 14int main() 15{ 16 17 vector<int>vec; 18 int *pint = NULL; 19 for ( int i = 0 ; i < 100 ; i++) 20 { 21 int x = func(i); 22 vec.push_back(x); 23 if (x<500) 24 { 25 pint = & vec[0]; 26 } 27 } 28 if (pint) 29 *pint = 0 ; 30 int siz = vec.size(); 31 for ( int i = 0 ; i < siz ; i++) printf("%d\n",vec[i]); 32 return 0; 33} 面试的时候只给了部分代码,func函数没有给出。

2016

manjaro安(zhe)装(teng)记

·730 words·2 mins
噫。。之前x200上装的是win7+fedora25 gnome。。。 虽然感觉gnome对于09年的老电脑来说有点吃力…不过也懒得换.. 结果硬盘挂了2333 于是换了块硬盘

搭建论坛历程

·547 words·2 mins
。。。由于一些不可描述的原因。。。 和某个华师计科的妹子一拍即合。。。打算搞一个论坛出来。。。 算是做一些微小的贡献2333 一开始打算尝试dz…毕竟社区比较丰富…服务器的话。。先拿个免费的搭起来再说https://www.hostinger.com.hk/

database connection error 的解决方案

·854 words·2 mins
其实 东西之前出现过…不过好像重启一下服务器就可以了? 这次比较麻烦。 一开始我是直接 google 了这条错误信息,结果答案五花八门,或者说…可能的原因非常多。

using your computer without mouse

·626 words·2 mins
键盘足够爽了以后。。。 鼠标明显降低效率。。。 学会逐步脱离鼠标吧orz. 首先是chrome插件vimium vimium教程 Vimium 常用的按键功能解释: # 1 * **j:向下细微滚动窗口 k:向上细微滚动窗口** 2 * J:(**Shift+j的意思,以下大写全部表示加Shift)** 下一个标签页 K:上一个标签页 3 * d:向下滚动半个屏幕 u:向上移动半个屏幕 4 * **g+g(连续按两下g):回到顶部** 5 * **G:到达页面底部** 6 * H:后退 L: 前进 7 * f:将当前网页上的所有可见链接/输入框分配一个快捷键,输入后就可以打开或者跳转到对应的输入框。如果按的是F,那么将在新窗口中打开页面(见上图) 8 * g+i:将光标 定位到输入框,如果有多个可以按Tab键切换 9 * x:关闭当前页面 X:恢复刚刚关闭的页面 10 * o:相当于Chrome中的地址栏,可以匹配历史记录、收藏夹并在当前窗口打开,或者直接打开一个网址或者搜索一个关键字(Chrome在全屏的时候地址栏死都出不来,有了它就解决这个一直困扰我的问题了!~),如果按的是O,则可以在新窗口中打开,非常非常方便! 11 * g+s:查看网页的源代码 12 * r:重新载入当前网页(顺便提一句,这点上新浪微博和它是一样的,光标没有定位在发送框时,即便没有安装这个插件你也可以用j/k来控制页面上下滚动,用r在刷新,用f或者p来定位到发送框。而Gmail的快捷键如j,k上下移动光标也是类似,有兴趣大家可以再自己去了解一下一些常用web应用的快捷键)

fedora 24 cannot modify keyboard delay and rate

·176 words·1 min
最近入手了x1 c 然后发现没办法支持 f22….. 没办法,只好上f24了。。。虽然明知道一堆bug… 最近发现。。之前在系统设置->键盘->打字 中的调整键盘延迟和速率的选项。。。不见了。。。

c++11 学习笔记

·172 words·1 min
昨天终于搞定了ycm对c++11的支持…. 嘛,17都快出来了,我竟然连11都不会用。 不过突然把所有的11特性给我也没办法全部吸收。 所以在这里记录下用过的c++11的用法。

c语言中static的作用

·185 words·1 min
一般有两个 1static int a; 2int b; 3void func(void) 4{ 5 static int c=0; 6 int d; 7} 在这里,a与b都是全局变量,二者的区别是,b可以被别的文件使用,a只能在本文件中使用,这是static对全局变量的作用。 ** c和d的区别是,d是一个自动变量,func函数执行完后,d会自动被释放。但c却不会被释放,下一次调用func函数时,c的值会保留上次的值继续使用(而不是初始值0,初始化只会在函数第一次被调用的时候执行)**

2015

在linux mint 上安装 Oracle JDK 的方法

·154 words·1 min
Open up the Terminal (Alt + F2 > Terminal). Remove OpenJDK installation. 1sudo apt-get update && apt-get remove openjdk* Download Oracle JDK from here. You are looking for a linux version with tar.gz extension. Also choose the right version from 32-bit (x86) and 64bit (x64) one. Change directory into one with downloaded tarball. In my case $HOME/Downloads. 1cd ~/Downloads Extract tarball. Replace with a name of dowloaded file. (just press Tab and it will be autocompleted.) 1tar -zxvf jdk- As a root create a folder in /opt where jdk will be stored. 1sudo mkdir -p /opt/java Move extracted folder to /opt/java. In my case, version number was 1.7.0_25. 1sudo mv jdk1.7.0_25 /opt/java Make JDK system default. 1sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_25/bin/java" 1 2 3sudo update-alternatives --set java /opt/java/jdk1.7.0_25/bin/java Test installed java version. java version “1.7.0_25” Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

atom在linux下安装插件失败的解决方案

·272 words·1 min
1gyp info it worked if it ends with ok 2gyp info using node-gyp@2.0.2 3gyp info using node@0.10.40 | linux | x64 4gyp http GET https://atom.io/download/atom-shell/v0.34.0/node-v0.34.0.tar.gz 5gyp WARN install got an error, rolling back install 6gyp ERR! install error 7gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and 8gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy or have bad 9gyp ERR! stack network settings. 10gyp ERR! stack at Request.<anonymous> (/opt/atom/resources/app/apm/node_modules/npm/node_modules/node-gyp/lib/install.js:234:21) 11gyp ERR! stack at Request.emit (events.js:95:17) 12gyp ERR! stack at Request.onRequestError (/opt/atom/resources/app/apm/node_modules/npm/node_modules/request/request.js:861:8) 13gyp ERR! stack at ClientRequest.emit (events.js:95:17) 14gyp ERR! stack at Socket.socketErrorListener (http.js:1548:9) 15gyp ERR! stack at Socket.emit (events.js:95:17) 16gyp ERR! stack at net.js:834:16 17gyp ERR! stack at process._tickCallback (node.js:448:13) 18gyp ERR! System Linux 3.16.0-38-generic 19gyp ERR! command "/opt/atom/resources/app/apm/bin/node" "/opt/atom/resources/app/apm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "install" "--target=0.34.0" "--dist-url=https://atom.io/download/atom-shell" "--arch=x64" "--ensure" 20gyp ERR! cwd /home/rkz2013/.atom 21gyp ERR! node -v v0.10.40 22gyp ERR! node-gyp -v v2.0.2 23gyp ERR! not ok 解决办法是不用apm install 而是用npm install…之前要安装一个npm