Thomas会Coding的博客
Thomas会Coding · 共 87 篇文章
android studio 添加第三方library (有图)
最近写一个android小项目,需要用到上拉刷新的功能。在github上找了一个比较经典的。想作为library加入自己的项目中,折腾了半天,终于成功。纪录一下过程。 1:首先新建一个android项目。 2:将github上pullToRefresh的项目下载到本地。 3:点击android studio的 file->import module . 地址栏需要写到 点击完成后。左边如图所示 点击 library 右键 如下图 make module library 点击app 右键 打开 open module setting app-->dependencies 上面显示的是将libr…
2015-05-20 20:22 · android · 评论(0)
利用百度地图sdk定位 要注意的
最近有个小项目需要进行一些定位的操作,找来找去,觉得百度做的还是比较好的。 就记录一点, MainActivity.java public class MainActivity extends Activity { public LocationClient mLocationClient = null; public LocationClientOption option; public BDLocationListener myListener = new BDLocationListener() { @Override public void onReceiveLocation(BDL…
2015-05-18 11:46 · android · 评论(0)
Reverse Linked List II (链表的前插操作)
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. 这一题的主要就是链表的逆序,逆序比较好的解法有前插,利用栈,这里我们使用前插的方式解决 先看代码 /** * Defin…
2015-04-26 12:11 · leetcode · 评论(0)
mac 10.10.2 下maven 安装
既然要安装maven,首先得下载吧。 mac上面安装软件的方式其实很简单 1:sudo brew install maven; 是不是很简单,一条语句搞定。 接下来就是让人头疼的问题了,当使用mvn -v 的时候出现了错误提示 Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java 好吧,这个错误的原因是我们的JAVA_HOME还没有设置。 有点晕哟。。。 因为当时安装jdk的时候使用的也是 brew install 命令。当时没记得配置过环境变量呀。 估计bre…
2015-04-18 23:19 · maven · 评论(0)
hashmap的remove异常问题
jdk为什么这样设计,只允许通过iterator进行remove操作? HashMap和keySet的remove方法都可以通过传递key参数删除任意的元素,而iterator只能删除当前元素(current),一旦删除的元素是iterator对象中next所正在引用的,如果没有通过modCount、 expectedModCount的比较实现快速失败抛出异常,下次循环该元素将成为current指向,此时iterator就遍历了一个已移除的过期数据。
2015-03-30 16:39 · 评论(0)
根据图片名称动态生成id
for(int i=0;i<15;i++){ int id=getResources.getIdentifier("**"+i,"drawable",mContext.getPackageName()); } 使用循环获取一组资源的id的方法
2015-01-21 16:15 · android · 评论(0)
leetcode-Evaluate Reverse Polish Notation
Valid operators are + , - , * , / . Each operand may be an integer or another expression. public class Solution { public int evalRPN(String[] tokens) { int result=0; List<Integer> arrayList=new LinkedList<Integer>(); int temp1=0; int temp2=0; for(String temp:tokens){ if(temp.compareTo("+")==0){ tem…
2015-01-21 12:09 · leetcode · 评论(0)
leetcode-Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9] , the largest formed number is 9534330 . Note: The result may be very large, so you need to return a string instead of an integer. public class Solution { public String l…
2015-01-21 11:05 · leetcode · 评论(0)
Python下载echo歌曲
最近在echo上面听到一首歌,一个6岁小女孩唱的“ I will always love you ”,简直是天籁, http://echo.kibey.com/sound/198168。你们也可以试试,真的很好听 想下载的时候发现还要装什么客户端。不爽。。。 简单分析了一下,结果就发现轻轻松松就下载了。。。。 1:打开网页发现没有什么验证就可以直接听了,说明没什么验证,只要给定特定的url就直接定位到音乐资源了。关键找到正确的url。 2:打开chrome ,打开网页的时候监视网络连接。 根据Size 我们很容易就定位到请求歌曲的那条url了。 找到真正的请求资源http://7fvgtj.…
2015-01-12 16:19 · python · 评论(0)
os.rename widnowsError [error 2] 错误的解决过程
今天需要对一系列的图片进行重命名。想到Python的listdir 和rename命令。觉得分分钟搞定的事情 于是开始搞起 图片的命名规则是icon_weather_day_00.png.重命名为d00.png 第一版如下 import os; import sys path="weather" for name in os.listdir(path): newName='d'+name.split('_')[3] os.rename(name,newName) 结果就出现了 windowserror 【error 2 】的提示了。 网上找原因说要把工作目录切换到当前目录 于是又有了第二版 …
2015-01-04 16:57 · python · 评论(0)
Python的图形化模块Tkinter的一些用法
#-*- encoding=UTF-8 -*- from Tkinter import * from ttk import * import os def get_sub_path(path): if os.path.isdir(path): for sub_path in os.listdir(path): get_sub_path(path+'\\'+sub_path) else: if os.path.splitext(path)[1].find('java')>0: count_line(path) def count_line(path): count_p=0 global cou…
2014-12-30 21:23 · python · 评论(0)
Python操作sqlite数据库的一些记录
Python 内置了sqlite的模块 import sqlite3 connection=sqlite3.connect('coachdata.sqlite') cursor=connection.cursor(); '''cursor.execute("""create table athletes(id integer primary key autoincrement unique not null, name text not null, dob date not null )""")''' #创建表 #cursor.execute("insert into athletes(na…
2014-12-28 21:36 · python · 评论(0)
Error: ENOENT, stat 'C:\Users\PC111\AppData\Roaming\npm'(转)
windows上运行npm 报Error: ENOENT, stat 'C:\Users\PC111\AppData\Roaming\npm' 错误解决方法 在windows上装好了node.js 版本为:v0.10.30 。由于不是用的默认安装路径,需要在 报错的路径下 建个名为 npm的文件 ,不要带后缀名哦。报错路径为: C:\Users\“你用户名”\AppData\Roaming\ 这个路径下建个npm文件即可正常使用npm 命令了!
2014-12-23 21:09 · nodeJs · 评论(0)
Python 使用htmlParser下载论坛歌曲
#encoding='GB2312' import requests import os from HTMLParser import HTMLParser print '本脚本可以帮助您下载K歌之王中上传的歌曲'+'\n' bourl = "http://bbs.byr.cn/board/KaraOK" filepath= 'python/' headers = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, co…
2014-12-23 15:02 · python · 评论(0)
'ascii' codec can't decode byte 0xcc in position 0: ordinal not in range(128)(转)
在Django视图函数中经常出现类似于'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)的错误。 在解决错误之前,首先要了解unicode和utf-8的区别。 unicode指的是万国码,是一种“字码表”。而utf-8是这种字码表储存的编码方法。unicode不一定要由utf-8这种方式编成bytecode储存,也可以使用utf-16,utf-7等其他方式。目前大多都以utf-8的方式来变成bytecode。 其次,python中字符串类型分为byte string 和 unicode s…
2014-12-22 15:42 · python · 评论(0)