自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(100)
  • 资源 (3)
  • 收藏
  • 关注

原创 go.泛型+管道 简单的阻塞队列

go在1.18迎来了一次大的改版,引进了相关泛型。这使得在开发过程有了更多的扩展性,可以有效解决功能相同但是代码重复的部分。这次使用泛型+管道的方式实现了一个简单的阻塞队列。对于管道而言就是go提供给我们天然的阻塞队列,我们在此基础上再根据泛型的特性可以完成对于任何类型的队列方式,此队列对于高并发的情况下依旧有效,类似于生产者消费者的应用。直接上code:import ( "context" "time")/** @author: nizhenxian...

2022-03-12 09:14:35 984

原创 goland大数计算(java转go福音)

在go语言中我们知道整形只有byte、int32以及int64等而浮点数只有float32和float64基本数据类型。有时候根据需求需要使用大数操作,go中的big包中带了NewInt以及NewFloat,但是提供的api较少,可供初始化的只能使用基本数据类型。不能使用字符串进行初始化。于是本人参考java的大数类进行开发go-bigger并且提供丰富的API调用。github:github:https://github.com/SineyCoder/go-bigger内置BigIntege..

2021-08-14 11:14:25 806

原创 goLang简单聊天室

有一段时间没写博客了,现在因为工作需要学习了go,做一个小Demo,简单的聊天室。首先服务端开启监听8889端口,监听每一个客户端。 客户端需要先登录,登录成功后,服务端会发送给每一个客户端一个消息,XXX用户登陆成功,目前程序还没写完全,后续会不断更新~~message.go:首先需要一个消息传送的protocol,因为是基于TCP协议,传输过程中会有粘包和拆包问题,因此定义一个协议来保证数据完整性。package messageconst ( LoginMesType =.

2021-05-23 20:47:35 945 4

原创 模拟ThreadLocal内存泄漏过程

我们知道,在java的ThraedLocal中可能存在内存泄漏的问题。原因在于其内部维护了一个弱引用Map,其对于key是一个弱引用,当我们线程的强引用不再指向其对象时,就会进行回收。但是map中只回收了key而没有回收value,这务必造成内存的泄漏。因此,这里通过模拟这一过程,更加好的理解ThreadLocal内存泄漏。import java.lang.ref.ReferenceQueue;import java.lang.ref.WeakReference;import java..

2020-09-14 07:43:41 411

原创 记录一致性hash的java实现

一致性hash通常用在客户端的负载均衡策略,目的就是在变更服务器数量时,能尽量保证命中率。这样就不会造成缓存雪崩的问题。下列代码就是通过模拟正常hash和一致性hash的比对进行。对于正常的hash而言,当我们存入K,V键值对时,我们只需要hash(K) % size,然后把结果映射到对应服务器即可。这种方式对于服务器负载均衡而言是很好的,经过测试每台服务器的压力都会平均。但是在扩展服务器后,可能就会出现问题,造成大量K不命中,从而重新往数据库查数据,增加了数据库压力。对于一致性hash,需要有足够.

2020-06-20 10:50:15 185

原创 模拟synchronized锁升级过程(详细代码)

synchronized在1.6之后发生了很大改动,做了很多优化。因为Doug Lea大师的ReentrantLock类设计的很完美,jdk源码作者不服,所以对synchronized做了很大的改动。此博客针对已对synchronized锁有所了解的。首先我们需要知道synchronized具有4种锁的状态(细分5种):无锁无偏向 无锁可偏向 有锁已偏向 轻量锁 重量锁...

2020-04-19 15:18:31 892

原创 去除异常值,使用python编写matlab的hampel(X)函数

matlab中默认生成一个2 * k + 1大小的窗口,不足的部分使用目前的数据填充。使用正态分布标准偏差估计值(值为1.4826) * 绝对中位差,得到一个估计标准差。matlab中默认为3个估计标准差以外的就判定为离群点。代码如下:def hampel(X): length = X.shape[0] - 1 k = 3 nsigma = 3...

2019-12-20 21:58:49 2760 3

原创 利用Javascript检测开发者工具Devtools是否打开

转载自此处function checkDevTools(options) { const isFF = ~navigator.userAgent.indexOf("Firefox"); let toTest = ''; if (isFF) { toTest = /./; toTest.toString = fu...

2019-11-12 09:24:36 3140 2

原创 用python解析csi数据,使用csi tools工具获取wifi的.dat文件

我只做大自然的搬运工原先的csi tools得到的.dat文件需要使用matlab进行解析,由于某些需要,使用python进行解析,但是网络上没有,因此和csi3群里的某位小伙伴合作完成(大部分工作都是他在做)。具体请转☞他的博客以及github...

2019-08-24 08:59:16 4104 5

原创 android仿探探图片拖拽功能

废话不多说,先给效果图使用allprojects { repositories { ... maven { url 'https://jitpack.io' } } }dependencies { implementation 'com.github.SineyCoder:DragPhoto:1.0' }<com.si...

2019-06-29 19:12:39 1019

原创 android图片加载完成后涟漪特效

先上效果图 思路:就是重写了View布局,然后通过drawArc来实现具体代码如下/** * author: siney * Date: 2019/2/21 * description: */public class RippleImage extends AppCompatImageView { public RippleImage(Context cont...

2019-02-21 13:23:59 258

原创 Android一种自定义下拉刷新和上拉加载更多(使用外部拦截法解决冲突)

首先上效果图有2种刷新方式1.list滚动时无法触发刷新,必须置顶或置底才能触发刷新。2.list滚动时也可以触发刷新,即刷新与滚动可以兼容(不包括fling)。开始之前,请在gradle加入RecyclerView组件implementation 'com.android.support:design:28.0.0' 因为之前参...

2019-01-17 21:30:02 462

原创 一种自定义的滚轮滑动控件

首先感谢这位博主, 我是在他的基础上添加了一些小样式。所以详细请看这位博主的描述。我将他的样式详细描述了下github使用 allprojects { repositories { ... maven { url 'https://jitpack.io' } } }dependencies { implementation 'com....

2018-12-15 17:34:57 202

原创 仿QQ左滑删除【基于RecyclerView】

这是我github开源项目,目前测试阶段,欢迎大家使用提意见! https://github.com/SineyCoder/LeftSlideView 使用步骤  添加仓库allprojects { repositories { ... maven { url 'https://jitpack.io' } } } 添加依赖包depend...

2018-12-09 14:30:25 2083 1

原创 PAT (Advanced Level) Practice 1116

1116 Come on! Let's C(20 分)"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun,...

2018-09-07 11:59:06 150

原创 PAT (Advanced Level) Practice 1117

1117 Eddington Number(25 分)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number",E -- that is, the maximum inte...

2018-09-07 11:55:48 130

原创 PAT (Advanced Level) Practice 1067

1067 Sort with Swap(0, i)(25 分)Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to u...

2018-09-03 20:08:37 176

原创 PAT (Advanced Level) Practice 1064

1064 Complete Binary Search Tree(30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys...

2018-09-03 13:36:40 225

原创 PAT (Advanced Level) Practice 1032

1032 Sharing(25 分)To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same ...

2018-09-02 11:12:50 157

原创 PAT (Advanced Level) Practice 1085

1085 Perfect Sequence(25 分)Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×pwhere M and m are the maximum and minimum numbe...

2018-09-01 10:27:31 154

原创 PAT (Advanced Level) Practice 1086

1086 Tree Traversals Again(25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered f...

2018-09-01 09:26:54 140

原创 PAT (Advanced Level) Practice 1142

1142 Maximal Clique(25 分)A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extende...

2018-09-01 08:50:17 104

原创 PAT (Advanced Level) Practice 1141

1141 PAT Ranking of Institutions(25 分)After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Inp...

2018-08-31 10:31:35 148

原创 PAT (Advanced Level) Practice 1140

1140 Look-and-say Sequence(20 分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is ...

2018-08-31 08:26:26 145

原创 PAT (Advanced Level) Practice 1144

1144 The Missing Number(20 分)Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. Fo...

2018-08-26 10:23:02 160

原创 PAT (Advanced Level) Practice 1020

 1020 Tree Traversals(25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level orde...

2018-08-26 10:05:46 145

原创 PAT (Advanced Level) Practice 1004

1004 Counting Leaves (30)(30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case...

2018-08-23 17:24:37 125

原创 PAT (Advanced Level) Practice 1024

1024 Palindromic Number (25)(25 分)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single d...

2018-08-22 16:28:13 115

原创 牛客网-F-发电(费马小定理+线段树)

链接:https://www.nowcoder.com/acm/contest/136/F来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述    HA实验是一个生产、提炼“神力水晶”的秘密军事基地,神力水晶可以让机器的工作效率成倍提升。    HA实验基地有n台...

2018-08-22 10:47:09 128

原创 牛客网-E-对弈

链接:https://www.nowcoder.com/acm/contest/136/E来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述    善弈者谋势,不善弈者谋子。                                        ——《弈...

2018-08-22 10:44:50 218

原创 牛客-B-鹏

链接:https://www.nowcoder.com/acm/contest/136/B来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述    化而为鸟,其名为鹏。鹏之背,不知其几千里也。                                   ...

2018-08-22 10:42:49 365

原创 android 开启摄像头以及选取相册照片剪裁图片并使用比例压缩大小

        之前搜索了各种网上的开启摄像头拍照和选取相册的方式,发现大部分都不太兼容、适合。因此在这里总结一下切实可用的方法(参考第一行代码)        拍照使用的是FileProvider,这是为了保证uri安全机制而使用的一个类。使用此类在最新安卓版本中不需要访问SD卡中内容。--工具包1.CameraUtil(相机相关工具类)import android.Ma...

2018-07-24 10:13:08 571

原创 PAT (Advanced Level) Practice 1022

1022 Digital Library (30)(30 point(s))A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book ...

2018-06-15 13:35:23 138

原创 PAT (Advanced Level) Practice 1054

1054 The Dominant Color (20)(20 point(s))Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the ...

2018-06-15 13:32:29 129

原创 PAT (Advanced Level) Practice 1050

1050 String Subtraction (20)(20 point(s))Given two strings S~1~ and S~2~, S = S~1~ - S~2~ is defined to be the remaining string after taking all the characters in S~2~ from S~1~. Your task is simply t...

2018-06-15 13:30:25 354

原创 PAT (Advanced Level) Practice 1042

1042 Shuffling Machine (20)(20 point(s))Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" ...

2018-06-15 13:26:53 176

原创 PAT (Advanced Level) Practice 1036

1036 Boys vs Girls (25)(25 point(s))This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specificatio...

2018-06-15 13:23:41 141

原创 PAT (Advanced Level) Practice 1025

1025 PAT Ranking (25)(25 point(s))Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in s...

2018-06-15 13:20:33 157

原创 PAT (Advanced Level) Practice 1007

1007 Maximum Subsequence Sum (25)(25 point(s))Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 &lt;= i &lt;= j &l...

2018-06-15 13:15:36 161

原创 PAT (Advanced Level) Practice 1065

1065 A+B and C (64bit) (20)(20 point(s))Given three integers A, B and C in [-2^63^, 2^63^], you are supposed to tell whether A+B &gt; C.Input Specification:The first line of the input gives the positi...

2018-06-09 18:26:41 247

安卓实战pdf

安卓实战pdf,适合学习安卓课程,快速高效地构建Android应用

2018-05-08

hadoop2.6通用winutils和hadoop.dll

里面集成了hadoop2.6在windwos环境下相关的环境文件,如hadoop.dll和winutils等

2018-01-27

codemirror-5.2

这是codemirror-5.2工具包,这个工具包可以高亮code代码,并且可以附带许多主题等!

2016-12-08

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除