Android Studio版本升级后编译原有工程,出现错误:clang++: error: no such file or directory: 'CMakeFiles/native.dir/src/main/cpp/native.cpp.o',尝试过网上建议的修改工程设置等各种方法均无效,最终解决办法:
$ rm -Rf .externalNativeBuild/
阅读:52
Android Studio版本升级后编译原有工程,出现错误:clang++: error: no such file or directory: 'CMakeFiles/native.dir/src/main/cpp/native.cpp.o',尝试过网上建议的修改工程设置等各种方法均无效,最终解决办法:
$ rm -Rf .externalNativeBuild/
阅读:52
# apt-get install phpmyadmin
# cd /var/www/html
# ln -s /usr/share/phpmyadmin phpmyadmin
若果登录时遇到错误:#2002 无法登录mysql服务器,可做如下修改解决:
# vi /etc/mysql/my.cnf
将:bind-address = 127.0.0.1 修改为:bind-address = localhost
阅读:10
使用Android Studio时发现一个怪现象,即使下载了SDK对应的文档,每次按F1时也会出现Fetching Documentation...,等待很久才能看到文档。研究后在Stack Overflow找到了答案,经测试可行:
Delete all javadoc paths from jdk.table.xml. Path to this file on OS X: /Users/.../Library/Preferences/AndroidStudio.../options/jdk.table.xml
--> Delete all of these and all occurrences --><javadocPath>
<root type="composite">
<root type="simple" url="http://developer.android.com/reference/" />
</root>
</javadocPath>
阅读:72
chmod +a "staff allow read,write,file_inherit,directory_inherit" /path/dir
chmod +a "staff deny delete,file_inherit,directory_inherit" /path/dir
阅读:6
每次升级iOS后就不得不升级xCode,而且默认总会引导至App Store进行更新(即使从apple.com进入也一样)。其实所有工具都可以直接从官方网站通过http下载,并且支持迅雷。链接地址:https://developer.apple.com/download/more/
阅读:19
大家有没有发现使用uGUI的游戏发布到手机后,点击放在ScrollRect中的按钮有时候会不起作用?这个问题的原因是因为ScrollRect滚动阈值设置得过于灵敏,一旦手指点击时轻微移动导致了滚动,就不会触发OnClick事件了。 继续阅读Unity UI的ScrollRect中的Button点击不灵敏的问题
阅读:83
某线上服务器的mysql突然崩溃后,重启一直失败。查看mysql的error.log发现如下错误信息:
InnoDB: Serious error! InnoDB is trying to free page 716 InnoDB: though it is already marked as free in the tablespace! InnoDB: The tablespace free space info is corrupt. InnoDB: You may need to dump your InnoDB tables & recreate the whole InnoDB: database!
尝试了各种修复方法均告失败,看来只能重建数据库了。
首先解决无法启动的问题(参见http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html的说明):
先添加如下设置到my.cnf:
# vi /etc/mysql/my.cnf [mysqld] innodb_force_recovery = 1
保存my.cnf退出vi后重启mysql:
# service mysql start
但重启依然失败。
按上述官方文档提示,尝试提高recovery级别到2:
[mysqld] innodb_force_recovery = 2
这次重启成功了,并且可以正常查询,但此时mysql处于只读状态,无法做update、delete等写操作。下面开始尝试先备份再恢复全部数据库。
1、备份全部数据库
mysqldump -uroot -p -AER > /root/recovery_dump.sql
2、删除全部数据库
mysql> SET FOREIGN_KEY_CHECKS=0; mysql> DROP DATABASE db1; mysql> DROP DATABASE db2; ...
如果数据库太多,可使用如下命令批量删除。注意:<password>应该替换为真实密码。
# mysql -uroot -p<password> -e "show databases" | grep -v Database | grep -v mysql| grep -v information_schema| grep -v test | grep -v OLD |gawk '{print "drop database " $1 ";select sleep(0.1);"}' | mysql -uroot -p<password>
3、停止mysql。注意应该禁用innodb_fast_shutdown,确保mysql完全停止。
# mysql -uroot -p -e "SET GLOBAL innodb_fast_shutdown = 0" # service mysql stop
阅读:74
抽象基类和接口有很多类似的地方,那么我们在软件架构的过程中如何决定该用抽象基类还是接口呢?Stack Overfollow上有一个回答总结得比较好,虽然只有短短几十个字:
Abstract classes and interfaces are semantically different, although their usage can overlap. An abstract class is generally used as a building basis for similar classes. Implementation that is common for the classes can be in the abstract class. An interface is generally used to specify an ability for classes, where the classes doesn't have to be very similar.
可以这么理解:基类是爹,接口是能力。爹只能有一个,而且他决定了你是什么,但能力可以有多个。
应该考虑使用抽象基类的场景:
阅读:131
前不久在Amazon购买了一台EC2服务器运行WordPress,配置为双核CPU,内存1G。运行了一段时间后,发现mysql经常崩溃。检查mysql的error.log发现,崩溃前最后一条日志是:
160328 16:50:26 InnoDB: Completed initialization of buffer pool 160328 16:50:26 InnoDB: Fatal error: cannot allocate memory for the buffer pool 160328 16:50:26 [ERROR] Plugin 'InnoDB' init function returned error. 160328 16:50:26 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 160328 16:50:26 [ERROR] Unknown/unsupported storage engine: InnoDB 160328 16:50:26 [ERROR] Aborting
因为网站访问量比较大,推测可能是系统内存不足导致的。使用下面的命令查看了一下,发现apache已经使用了60%多的内存(总内存为1G)。
$ ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Total (MB): "x/1024; print "Average (MB): "x/((y-1)*1024)}' Total (MB): 622.996 Average (MB): 14.8332
apache、mysql都是吃内存的大户,1G屋里内存显然不够用了。使用swapon查看交换文件状态:
$ sudo swapon -s
Filename Type Size Used Priority
OMG,竟然没有。。。那就创建一个。
先创建一个4G的文件:
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=4000 4000+0 records in 4000+0 records out 4194304000 bytes (4.2 GB) copied, 5.12 s, 1203 MB/s
然后把它转变为swap文件: 继续阅读为Ubuntu Linux创建Swap分区
阅读:109
#查看系统版本
uname -a
cat /etc/issue
#修改系统时区
#先使用tzselect按提示一步步找到对应的时区,比如Asia/Shanghai,然后:
echo "Asia/Shanghai" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata
#查看进程侦听的端口
lsof -iTCP -sTCP:LISTEN -n -P
#查看目录大小(h:自动使用最佳可读单位,c:最后显示总大小)
du -hc /path
du -k /path | sort -nr
#查看磁盘使用情况
df -h
#创建空文件
touch filename
阅读:181