packagemainimport"fmt"funcmain(){str:="你好"//6str1:="hello"//5//len()获得长度fmt.Println(len(str))fmt.Println(len(str1))}转换成切片,解决中文乱码packagemainimport"fmt"funcmain(){str:="hello你好"//6fori:=0;i
golang学习笔记--函数
飞鸟malred
golanggopher笔记golangjava开发语言
funcmain(){varaint=1varbint=2c:=add(a,b)fmt.Println(c)}funcadd(aint,bint)(int){returna+b}函数调用机制值传递packagemainimport"fmt"functest(nint){n+=1fmt.Println("test-n=",n)}funcmain(){n:=10//根据赋值推断类型test(n)fmt
golang学习笔记--包
飞鸟malred
golanggopher笔记golang开发语言后端
实例:导入时要写相对路径(默认从根目录src开始算)packagemainimport("fmt""learn01/src/packTest/utils")funcmain(){varcint=0c=utils.Add(1,2)fmt.Print(c)}packageutils//名称第一个字母要大写funcAdd(aint,bint)(int){returna+b}被导入的包函数需要首字母大写,
golang学习笔记--接收键盘输入
飞鸟malred
gopher笔记golanggolang学习开发语言
获取用户输入的数据1,导入fmt2,调用方法1,scanln直到用户输入换行符才会停止扫描,可以看作扫描一行(推荐)packagemainimport"fmt"funcmain(){varnamestringvaragebytevarsalfloat32varisPassboolfmt.Print("请输入姓名")fmt.Scanln(&name)fmt.Print("请输入年龄")fmt.Sca
GoLang学习笔记之进阶编程(一):文件操作
Allen-LuLu
GoLang进阶golang开发语言后端
目录一、文件信息的获取二、文件的基本操作2.1.创建文件2.2.读取文件2.2.1.IO接口直接读2.2.2.带缓冲区的读(bufio)2.2.3.ioutil包直接读2.3.写入文件2.3.1.IO接口直接写2.3.2.带缓冲区的写(bufio)2.3.3.ioutil包直接写2.4.文件拷贝2.5.文件光标置位2.6.删除文件三、练习3.1.使用三种不同的方式实现文件拷贝3.2.断点续传3.3
GoLang学习笔记之进阶编程(四):标准库常用包
Allen-LuLu
GoLang进阶golang开发语言后端
目录前言一、Sort包的基本使用二、Time包的基本使用2.1.获取时间2.2.格式化时间2.3.从字符串中解析时间2.4.获取时间戳2.5.时间的加减运算三、Flag包的基本使用四、net/http包的基本使用五、context包的使用5.1.WithCancel()5.2.WithDeadLine()5.3.WithTimeOut()5.4.WithValue()总结总结前言GO语言标准库为我
Golang学习笔记
爱上的云
golang学习开发语言
Golang学习网站菜鸟教程Go语言教程|菜鸟教程进度:Go语言常量Go语言入门教程(语言中文网)Go语言入门教程,Golang入门教程(非常详细)https://kaifa.baidu.com/开发者搜索开发者搜索-Beta-让技术搜索更简单高效Bilibili教学视频8-import导包路径问题与init方法调用流程_哔哩哔哩_bilibili极客时间-训练营《8小时上手Go语言》极客时间训练
golang学习笔记(25)-json序列化与反序列化
-logieeU
jsongolang学习
-json序列化与反序列化目录-json序列化与反序列化json数据格式json序列化反序列化小结json数据格式再js语言中,一切都是对象。因此,任何的数据类型都可以通过json来表示,例如字符串,数字,对象,数组,map,结构体等,json键值对是用来保存数据的一种方式。键值对组合中的键名在前面并用双引号“”包裹,使用冒号:分割,然后紧跟着值:{“Name”:“ylj”,“age”:18}突出
Golang学习笔记之接口(interface)
学生黄哲
接⼝是⼀个或多个⽅法签名的集合,任何类型的⽅法集中只要拥有与之对应的全部⽅法,就表⽰它"实现"了该接⼝。所谓对应⽅法,是指有相同名称、参数列表(不包括参数名)以及返回值。当然,该类型还可以有其他⽅法。•接⼝命名习惯以er结尾,结构体。•接⼝只有⽅法签名,没有实现。•接⼝没有数据字段。•可在接⼝中嵌⼊其他接⼝。•类型可实现多个接⼝。•引用类型•实现接口不需要显式的声明,只需实现相应方法即可•多个类型
golang学习笔记——面试题 使用 3 个协程顺序打印 cat、dog、fish 各 100 次
怪我冷i
golang从入门到入门golang学习笔记
文章目录面试题使用3个协程顺序打印cat、dog、fish各100次拓展第一种方法第二种方法参考资料面试题使用3个协程顺序打印cat、dog、fish各100次编程题:3个函数分别打印cat、dog、fish,要求每个函数都要起一个goroutine,按照cat、dog、fish顺序打印在屏幕上100次。packagemainimport("fmt""sync")//面试题:每个函数起一个goro
golang学习笔记——数据类型
阿伟学编程~
golang学习golang
目录Go语言基本数据类型整型浮点型与复数布尔型字符串byte和rune类型Go语言基本数据类型数据类型的出现是为了把数据分成所需内存大小不同的数据,编程的时候需要用大数据的时候才需要申请大内存,就可以充分利用内存,Go语言中有丰富的数据类型,除了基本的整型、浮点型、布尔型、字符串外,还有数组、切片、结构体、函数、map、通道(channel)等。整型整型分为以下两个大类:按长度分为:int8、in
golang学习笔记——go语言多文件项目运行的四种方式
怪我冷i
golang从入门到入门golang学习笔记
go语言多文件运行技巧有两个源码文件的go语言项目如何运行?go.modmain.goTrie.go如何直接运行gorunmain.go会提示找不到文件。#在windows10下运行$gorunmain.go#command-line-arguments.\main.go:6:9:undefined:Constructor是真的找不到文件吗。其实不是。我们把鼠标放到Constructor()函数上
golang学习笔记——http.Handle和http.HandleFunc的区别与type func巧妙运用
怪我冷i
golang从入门到入门golang学习笔记
文章目录http.Handle和http.HandleFunc的区别http.Handle分析typefunc巧妙运用http.HandleFunc分析总结参考资料http.Handle和http.HandleFunc的区别http.Handle和http.HandleFunc的区别体现了Go语言接口的巧妙运用下面代码启动了一个http服务器,监听8080端口,并注册路由。实现这两个路由注册的方法
Golang学习笔记-defer关键字学习
LegendGo
defer学习很多现代的变成语言中都会有defer关键字,Go语言的defer会在当前函数或是方法返回之前执行传入的函数,它会经常被用于关闭文件描述符,关闭数据库链接和解锁资源。作为一个编程语言中的关键字,defer的实现一定是由编译器和运行时共同完成的,不过在深入源码分析它的实现之前我们还是需要了解defer关键字的常见使用场景以及使用时的注意事项。使用defer的最常见的场景就是在函数调用结束
golang学习笔记(18)-gin对于文件的接收以及返回
-logieeU
golang学习gin
gin对于文件的接收以及返回目录gin对于文件的接收以及返回接收文件接收文件的方法分析给前端返回文件多文件上传接收文件先根据官方文档,编写一个实现接收文件方法funcmain(){r:=gin.Default()r.POST("/testLoad",func(c*gin.Context){file,_:=c.FormFile("file")c.SaveUploadedFile(file,"./tm
Golang学习笔记-指针的简单使用
亮仔IT哥
Golang
指针的简单使用Go语言中和C/C++一样,直接提供了指针类型,但是不同的是Go语言的指针无法进行位移和运算的,它只是一个存储了其它变量地址的变量而已。它在Go语言中最大的作用就是在值传递的过程中减少内存消耗。注意:&取地址符号*取值的符号
golang学习笔记004--指针
自律成就自由
golanggolang开发语言后端
目录1.基本介绍2.使用细节3.值类型和引用类型1.基本介绍●基本数据类型,变量存的就是值,也叫值类型●获取变量的地址,用&●指针类型,指针变量存的是一个地址,这个地址指向的空间存的才是值●获取指针类型所指向的值,使用*variint=10fmt.Println("i的地址=",&i)//i的地址=0xc0000120a8varptr*int=&i//ptr是一个指针变量//ptr的类型是*int
解读Servlet原理篇二---GenericServlet与HttpServlet
周凡杨
javaHttpServlet源理GenericService源码
在上一篇《解读Servlet原理篇一》中提到,要实现javax.servlet.Servlet接口(即写自己的Servlet应用),你可以写一个继承自javax.servlet.GenericServletr的generic Servlet ,也可以写一个继承自java.servlet.http.HttpServlet的HTTP Servlet(这就是为什么我们自定义的Servlet通常是exte
MySQL性能优化
bijian1013
数据库mysql
性能优化是通过某些有效的方法来提高MySQL的运行速度,减少占用的磁盘空间。性能优化包含很多方面,例如优化查询速度,优化更新速度和优化MySQL服务器等。本文介绍方法的主要有:
a.优化查询
b.优化数据库结构
ThreadPool定时重试
dai_lm
javaThreadPoolthreadtimertimertask
项目需要当某事件触发时,执行http请求任务,失败时需要有重试机制,并根据失败次数的增加,重试间隔也相应增加,任务可能并发。
由于是耗时任务,首先考虑的就是用线程来实现,并且为了节约资源,因而选择线程池。
为了解决不定间隔的重试,选择Timer和TimerTask来完成
package threadpool;
public class ThreadPoolTest {
Oracle 查看数据库的连接情况
周凡杨
sqloracle 连接
首先要说的是,不同版本数据库提供的系统表会有不同,你可以根据数据字典查看该版本数据库所提供的表。
select * from dict where table_name like '%SESSION%';
就可以查出一些表,然后根据这些表就可以获得会话信息
select sid,serial#,status,username,schemaname,osuser,terminal,ma
类的继承
朱辉辉33
java
类的继承可以提高代码的重用行,减少冗余代码;还能提高代码的扩展性。Java继承的关键字是extends
格式:public class 类名(子类)extends 类名(父类){ }
子类可以继承到父类所有的属性和普通方法,但不能继承构造方法。且子类可以直接使用父类的public和
protected属性,但要使用private属性仍需通过调用。
子类的方法可以重写,但必须和父类的返回值类
android 悬浮窗特效
肆无忌惮_
android
最近在开发项目的时候需要做一个悬浮层的动画,类似于支付宝掉钱动画。但是区别在于,需求是浮出一个窗口,之后边缩放边位移至屏幕右下角标签处。效果图如下:
一开始考虑用自定义View来做。后来发现开线程让其移动很卡,ListView+动画也没法精确定位到目标点。
后来想利用Dialog的dismiss动画来完成。
自定义一个Dialog后,在styl
hadoop伪分布式搭建
林鹤霄
hadoop
要修改4个文件 1: vim hadoop-env.sh 第九行 2: vim core-site.xml <configuration> &n
gdb调试命令
aigo
gdb
原文:http://blog.csdn.net/hanchaoman/article/details/5517362
一、GDB常用命令简介
r run 运行.程序还没有运行前使用 c cuntinue 
Socket编程的HelloWorld实例
alleni123
socket
public class Client
{
public static void main(String[] args)
{
Client c=new Client();
c.receiveMessage();
}
public void receiveMessage(){
Socket s=null;
BufferedRea
线程同步和异步
百合不是茶
线程同步异步
多线程和同步 : 如进程、线程同步,可理解为进程或线程A和B一块配合,A执行到一定程度时要依靠B的某个结果,于是停下来,示意B运行;B依言执行,再将结果给A;A再继续操作。 所谓同步,就是在发出一个功能调用时,在没有得到结果之前,该调用就不返回,同时其它线程也不能调用这个方法
多线程和异步:多线程可以做不同的事情,涉及到线程通知
&
JSP中文乱码分析
bijian1013
javajsp中文乱码
在JSP的开发过程中,经常出现中文乱码的问题。
首先了解一下Java中文问题的由来:
Java的内核和class文件是基于unicode的,这使Java程序具有良好的跨平台性,但也带来了一些中文乱码问题的麻烦。原因主要有两方面,
js实现页面跳转重定向的几种方式
bijian1013
JavaScript重定向
js实现页面跳转重定向有如下几种方式:
一.window.location.href
<script language="javascript"type="text/javascript">
window.location.href="http://www.baidu.c
【Struts2三】Struts2 Action转发类型
bit1129
struts2
在【Struts2一】 Struts Hello World http://bit1129.iteye.com/blog/2109365中配置了一个简单的Action,配置如下
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configurat
【HBase十一】Java API操作HBase
bit1129
hbase
Admin类的主要方法注释:
1. 创建表
/**
* Creates a new table. Synchronous operation.
*
* @param desc table descriptor for table
* @throws IllegalArgumentException if the table name is res
nginx gzip
ronin47
nginx gzip
Nginx GZip 压缩
Nginx GZip 模块文档详见:http://wiki.nginx.org/HttpGzipModule
常用配置片段如下:
gzip on; gzip_comp_level 2; # 压缩比例,比例越大,压缩时间越长。默认是1 gzip_types text/css text/javascript; # 哪些文件可以被压缩 gzip_disable &q
java-7.微软亚院之编程判断俩个链表是否相交 给出俩个单向链表的头指针,比如 h1 , h2 ,判断这俩个链表是否相交
bylijinnan
java
public class LinkListTest {
/**
* we deal with two main missions:
*
* A.
* 1.we create two joined-List(both have no loop)
* 2.whether list1 and list2 join
* 3.print the join
Spring源码学习-JdbcTemplate batchUpdate批量操作
bylijinnan
javaspring
Spring JdbcTemplate的batch操作最后还是利用了JDBC提供的方法,Spring只是做了一下改造和封装
JDBC的batch操作:
String sql = "INSERT INTO CUSTOMER " +
"(CUST_ID, NAME, AGE) VALUES (?, ?, ?)";
[JWFD开源工作流]大规模拓扑矩阵存储结构最新进展
comsci
工作流
生成和创建类已经完成,构造一个100万个元素的矩阵模型,存储空间只有11M大,请大家参考我在博客园上面的文档"构造下一代工作流存储结构的尝试",更加相信的设计和代码将陆续推出.........
竞争对手的能力也很强.......,我相信..你们一定能够先于我们推出大规模拓扑扫描和分析系统的....
base64编码和url编码
cuityang
base64url
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
web应用集群Session保持
dalan_123
session
关于使用 memcached 或redis 存储 session ,以及使用 terracotta 服务器共享。建议使用 redis,不仅仅因为它可以将缓存的内容持久化,还因为它支持的单个对象比较大,而且数据类型丰富,不只是缓存 session,还可以做其他用途,一举几得啊。1、使用 filter 方法存储这种方法比较推荐,因为它的服务器使用范围比较多,不仅限于tomcat ,而且实现的原理比较简
Yii 框架里数据库操作详解-[增加、查询、更新、删除的方法 'AR模式']
dcj3sjt126com
数据库
public function getMinLimit () { $sql = "..."; $result = yii::app()->db->createCo
solr StatsComponent(聚合统计)
eksliang
solr聚合查询solr stats
StatsComponent
转载请出自出处:http://eksliang.iteye.com/blog/2169134
http://eksliang.iteye.com/ 一、概述
Solr可以利用StatsComponent 实现数据库的聚合统计查询,也就是min、max、avg、count、sum的功能
二、参数
百度一道面试题
greemranqq
位运算百度面试寻找奇数算法bitmap 算法
那天看朋友提了一个百度面试的题目:怎么找出{1,1,2,3,3,4,4,4,5,5,5,5} 找出出现次数为奇数的数字.
我这里复制的是原话,当然顺序是不一定的,很多拿到题目第一反应就是用map,当然可以解决,但是效率不高。
还有人觉得应该用算法xxx,我是没想到用啥算法好...!
还有觉得应该先排序...
还有觉
Spring之在开发中使用SpringJDBC
ihuning
spring
在实际开发中使用SpringJDBC有两种方式:
1. 在Dao中添加属性JdbcTemplate并用Spring注入;
JdbcTemplate类被设计成为线程安全的,所以可以在IOC 容器中声明它的单个实例,并将这个实例注入到所有的 DAO 实例中。JdbcTemplate也利用了Java 1.5 的特定(自动装箱,泛型,可变长度
JSON API 1.0 核心开发者自述 | 你所不知道的那些技术细节
justjavac
json
2013年5月,Yehuda Katz 完成了JSON API(英文,中文) 技术规范的初稿。事情就发生在 RailsConf 之后,在那次会议上他和 Steve Klabnik 就 JSON 雏形的技术细节相聊甚欢。在沟通单一 Rails 服务器库—— ActiveModel::Serializers 和单一 JavaScript 客户端库——&
网站项目建设流程概述
macroli
工作
一.概念
网站项目管理就是根据特定的规范、在预算范围内、按时完成的网站开发任务。
二.需求分析
项目立项
我们接到客户的业务咨询,经过双方不断的接洽和了解,并通过基本的可行性讨论够,初步达成制作协议,这时就需要将项目立项。较好的做法是成立一个专门的项目小组,小组成员包括:项目经理,网页设计,程序员,测试员,编辑/文档等必须人员。项目实行项目经理制。
客户的需求说明书
第一步是需
AngularJs 三目运算 表达式判断
qiaolevip
每天进步一点点学习永无止境众观千象AngularJS
事件回顾:由于需要修改同一个模板,里面包含2个不同的内容,第一个里面使用的时间差和第二个里面名称不一样,其他过滤器,内容都大同小异。希望杜绝If这样比较傻的来判断if-show or not,继续追究其源码。
var b = "{{",
a = "}}";
this.startSymbol = function(a) {
Spark算子:统计RDD分区中的元素及数量
superlxw1234
sparkspark算子Spark RDD分区元素
关键字:Spark算子、Spark RDD分区、Spark RDD分区元素数量
Spark RDD是被分区的,在生成RDD时候,一般可以指定分区的数量,如果不指定分区数量,当RDD从集合创建时候,则默认为该程序所分配到的资源的CPU核数,如果是从HDFS文件创建,默认为文件的Block数。
可以利用RDD的mapPartitionsWithInd
Spring 3.2.x将于2016年12月31日停止支持
wiselyman
Spring 3
Spring 团队公布在2016年12月31日停止对Spring Framework 3.2.x(包含tomcat 6.x)的支持。在此之前spring团队将持续发布3.2.x的维护版本。
请大家及时准备及时升级到Spring
fis纯前端解决方案fis-pure
zccst
JavaScript
作者:zccst
FIS通过插件扩展可以完美的支持模块化的前端开发方案,我们通过FIS的二次封装能力,封装了一个功能完备的纯前端模块化方案pure。
1,fis-pure的安装
$ fis install -g fis-pure
$ pure -v
0.1.4
2,下载demo到本地
git clone https://github.com/hefangshi/f