jfo planet

Hope is the best gift that tomorrow gives.

  • 首页
  • 分类
  • 归档
  • 标签
  • 搜索
close

How do I share internet to 2nd router through Mac?

发表于 2015-03-27   |   分类于 Mac OS X
Mac配置:Mac通过USB无线网卡连接外网,还有一个有线网口目标:共享Mac无线网络,让另一台路由连接Mac有线网,上外网 步骤: Make sure the 2nd router is off for now Go to Dock/Finder–>Preferences–>Sharing (Assuming OSX 10.7+) Highlight the 2nd-to-last option (Internet Sharing)–>Select ‘Wi-Fi’ from the ‘Share your connection from’ drop-box Click the check-box next to ‘Ethernet’ in the ‘To computers using:’ section and click the check-box next to ‘Internet Sharing’ to finally enable it. Connect the ethernet cable from your Mac to your router’s ...
阅读全文 »

【zz】Android NDK开发Crash错误定位

发表于 2015-03-19   |   分类于 Android
NDK安装包中提供了三个调试工 具:addr2line、objdump和ndk-stack 参考:http://android.jobbole.com/80685/ (PDF下载)
阅读全文 »

【zz】为什么不能往Android的Application对象里存储数据

发表于 2015-03-13   |   分类于 Android
在一个App里面总有一些数据需要在多个地方用到。这些数据可能是一个 session token,一次费时计算的结果等。通常为了避免activity之间传递对象的开销 ,这些数据一般都会保存到持久化存储里面。 有人建议将这些数据保存到 Application 对象里面,这样这些数据对所有应用内的activities可用。这种方法简单,优雅而且……完全扯淡。 假设把你的数据都保存到Application对象里面去了,那么你的应用最后会以一个NullPointerException 异常crash掉。 一个简单的测试案例 代码Application 对象: // access modifiers omitted for brevityclass MyApplication extends Application { String name; String getName() { return name; } void setName(String name) { this.name = name; } }第一个activity,我们往application对象里面存储了用 ...
阅读全文 »

防止Handler导致的内存泄露

发表于 2015-03-13   |   分类于 Android
先来看一段代码: public class MyActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { doSomething(); } }); } void doSomething() { // Uses the activity instance } } 上面的代码会 ...
阅读全文 »

关于IBinder运行的线程

发表于 2015-03-13   |   分类于 Android
根据官方文档说明 This is primarily true for methods that can be called remotely—such as methods in a bound service. When a call on a method implemented in an IBinder originates in the same process in which the IBinder is running, the method is executed in the caller’s thread. However, when the call originates in another process, the method is executed in a thread chosen from a pool of threads that the system maintains in the same process as the IBinder (it’s not executed in the UI thread of the process) ...
阅读全文 »

iptables NAT

发表于 2014-12-27   |   分类于 Network
SNAT,DNAT,MASQUERADE都是NAT MASQUERADE是SNAT的一个特例,要允许带有内部 IP 地址的 LAN 节点和外部的公共网络通信,需要配置防火墙的 IP 伪装(IP masquerading)。这会把来自 LAN 节点的请求都伪装成防火墙的外部设备的 IP 地址 SNAT是指在数据包从网卡发送出去的时候,把数据包中的源地址部分替换为指定的IP,这样,接收方就认为数据包的来源是被替换的那个IP的主机 DNAT 修改数据包中的目的IP,如果你想让内部网络内的某个服务器能够被外部利用,你可以使用 NAT 内 PREROUTING 链的 -j DNAT 目标来指定该向哪个目标 IP 地址以及端口转发请求连接到内部服务的分组 -j MASQUERADE 用发送数据的网卡上的IP来替换源IP iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source `ifconfig | ...
阅读全文 »

Ubuntu上安装和配置FreeRadius和DaloRadius

发表于 2014-12-22   |   分类于 Linux App
按照后面的那篇文章的步骤做就行了,由于我使用的是xampp作为mysql server和apache server,php5相关包就不需要安装了,但是需要如下设置: 使用的xampp版本是xampp-linux-x64-5.5.19,需要下载php-db,将其中的usr/share/php/{DB.php,DB}目录拷贝至lampp/lib/php目录 ln -sv /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock否则freeradius服务启动报错,无法连接mysql server 配置lampp/apache2/conf/httpd.conf,添加 <VirtualHost *:80> DocumentRoot "/opt/www/daloradius" ServerName "your.server.domain" ServerAlias "your.server.domain" <Directory "/opt/www/daloradius"> Options ...
阅读全文 »

websocket协议

发表于 2014-12-13   |   分类于 python/js/php/html/mysql/http
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-------+-+-------------+-------------------------------+ |F|R|R|R| opcode|M| Payload len | Extended payload length | |I|S|S|S| (4) |A| (7) | (16/64) | |N|V|V|V| |S| | (if payload len==126/127) | | |1|2|3| |K| | | +-+-+-+-+-------+-+-------------+ ...
阅读全文 »

通过android permission获取Linux guid权限

发表于 2014-11-14   |   分类于 Android
先来看一个实例,通过BLUETOOTH_STACK和DIAGNOSTIC permission获取linux的net_bt_stack和input guid权限 1.在app的AndroidManifest中声明如下permission,BLUETOOTH_STACK将应用加入到net_bt_stack用户组,可读写/dev/uinput设备,DIAGNOSTIC将应用加入到input组,可读写/dev/input/下的event设备 <uses-permission android:name="android.permission.BLUETOOTH_STACK" /> <uses-permission android:name="android.permission.DIAGNOSTIC" /> 2.用platform签名给应用apk签名以上两个权限都是要platform签名的 java -jar out/host/linux-x86/framework/signapk.jar build/target/pro ...
阅读全文 »

sensors data get/set from android emulator sensor socket

发表于 2014-11-08   |   分类于 Android
android emulator在初始化时会为sensor单独开一个socket,端口为1970,监听外部应用(比如eclipse调试工具)传递的模拟sensor数据 socket创建过程大致如下图所示: 可以看到,最后从socket接受到的外部模拟sensor数据通过android_sensors_set()存放在hw-sensors.c中,这与《sensors data get/set from android emulator console》中用console设置传感器数据类似 具体如何使用1970这个socket端口,可以参考android源代码目录下的sdk/apps/SdkController,它将实体手机的传感器数据传递给模拟器,但目前有bug,可以从https://github.com/jfojfo/VirtualSensors下载fix bug的版本
阅读全文 »
1234…61
jfo

jfo

605 日志
38 分类
4 标签
RSS
GitHub 微博
友情链接
  • 收藏夹
  • 网络剪贴板
  • 爱逛吧
© 2007 - 2018 jfo
由 Hexo 强力驱动
主题 - NexT.Pisces