首页 文章 精选 留言 我的

精选列表

搜索[TDSQL-C PostgreSQL 版],共10000篇文章
优秀的个人博客,低调大师

Hadoop HDFS分布式文件系统Docker版

一、Hadoop文件系统HDFS 构建单节点的伪分布式HDFS 构建4个节点的HDFS分布式系统 nameNode secondnameNode datanode1 datanode2 其中 datanode2动态节点,在HDFS系统运行时,==动态加入==。 二、Mac docker环境 通常在mac os上搭建开发环境是非常方便的,两个docker软件: Docker for mac Docker toolBox 如果你要在本机做开发,配置IDE环境,想要连接到Docker中,推荐使用Docker toolBOX。docker for mac 版本没有docker0网桥。 在mac系统上又运行了一层虚拟机,只有这层虚拟机可以直连到docker网络。强烈建议开发不要再找docker for mac连接docker0的方法了,这个坑已经浪费了很多人的时间。 如果mac系统版本在10.13 以上,还会遇到创建网卡失败的问题,要注意关闭系统安全特性设置。 sudo spctl --master-disable 感谢作者@ 仰望神的光,《macOS 10.13 安装Virtualbox失败》,https://blog.csdn.net/u013247765/article/details/78176079 docker 常用命令的总结,会在文章末尾附录。 三、Docker 镜像 构建Hadoop镜像文件。构建docker image有2中方式,(1)docker commit保存现有环境生成image(2)Dockfile,docker build生成image。通过实验,构建Dockerfile的速度很快,而且支持环境变量,同步文件等方式。开始可以用commit不断调整,最后确定Dockfile内容。而且Dockerfile文件结构清晰,方便查看。 FROM ubuntu:16.04 MAINTAINER wsn RUN apt-get update RUN apt-get install -y openjdk-8-jdk RUN apt-get install -y vim RUN apt install -y net-tools RUN apt install -y iputils-ping RUN apt-get install -y openssh-server RUN mkdir /var/run/sshd RUN echo 'root:root' |chpasswd RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config RUN sed -ri 's/# StrictHostKeyChecking ask/StrictHostKeyChecking no/' /etc/ssh/ssh_config RUN mkdir /root/.ssh RUN ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 ENV JRE_HOME /usr/lib/jvm/java-8-openjdk-amd64/jre ENV PATH /opt/hadoop-2.6.5/bin:/opt/hadoop-2.6.5/sbin:/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH ENV CLASSPATH ./:/usr/lib/jvm/java-8-openjdk-amd64/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib ADD hadoop-2.6.5.tar.gz /opt/ EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] Dockerfile 解析 ubuntu 16.04 为基础镜像,开始开发之前一定要apt-get update。 PermitRootLogin、UsePAM、StrictHostKeyChecking 有关SSH的配置。 ssh-keygen 生成公钥,保存到authorized_keys中。 配置JDK,hadoop的环境变量。 hadoop-2.6.5.tar.gz 保存到与Dockerfile同一个目录,会自动解压到/opt目录下。注意hadoop的环境变量基石/opt/hadoop-2.6.5/bin下。 编译镜像,其中wsn/ubuntu_ssh_java_hadoop是镜像的名字,其中.代表当前目录。 docker bulid -t wsn/ubuntu_ssh_java_hadoop . 四、HDFS 伪分布式 HDFS系统中包括三种角色,namenode主控节点,datanode数据节点,secondenamenode主控节点的热备节点。伪分布式,就是在一台主机上启动3个进程,构建一套分布式系统。 在单节点上配置伪分布式很简单,修改 hadoop-env.sh,core-site.xml,hdfs-site.xml 。 core-site.xml包含2个属性,其中namenode代表节点hostname、域名,换成ip也可以;hadoop.tmp.dir是hadoop工作目录(可以设置docker volumn,实现持久化)。 <configuration> <property> <name>fs.default.name</name> <value>hdfs://namenode:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/tmp</value> </property> </configuration> hdfs-site.xml <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration> 启动镜像 docker run --name namenode --rm wsn/ubuntu_ssh_java_hadoop 最后2步: /opt/hadoop/bin/hadoop namenode -format /opt/hadoop/sbin/start-hdfs.sh start 查看系统状态,jps会看到3个进程namenode,secondnamenode,datanode。 一些简单hdfs命令,这些命令可以帮助你对hdfs系统的测试。 hdfs dfs -ls / hdfs dfs -mkdir /test hdfs dfs -put 1.txt /test 五、Docker特性 (一) 分层 docker系统采用了分层的设计思想,在docker中运行的修改是不会自动保存,你可以调用commit生成新的镜像。或者采用挂载数据卷的方式,将数据和系统分类,实现数据持久化。 刚刚接触Docker对分层的意义了解不深。在构建Dockerfile的时候,每个RUN命令会构建一个层,image按层存储,此时就产生不同的镜像引用了相同的层,节省了存储空间,实现image hub高效存储。 docker挂载文件、文件夹命令。 docker -v 宿主机路径:container路径 image (二)网络与内嵌DNS 在docker环境中,可以创建一个子网络 docker network create --subnet=172.18.0.0/16 hadoopnet 在第二节中讨论过,我们希望能过访问这个网络,在主机上添加路由信息 sudo route -n add 172.18.0.0/24 192.168.99.100 此时,我们可以创建一台绑定网段、ip的主机了, docker run -it --name namenode --hostname namenode --network hadoopnet --ip 172.18.0.11 wsn/ubuntu_ssh_java_hadoop 当我们创建一台docker主机,设置了name、ip时,内嵌DNS提供了name和ip的解析,省却了修改hosts文件的麻烦。 (三)免密码登录 此例中,创建Dockerfile文件的时候,就生成了公钥,并写入authorize文件中。结果就是,所有的container的公钥都是一样的,而且写入了authorize文件,所以都实现了免密码登录。其实笔者不希望这样,对于docker的公钥问题留下待解决的问题。 在构建Dockerfile的时候,ssh_config文件StrictHostKeyChecking no,设置在首次ssh登录的时候,不用询问。 The authenticity of host 'namenode (172.18.0.11)' can't be established. ECDSA key fingerprint is SHA256:4utoWe5uVp79ImYqkPPukjmrGIfvDC5demc1sx8sY9c. Are you sure you want to continue connecting (yes/no)? yes (四)启动脚本 docker 容器有一个特性,当没有前台应用的时候,docker自动停止(这个设计有什么优势我还不知道)。 我们在创建dockerfile的时候配置了CMD ,就是系统运行后前台命令。如果run docker的时候,配置了start-hdf.sh 命令,那么就会遇到脚本运行结束docker自动停止。 解决方法,在本地创建一个.sh文件,在docker run 的时候挂载到container中,run 命令设置运行这个docker容器中的sh文件。 /etc/init.d/ssh start /opt/hadoop-2.6.5/sbin/start-dfs.sh 六、分布式Hadoop环境 在本地建立4个文件目录,namenode、secondnamenode、datanode、datanode2。 (一) namenode文件夹: hadoop namenode.sh #启动脚本 run.sh #ssh start start-dfs.sh data #挂载到/opt/tmp hadoop文件夹是容器内/opt/hadoop/etc/hadoop的挂载文件 core-site.xml <configuration> <property> <name>fs.default.name</name> <value>hdfs://namenode:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/opt/tmp</value> </property> </configuration> hdfs-site.xml,全部类型的节点都用这个配置,标注了namenode 和secondnamenode的域名/ip。 <configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.http.address</name> <value>namenode:50070</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>secondnamenode:50090</value> </property> </configuration> slaves secondnamenode datanode masters secondnamenode namenode.sh docker run -it --name namenode --hostname namenode --network hadoopnet --ip 172.18.0.11 -d -v $PWD/data:/opt/tmp -v $PWD/hadoop:/opt/hadoop-2.6.5/etc/hadoop -v $PWD/run.sh:/opt/run.sh --rm wsn/ubuntu_ssh_java_hadoop /opt/run.sh run.sh,如果没有格式化目录,首先格式化目录。```bash``使终端有一个前台进程。 #!/bin/bash if [ ! -d "/opt/tmp/dfs" ];then hadoop namenode -format else echo "already format" fi /etc/init.d/ssh start /opt/hadoop-2.6.5/sbin/start-dfs.sh bash (二)secondnamenode,datanode 启动命令 docker run --name secondnamenode --hostname secondnamenode --network hadoopnet --ip 172.18.0.12 -d -v $PWD/data:/opt/tmp -v $PWD/hadoop:/opt/hadoop-2.6.5/etc/hadoop --rm wsn/ubuntu_ssh_java_hadoop docker run --name datanode1 --hostname datanode1 --network hadoopnet --ip 172.18.0.13 -d -v $PWD/data:/opt/tmp -v $PWD/hadoop:/opt/hadoop-2.6.5/etc/hadoop --rm wsn/ubuntu_ssh_java_hadoop 这个两个节点已经写到namenode的slaves文件,secondnamenode在配置文件hdfs-site.xml设置为secondary。当namenode启动start-hdf.sh时会通过ssh,启动secondnamenode上的secondname进程和datanode进程。datanode容器会启动datanode进程,此时可以通过web界面查看了。 (三)datanode2 启动 docker run --name datanode2 --hostname datanode2 --network hadoopnet --ip 172.18.0.14 -d -v $PWD/data:/opt/tmp -v $PWD/hadoop:/opt/hadoop-2.6.5/etc/hadoop --rm wsn/ubuntu_ssh_java_hadoop datanode2没有添加到namenode的slaves文件中,但是在datanode2的hdfs文件中配置了namenode和secondnamenode,所以datanode可以自动添加到HDFS系统中。 /opt/etc/hadoop/sbin/hadoop-daemon.sh start datanode web,http://172.18.0.11:50070/dfshealth.html#tab-datanode 七、总结 Google 三篇论文,分别介绍了分布式文件系统、MapReduce、宽表。对应开源系统Hadoop中的HDFS、MapReduce、HBase。通过对HDFS系统的配置,了解了主从结构的网络,应该用什么样的配置文件。对HBase系统也有一些了解,在HBase中对master节点采用了zookeeper进行控制。 大数据对系统结构搭建非常重视,实际工作中运维难度大。 Spark 是目前主流的大数据架构。 附录 docker 常用命令 image 案例一:启动nginx,绑定80到连接本地的8080端口 docker run -p 8080:80 -d nginx -d:后台运行, 案例二: 启动ubuntu docker run ubuntu echo hello world 自动下载ubuntu ,并启动 案例三:替换docker 中文件 docker cp index.html containerId://usr/share/nginx/html 案例四:保存docker docker commit -m "message" containerId 保存为一个新的image 案例五:dockerfile 文件创建docker image FROM ubuntu MAINTAINER wsn RUN apt-get update RUN apt-get install -y nginx copy index.html /var/www/html ENTRYPOINT ["/usr/sbin/nginx","-g","daemon off;"] EXPOSE 80 当前目录下运行命令 docker build -t wsn/ubuntu-nginx . wsn/ubuntu-nginx 作为容器的名字 案例六:docker分层 案例七:volumn 持久化 docker run -p 80:80 -d -v $PWD/html:/usr/share/nginx/html nginx $PWD/html 挂载虚拟机的/usr/share/nginx/html目录下 案例八:进入docker虚拟机shell,-it交互方法 docker exec -it nginx /bin/bash

优秀的个人博客,低调大师

leetcode算法题解(Java版)-13-经典反转链表

一、简单二分搜索 题目描述 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 → 1[1,3,5,6], 7 → 4[1,3,5,6], 0 → 0 思路 题目很简单,二分就能通过 代码 public class Solution { public int searchInsert(int[] A, int target) { //二分查找 int left = 0; int right = A.length-1; while(left<=right){ int mid = (left+right)/2; if(A[mid]==target){ return mid; } else if(A[mid]<target){ left = mid+1; } else{ right = mid-1; } } return left; } } 二、反转链表 题目描述 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given1->2->3->4->5->NULL, m = 2 and n = 4, return1->4->3->2->5->NULL. Note: Given m, n satisfy the following condition:1 ≤ m ≤ n ≤ length of list. 思路 经典的题目,值得反复推敲。设置两个指针,一个指向m的位置,一个指向m之前的那个位置,不断刷新这两个指针的next,达到反转的效果。 注意,这两个指针本身不变化,变化的是他们的next. 这样做,满足了题意中的:do it in-place and in one-place 代码 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */ public class Solution { public ListNode reverseBetween(ListNode head, int m, int n) { ListNode dummy = new ListNode(0); dummy.next = head; ListNode start = head; ListNode prestart = dummy; for(int i=1;i<m;i++){ prestart = start; start = start.next; } ListNode tem; for(int i=0;i<n-m;i++){ tem = start.next; start.next = tem.next; tem.next = prestart.next; prestart.next = tem; } return dummy.next; } } 三、深搜 题目描述 Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example,If S =[1,2,2], a solution is: [ [2], [1], [1,2,2], [2,2], [1,2], [] ] 思路 题目要列出所有不重复的,用所给数组中数字组成的非递减数列。 深搜解决问题:注意到不能有重复的数字,之前好像做过类似的题目,今天又碰到了,也就是要让拿的数字不能和已经拿过的一样。if(start>i&&num[i]==num[i-1] 代码 import java.util.ArrayList; import java.util.Arrays; public class Solution { ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); public ArrayList<ArrayList<Integer>> subsetsWithDup(int[] num) { if(num==null||num.length==0){ return res; } Arrays.sort(num); findAll(num,0,new ArrayList<>()); return res; } public void findAll(int [] num,int start,ArrayList<Integer> list){ res.add(new ArrayList<Integer>(list)); for(int i=start;i<num.length;i++){ if(i>start&&num[i]==num[i-1]){ continue; } list.add(num[i]); findAll(num,i+1,list); list.remove(list.size()-1); } } }

优秀的个人博客,低调大师

leetcode算法题解(Java版)-12-中序遍历

日子又恢复正常了,浪了半个月。。。还是学习的时候感觉好~~ 一、动态规划 题目描述 Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 2 3 思路 题目看上去像是二叉搜索树的题,实际上是动态规划。给到1~n的数,要找出多少种二叉查找树,对于取值为k的数来说,在它左边的又1~k-1,右边的有k+1~n.所以可以把左子树排列的种数乘右子树的种数得到以这个为根的二叉查找树的个数。 用一个状态数组记录下值。 代码 public class Solution { public int numTrees(int n) { if(n==0){ return 0; } int [] f = new int[n+1]; f[0]=1; for(int i=1;i<=n;i++){//外循环,刷新1,2,3,4.。。n的结果 for(int j=1;j<=i;j++){//小循环,计算各个的值 f[i]+=f[j-1]*f[i-j]; } } return f[n]; } } 二、中序遍历 题目描述 Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,3,2]. 思路 二叉树的中序遍历,就是所谓的左-中-右。 递归和非递归方法,直接看代码! 代码 //递归 /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ import java.util.ArrayList; public class Solution { public ArrayList<Integer> inorderTraversal(TreeNode root) { ArrayList<Integer> res=new ArrayList<Integer>(); if(root==null)return res; inorder(root,res); return res; } public static void inorder(TreeNode root, ArrayList<Integer> list){ if(root != null){ inorder(root.left,list); list.add(root.val); inorder(root.right,list); } } } //非递归 /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ import java.util.ArrayList; import java.util.Stack; public class Solution { public ArrayList<Integer> inorderTraversal(TreeNode root) { ArrayList<Integer> res = new ArrayList<>(); Stack<TreeNode> stack = new Stack<>(); TreeNode node = root; if(root==null){ return res; } while(!stack.isEmpty()||node!=null){ while(node!=null){ stack.add(node); node = node.left; } node = stack.pop(); res.add(node.val); node = node.right; } return res; } } 三、深搜 题目描述 Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given"25525511135", return["255.255.11.135", "255.255.111.35"]. (Order does not matter) 思路 深度搜索+回溯的时候剪枝 代码 import java.util.ArrayList; public class Solution { public ArrayList<String> restoreIpAddresses(String s) { ArrayList<String> res =new ArrayList<String>(); ArrayList<String> ip =new ArrayList<String>(); int start = 0 ; dfs(s,res,ip,start); return res; } public void dfs(String s,ArrayList<String> res,ArrayList<String> ip,int start){ if(ip.size()==4&&start==s.length()){ res.add(ip.get(0)+'.'+ip.get(1)+'.'+ip.get(2)+'.'+ip.get(3)); } if(s.length()-start > 3*(4-ip.size())){//剪枝 return ; } if(s.length()-start+1 < 4-ip.size()){//剪枝 return ; } int num = 0 ; for(int i=start;i<start+3&&i<s.length();i++){ num = num*10+(s.charAt(i)-'0'); if(num<0||num>255){ return ; } ip.add(s.substring(start,i+1)); dfs(s,res,ip,i+1); ip.remove(ip.size()-1); if(num==0){//可以添加0,但不允许有前缀为0的 break; } } } }

优秀的个人博客,低调大师

leetcode算法题解(Java版)-10-全排列(递归)

一、二维数据 题目描述 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 思路 最简单的方法就是在开一个新二维数组tem,然后实行“旋转操作” 这样,不符合题意!要在同一个数组中进行! 代码 public class Solution { public void rotate(int[][] matrix) { int [][] tem=new int [matrix.length][matrix.length]; for(int i=0;i<tem.length;i++){ for(int j=0;j<tem.length;j++){ tem[j][tem.length-1-i]=matrix[i][j]; } } for(int i=0;i<tem.length;i++){ for(int j=0;j<tem.length;j++){ matrix[i][j]=tem[i][j]; } } } } 思路二 画一条从左上角到右下角的对角线,这时候矩阵被分成了两份,然后将左下角那部分和右上角那部分的处于对称位置的对调。 然后将列水平对称位置对调,即为所求! 听着有点懵的话,不妨在纸上试试。 代码 public class Solution { public void rotate(int[][] matrix) { int len=matrix.length; int tem; for(int i=0;i<len;i++){ for(int j=0;j<i;j++){ tem=matrix[i][j]; matrix[i][j]=matrix[j][i]; matrix[j][i]=tem; } } for(int i=0;i<len;i++){ for(int j=0;j<len/2;j++){ tem=matrix[i][j]; matrix[i][j]=matrix[i][len-1-j]; matrix[i][len-1-j]=tem; } } } } 二、全排列(深搜) 题目描述 Given a collection of numbers, return all possible permutations. For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1]. 思路 找全排列,典型的深搜题。 语法点:res.add(new ArrayList<Integer>(list));不要忘了加new ArrayList<Integer>不加就通过不了,虽然不明白为什么要加上。 代码 import java.util.ArrayList; public class Solution { public ArrayList<ArrayList<Integer>> permute(int[] num) { ArrayList<ArrayList<Integer>> res=new ArrayList<>(); int len=num.length; if(num==null||len==0){ return res; } boolean [] visit=new boolean [len]; ArrayList<Integer> list=new ArrayList<>(); dfs(num,list,visit,res); return res; } public void dfs(int [] num,ArrayList<Integer> list,boolean [] visit,ArrayList<ArrayList<Integer>> res){ if(list.size()==num.length){ res.add(new ArrayList<Integer>(list)); return ; } for(int i=0;i<num.length;i++){ if(!visit[i]){ visit[i]=true; list.add(num[i]); dfs(num,list,visit,res); list.remove(list.size()-1); visit[i]=false; } } } } 这道全排列的题,还有扩展,明天接着搞~~

优秀的个人博客,低调大师

leetcode算法题解(Java版)-9-N皇后问题

一、贪心 题目描述 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array[−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray[4,−1,2,1]has the largest sum =6. click to show more practice.More practice: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. 思路 贪心的基本思想就是局部找最优解,然后通过局部的最优解得出来的结果,就是全局的最优解,往往很难证明,但不妨先试一试。 就像这道题,因为要求的是最大的子串和,那显然负数是起到反作用的,所以如果当前和是负的,那就果断舍去,这也是贪心的思路。 这样的解法时间复杂度是O(n)题目中说明了,可以使用分治进一步优化,请看代码二。 代码一 public class Solution { public int maxSubArray(int[] A) { int len=A.length; if(len==0){ return 0; } int sum=A[0]; int max=A[0]; for(int i=1;i<len;i++){ if(sum<0){ sum=0; } sum+=A[i]; if(sum>max){ max=sum; } } return max; } } 代码二 public class Solution { public int div(int [] A,int left,int right){ int mid=(left+right)/2; if(left==right){ return A[left]; } int max1=div(A,left,mid); int max2=div(A,mid+1,right); int max3=-999999;//这里不严谨,但不能用Integer.MIN_VALUE。 //否则max3+max4如果是负数和Integer.MIN_VALUE相加会溢出 int max4=-999999; int tem=0; for(int i=mid;i>=left;i--){ tem+=A[i]; max3=Math.max(max3,tem); } tem=0; for(int i=mid+1;i<=right;i++){ tem+=A[i]; max4=Math.max(max4,tem); } return Math.max(Math.max(max1,max2),max3+max4); } public int maxSubArray(int[] A) { int len=A.length; if(len==0){ return 0; } return div(A,0,len-1); } } 二、N皇后问题 题目描述 Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. 思路 经典的老题目了,存储当然是用一个数组map解决:下标表示行号,每个map[i]中存放的数字表示列号。 然后就是写一个判断函数:1.判断行是否重复:这个不需要判定,因为数组下标即使行。2.判断列是否重复,即map[t]!=map[i]。3.判断对角线是否重复:即map[t]-map[i]!=t-i。 代码 public class Solution { public int [] map=new int[30]; public int count=0;//注意!!不能写成public static int count=0; //否则全局静态变量的话,内存地址是一个, //也就是当前测试用例会受到上一个测试用例中count的影响 public int totalNQueens(int n) { backtrack(1,n); return count; } public void backtrack(int t,int n){ if(t>n){ count++; } else{ for(int i=1;i<=n;i++){ map[t]=i; if(valid(t)){ backtrack(t+1,n); } } } } public boolean valid(int t){ for(int i=1;i<t;i++){ if(Math.abs(t-i)==Math.abs(map[t]-map[i])||map[i]==map[t]){ return false; } } return true; } } 三、N皇后问题再度升级 题目描述 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where'Q'and'.'both indicate a queen and an empty space respectively. For example,There exist two distinct solutions to the 4-queens puzzle: [ [".Q..", // Solution 1 "...Q", "Q...", "..Q."], ["..Q.", // Solution 2 "Q...", "...Q", ".Q.."] ] 思路 和上一道只需要输出个数,这道题也需要把所有的图输出来。只需要改动一个地方就OK。具体的看代码,写的很清楚。 代码 import java.util.ArrayList; public class Solution { public int [] mark=new int [30]; public int count=0; public ArrayList<String[]> resList=new ArrayList<>(); public ArrayList<String[]> solveNQueens(int n) { backtrack(1,n); return resList; } public StringBuilder drawOneLine(int n){ StringBuilder sb=new StringBuilder(); for(int i=0;i<n;i++){ sb.append('.'); } return sb; } public boolean valid(int t){ for(int i=1;i<t;i++){ if(Math.abs(mark[i]-mark[t])==Math.abs(i-t)||mark[i]==mark[t]){ return false; } } return true; } public void backtrack(int t,int n){ if(t>n){ String [] tem=new String[n]; for(int i=0;i<n;i++){ StringBuilder line=drawOneLine(n); line.setCharAt(mark[i+1]-1,'Q');//因为String从0开始而我的mark是从1开始记的 //这里下标有点乱:mark数组是从1开始的,而tem是从0开始的。 tem[i]=line.toString(); } resList.add(tem); } else{ for(int i=1;i<=n;i++){ mark[t]=i; if(valid(t)){ backtrack(t+1,n); } } } } }

优秀的个人博客,低调大师

leetcode算法题解(Java版)-3-广搜+HashMap

一、运算符——异或"^" 题目描述 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 思路 题目很简单,考到了一个知识点——异或:比较两个操作数的二进制的各个位置,相同则为0不同则为1。所以,1.与0异或是本身2.与和自己一样的异或是0. 代码 public class Solution { public int singleNumber(int[] A) { int res=0; for(int i=0;i<A.length;i++){ res^=A[i]; } return res; } } 二、动态规划 题目描述 There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one candy. Children with a higher rating get more candies than their neighbors. What is the minimum candies you must give? 思路: 一开始看错题了,孩子们本来站好队了,我按权重从大到小排了一下。。。看了别人的代码,思路并不难:先给每人一个糖果,两个循环解决问题,一,从前往后扫一遍,如果下一个比上一个权重大就在上一个基础上加一;再从后往前扫一遍,如果前面的比后面的权重大且糖果比他少就再后面的基础上加一刷新原有的值。 语法点:Arrays.fill(array,val);Arrays.sort(array); 代码 import java.util.Arrays; public class Solution { public int candy(int[] ratings) { if(ratings==null||ratings.length==0){ return 0; } int len=ratings.length; int [] cnt=new int [len]; Arrays.fill(cnt,1); for(int i=1;i<len;i++){ if(ratings[i]>ratings[i-1]){ cnt[i]=cnt[i-1]+1; } } int sum=0; for(int i=len-1;i>0;i--){ if(ratings[i-1]>ratings[i]&&cnt[i-1]<=cnt[i]){ cnt[i-1]=cnt[i]+1; } sum+=cnt[i]; } return sum+cnt[0]; } } 三、模拟题(环状) 题目描述 There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costscost[i]of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. Return the starting gas station's index if you can travel around the circuit once, otherwise return -1. Note: The solution is guaranteed to be unique. 思路 设置start和end,分别放在首尾。如果能继续走就让end++,不能则让start退一个。结束while循环有两种可能结果,一个是sum>=0,则最后相会的点就是出发点,另一个则不可能。 代码 public class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int len=gas.length; int start=len-1; int end=0; int sum=0; sum=gas[start]-cost[start]; while(end<start){ if(sum>=0){ sum+=gas[end]-cost[end]; end++; } else{ start--; sum+=gas[start]-cost[start]; } } return sum>=0?start:-1; } } 四、BFS+HashMap 题目描述 Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors. 思路 广搜,然后用map存储原来的和克隆的一一映射 HashMap中通过get()来获取value,通过put()来插入value,containsKey()则用来检验对象是否已经存在 Stack:st.push(node);st.pop();st.empty(); 代码 /** * Definition for undirected graph. * class UndirectedGraphNode { * int label; * ArrayList<UndirectedGraphNode> neighbors; * UndirectedGraphNode(int x) { label = x; neighbors = new ArrayList<UndirectedGraphNode>(); } * }; */ import java.util.Stack; import java.util.HashMap; public class Solution { public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if(node==null){ return null; } HashMap<UndirectedGraphNode,UndirectedGraphNode> map=new HashMap<>(); Stack<UndirectedGraphNode> stackNode=new Stack<>(); stackNode.push(node); while(!stackNode.empty()){ UndirectedGraphNode tempNode=stackNode.pop(); if(map.containsKey(tempNode)){ continue; } UndirectedGraphNode copyNode=new UndirectedGraphNode(tempNode.label); for(UndirectedGraphNode uNode:tempNode.neighbors){ copyNode.neighbors.add(uNode); if(map.containsKey(uNode)){ continue; } stackNode.push(uNode); } map.put(tempNode,copyNode); } return map.get(node); } }

优秀的个人博客,低调大师

Android小知识10则(上)(2018.8重编版)

Android小知识10则(下) 目录 前言 横竖屏锁定 不同分辨率的图标 将字符串写在资源文件中 为AlertDialog设置点击监听 ProgressDialog了解一下 最后 前言 Android的知识还是比较碎的, 日常积累很重要. 我把平常一些小知识点整合整合, 理成了上下两篇文章, 每篇五个知识点. 横竖屏锁定 有两种方法可以实现 使用配置文件 在AndroidManifest.xml的activity标签下添加android:screenOrientation="portrait"即可.默认是android:screenOrientation="unspecified", 也就是根据系统当前的横竖屏状态切换. 使用Java代码 使用setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);是锁定横屏. 使用setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);是锁定竖屏. 个人推荐写在配置文件里面. 来两张图: 配置文件 Java代码 不同分辨率的图标 由于Android的分辨率很不统一, 小到4寸左右, 大到10寸左右. 屏幕适配是很恶心人的问题. 这里就简单说一下如何添加不同分辨率的图标到工程当中. 首先看一下官方的例子, 我们的目标就是让我们的图标按照不同分辨率, 放在一个同名文件夹中. 官方例子 右击mipmap文件夹, 在目录中打开, 我的是mac所以显示finder, win/linux的话好像是文件浏览器之类的名称吧, 位置是差不多的. 右击mipmap文件夹 然后就很简单了, 你只需要把不同分辨率的图标, 由小到大逐一放入到mipmap-hdpi到mipmap-xxxhdpi中即可. 当然了, drawable也是一样, 从drawable-hdpi到drawable-xxxhdpi. 回到Android Studio就会有想要的效果了, 用的时候只要输入图片名称即可, 系统会自动选择最合适的图片显示. 当然说是这么说, 其实布局文件还得按照分辨率来写不是, 没准还要区分版本(手动无奈). 将字符串写在资源文件中 将字符串写在资源文件中好处是不言而喻的, 便于管理, 便于查找, 便于维护, 便于全球化等等, 而且上传github的时候, 它也会死命提示你的(手动滑稽). 那就来看看这个知识点吧. 单个字符串 单个字符串的使用是非常简单的. 将字符串写在strings.xml中, java直接引用就好. 或者用getResources().getString()方法 <string name="single_str">SingleStr</string> TextView tvSingleStr = (TextView) findViewById(R.id.tv_single_str); tvSingleStr.setText(R.string.single_str); getResources().getString(R.string.app_name); 字符串数组 字符串数组的使用稍微麻烦点. 同样在strings.xml中写一个字符串数组. 然后在java里面引用. <string-array name="str_arr"> <item>a</item> <item>b</item> <item>c</item> <item>d</item> </string-array> String[] stringArray = getResources().getStringArray(R.array.str_arr); TextView tvStrArr = (TextView) findViewById(R.id.tv_str_arr); tvStrArr.setText(Arrays.toString(stringArray)); 格式化字符串 这个格式化字符串在c里面是家常便饭, 但是到了java可能就没那么好使了. 总之, 也还是可以用的. 步骤还是一样, 先strings.xml, 后java. <string name="format_str">我买了%1$d个苹果, 花了%2$.2f元, 抽到了%3$s去夏威夷的票, 用手比了一个%4$c</string> String formatStr = String.format(getResources().getString(R.string.format_str), 5, 3.2, "两张", 'v'); TextView tvFormatStr = (TextView) findViewById(R.id.tv_format_str); tvFormatStr.setText(formatStr); 为AlertDialog设置点击监听 为列表和单选列表设置监听 关于AlertDialog的初步使用请参见之前的文章. 然后来看具体添加监听的代码. 列表 直接在setItems后面添加监听函数, 或者新建类实现监听接口都是可以的, 要说的是, which对应点击的条目, 从0开始. 比如说点击"apple"就是0, 点击"boy"就是1. builder.setItems(new String[]{"apple", "boy", "cat"}, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.i("sorrower", "which: " + which); } }); 单选列表 单选列表大体和列表相同, 值得一提的就是setSingleChoiceItems的第二个参数如果是-1, 就代表都不选, 如果是0, 代表默认选中第一个, 这里的话就是"apple". builder.setSingleChoiceItems(new String[]{"apple", "boy", "cat"}, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.i("sorrower", "which: " + which); } }); 为AlertDialog自带按钮设置监听 每个AlertDialog默认有三个按钮的, 肯定否定和中性. 这里不使用匿名监听, 我们新建一个类实现监听接口. builder.setPositiveButton("positive", new clickListener()); builder.setNegativeButton("negative", new clickListener()); builder.setNeutralButton("neutral", new clickListener()); class clickListener implements DialogInterface.OnClickListener { @Override public void onClick(final DialogInterface dialog, int which) { Log.i("sorrower", "which: " + which); } } 然后得到的结果和猜想的不太一样, 点击NeutralButton, which的值是-3; 点击NegativeButton, which的值是-2; 点击PositiveButton, which的值是-1. 我们可以使用which值区分用户点击. ProgressDialog了解一下 进度条弹窗还是很实用的, 今天就带大家了解一下! 先来张效果图: 效果图 final ProgressDialog pd = new ProgressDialog(this); pd.setIcon(R.mipmap.ic_launcher_round); pd.setTitle("Dealing..."); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); // 设置为矩形进度条 pd.setCancelable(false); pd.setIndeterminate(false); // 设置进度条是否为不明确 pd.setMax(100); pd.setProgress(0); pd.show(); new Thread() { @Override public void run() { for (int i = 0; i < 100; i++) { try { Thread.sleep(80); } catch (InterruptedException e) { e.printStackTrace(); } final int j = i + 1; pd.setProgress(j); } pd.dismiss(); } }.start(); 如果你改一行pd.setIndeterminate(true);, 那么就不会显示百分比, 和处理具体数. 直接上图: 效果图 如果你注释掉pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);这一行. 那么就是那种圆形扫描式的进度条, 你见过的. 上图: 效果图 最后 还有下篇的五个知识点哦, 觉得不错记得点赞或者关注我哦~

优秀的个人博客,低调大师

mui封装做好的手机版网站为apk

BOSS提到的一个功能,就是把已经做好的手机网站http://xxx.com/m/home/index ,想着看起来应该蛮简单,一个html页面里就一个iframe就好了,然后宽度和高度都设置为100%, 试了下,宽度没问题,就是高度的话100%是没有用的,试过在我的MX2手机上是可以100%撑开,钽是在同事的华为手机上又不能撑开了,上网搜索了一下,可以用JS来取得整个窗口的高度,下面是代码,直接写在MUI的新建 的项目中的INDEX.HTML页面就行了 <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title></title> <style> * { margin: 0; padding: 0; } </style> <script type="text/javascript"> document.addEventListener('plusready', function() { //console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。" // var h = plus.webview.currentWebview().height; 这是错的,取不到值 //console.log("当前页面URL:" + plus.webview.currentWebview().getURL() + " ,当前窗口高度:" + h); // document.getElementById('frm1').style.height = h + "px"; }); function setIframeHeight(iframe) { if(iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if(iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; console.log("窗口高度:" + iframe.height); document.getElementById('frm1').style.height = iframe.height + "px"; } } }; window.onload = function() { setIframeHeight(document.getElementById('frm1')); }; </script> </head> <body> <iframe id="frm1" style="border:none;width:100%;height:100%;" src="http://baidu.com/"></iframe> </body>

优秀的个人博客,低调大师

一个简单的线程池实现(java版)

线程池代码: 复制代码 import java.util.List; import java.util.Vector; public class ThreadPool { private static ThreadPool instance_ = null; //定义优先级别常数,空闲的线程按照优先级不同分别存放在三个vector中 public static final int LOW_PRIORITY = 0; public static final int NORMAL_PRIORITY = 1; public static final int HIGH_PRIORITY = 2; //保存空闲线程的List,或者说它是"池" private List<PooledThread>[] idleThreads_; private boolean shutDown_ = false; private int threadCreationCounter_; //以创建的线程的个数 private boolean debug_ = false; //是否输出调试信息 //构造函数,因为这个类视作为singleton实现的,因此构造函数为私有 private ThreadPool() { // 产生空闲线程.三个vector分别存放分别处在三个优先级的线程的引用 List[] idleThreads = {new Vector(5), new Vector(5), new Vector(5)}; idleThreads_ = idleThreads; threadCreationCounter_ = 0; } public int getCreatedThreadsCount() { return threadCreationCounter_; } //通过这个函数得到线程池类的实例 public static ThreadPool instance() { if (instance_ == null) instance_ = new ThreadPool(); return instance_; } public boolean isDebug() { return debug_; } //将线程repoolingThread从新放回到池中,这个方式是同步方法。 //这个方法会在多线程的环境中调用,设计这个方法的目的是让工作者线程 //在执行完target中的任务后,调用池类的repool()方法, //将线程自身从新放回到池中。只所以这么做是因为线程池并不能预见到 //工作者线程何时会完成任务。参考PooledThread的相关代码。 protected synchronized void repool(PooledThread repoolingThread) { if (!shutDown_) { if (debug_) { System.out.println("ThreadPool.repool() : repooling "); } switch (repoolingThread.getPriority()) { case Thread.MIN_PRIORITY : { idleThreads_[LOW_PRIORITY].add(repoolingThread); break; } case Thread.NORM_PRIORITY : { idleThreads_[NORMAL_PRIORITY].add(repoolingThread); break; } case Thread.MAX_PRIORITY : { idleThreads_[HIGH_PRIORITY].add(repoolingThread); break; } default : throw new IllegalStateException("Illegal priority found while repooling a Thread!"); } notifyAll();//通知所有的线程 } else { if (debug_) { System.out.println("ThreadPool.repool() : Destroying incoming thread."); } repoolingThread.shutDown();//关闭线程 } if (debug_) { System.out.println("ThreadPool.recycle() : done."); } } public void setDebug(boolean newDebug) { debug_ = newDebug; } //停止池中所有线程 public synchronized void shutdown() { shutDown_ = true; if (debug_) { System.out.println("ThreadPool : shutting down "); } for (int prioIndex = 0; prioIndex <= HIGH_PRIORITY; prioIndex++) { List prioThreads = idleThreads_[prioIndex]; for (int threadIndex = 0; threadIndex < prioThreads.size(); threadIndex++) { PooledThread idleThread = (PooledThread) prioThreads.get(threadIndex); idleThread.shutDown(); } } notifyAll(); if (debug_) { System.out.println("ThreadPool : shutdown done."); } } //以Runnable为target,从池中选择一个优先级为priority的线程创建线程 //并让线程运行。 public synchronized void start(Runnable target, int priority) { PooledThread thread = null; //被选出来执行target的线程 List idleList = idleThreads_[priority]; if (idleList.size() > 0) { //如果池中相应优先级的线程有空闲的,那么从中取出一个 //设置它的target,并唤醒它 //从空闲的线程队列中获取 int lastIndex = idleList.size() - 1; thread = (PooledThread) idleList.get(lastIndex); idleList.remove(lastIndex); thread.setTarget(target); } //池中没有相应优先级的线程 else { threadCreationCounter_++; // 创建新线程, thread = new PooledThread(target, "PooledThread #" + threadCreationCounter_, this); // 新线程放入池中 switch (priority) { case LOW_PRIORITY : { thread.setPriority(Thread.MIN_PRIORITY); break; } case NORMAL_PRIORITY : { thread.setPriority(Thread.NORM_PRIORITY); break; } case HIGH_PRIORITY : { thread.setPriority(Thread.MAX_PRIORITY); break; } default : { thread.setPriority(Thread.NORM_PRIORITY); break; } } //启动这个线程 thread.start(); } } } 复制代码 工作者线程代码: 复制代码 public class PooledThread extends Thread { private ThreadPool pool_; // 池中线程需要知道自己所在的池 private Runnable target_; // 线程的任务 private boolean shutDown_ = false; private boolean idle_ = false;//设置是否让线程处于等待状态 private PooledThread() { super(); } private PooledThread(Runnable target) { super(target); //初始化父类 } private PooledThread(Runnable target, String name) { super(target, name); } public PooledThread(Runnable target, String name, ThreadPool pool) { super(name); pool_ = pool; target_ = target; } private PooledThread(String name) { super(name);//初始化父类 } private PooledThread(ThreadGroup group, Runnable target) { super(group, target); } private PooledThread(ThreadGroup group, Runnable target, String name) { super(group, target, name); } private PooledThread(ThreadGroup group, String name) { super(group, name); } public java.lang.Runnable getTarget() { return target_; } public boolean isIdle() { return idle_;//返回当前的状态 } //工作者线程与通常线程不同之处在于run()方法的不同。通常的线程, //完成线程应该执行的代码后,自然退出,线程结束。 //虚拟机在线程结束后收回分配给线程的资源,线程对象被垃圾回收。] //而这在池化的工作者线程中是应该避免的,否则线程池就失去了意义。 //作为可以被放入池中并重新利用的工作者线程,它的run()方法不应该结束, //随意,在随后可以看到的实现中,run()方法执行完target对象的代码后, //就将自身repool(),然后调用wait()方法,使自己睡眠而不是退出循环和run()。 //这就使线程池实现的要点。 public void run() { // 这个循环不能结束,除非池类要求线程结束 // 每一次循环都会执行一次池类分配给的任务target while (!shutDown_) { idle_ = false; if (target_ != null) { target_.run(); // 运行target中的代码 } idle_ = true; try { //线程通知池重新将自己放回到池中 pool_.repool(this); // //进入池中后睡眠,等待被唤醒执行新的任务, //这里是线程池中线程于普通线程的run()不同的地方。 synchronized (this) { wait(); } } catch (InterruptedException ie) { } idle_ = false; } //循环这里不能结束,否则线程结束,资源被VM收回, //就无法起到线程池的作用了 } public synchronized void setTarget(java.lang.Runnable newTarget) {//设置新的target,并唤醒睡眠中的线程 target_ = newTarget; // 新任务 notifyAll(); // 唤醒睡眠的线程 } public synchronized void shutDown() { shutDown_ = true; notifyAll(); } } 复制代码 测试代码: 复制代码 public static void main(String[] args) { System.out.println("Testing ThreadPool "); System.out.println("Creating ThreadPool "); ThreadPool pool = ThreadPool.instance(); pool.setDebug(true); class TestRunner implements Runnable { public int count = 0; public void run() { System.out.println("Testrunner sleeping 5 seconds "); //此方法使本线程睡眠5秒 synchronized (this) { try { wait(5000);//等待5秒时间 } catch (InterruptedException ioe) { } } System.out.println("Testrunner leaving "); count++; } } System.out.println("Starting a new thread "); TestRunner runner = new TestRunner(); pool.start(runner, pool.HIGH_PRIORITY); System.out.println("count : " + runner.count); System.out.println("Thread count : " + pool.getCreatedThreadsCount()); pool.shutdown(); } } 复制代码 测试结果: 复制代码 Testing ThreadPool Creating ThreadPool Starting a new thread Testrunner sleeping 5 seconds count : 0 Thread count : 1 ThreadPool : shutting down ThreadPool : shutdown done. Testrunner leaving ThreadPool.repool() : Destroying incoming thread. ThreadPool.recycle() : done. 复制代码 本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/07/19/1246623.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

微信中很实用却被隐藏的功能(Android版)

微信是当前非常火爆的时尚社交软件,尤其是在朋友圈、聊(yue)天(pao)功能方面可谓是挖掘了人性的极致。但是微信并不仅仅像看上去那么简单,今天小魔来聊聊在微信里面找到一些实用的隐藏功能 No.1 多页签 有时候我会遇到一种情况:我们在某个公众号上阅读一篇好文章时,突然一个好友发来了紧急消息(或者另一半来查岗?!敢不回?),你若从文章页面切出去聊天界面,回复他们后,那么你重新进入文章是需要“重新点进公众号-翻回文章页面并选择进入”,偶尔需要加载时间。以上的步骤似乎有点繁琐耗时,尤其是那个文章是很难定位找回链接的(比如是某个公众号的历史文章)。今天小魔来介绍一个微信隐藏的功能-多页签功能,有点类似手机实现各个APP软件之间切换功能,因为这个功能将微信的链接文章变成了类似只有一个网页的APP,步骤如下: 在微信任意一个聊天窗口,输入“//multiwebview”,然后按发送 进入一个公众号的一篇文章阅读 然后点击主页键返回手机桌面,接着点进微信去到回复你好友的消息,这个时候,按下那个之前你用来切换手机各个启动的APP软件的按钮,此时你应该能够成功的看到了两个微信的页签了(获取直接从手机的通知栏进入和好友互动的聊天框,然后再按下那个APP之间的切换键也可以看到下图效果) 如果想取消这个(强大的)功能,只需要在一个聊天框输入“//multiwebview”即可(觉得这个步骤就没必要了,毕竟上面这种方便的切换功能是经常要用到的0_0);但注意的是,看完文章要记得按返回键退出或者点击文章的关闭按钮退出,否则这个文章的标签会像一个个app一样还存在着! No.2 微信来检验是否为二手手机 相信很多人在买手机的时候,都不想买到被人用过的二手手机,那么此时只需要在你安装登录以后进行一下操作即可检查出来是不是二手手机: 进入微信主页,点击“我-设置” 选择“帐号与安全” 进入“微信安全中心” 选择“找回帐号密码” 选择“申诉找回微信账号密码” 微信弹出“开始申诉”后,点击那个按钮 神奇的事情发生了,出现了两个帐号 因为我之前有用过另一个帐号(小),所以有两个帐号;即使先卸载重装了微信,如果重复以上的步骤,还是会显示这两个帐号;经他人测试,无论是恢复出厂设置、刷机升级、root破解、卸载重装,只要装过微信登录过,那么都会留下帐号记录,原因是微信在安装的时候会获取一个IMEI设备识别号(国际移动设备标识的缩写)然后上传至腾讯的微信服务器保存,以上的操作会通过IMEI号再次获取之前所有在该设备(手机)上装过微信、并且登录过的微信号列表。所以说,如果手机上显示的微信号列表中有你不认识的,那么很有可能你的手机就是二手机了(PS:还能检查你另一半有没有小号哦) 插播福利: 1.近期整理了20G资源,包含产品/运营/测试/程序员/市场等,互联网从业者【工作必备干货技巧、行业专业书籍、面试真题宝典等】 获取方式:扫描下方二维码,关注微信公众号【非典型互联网】,将最新的文章转发至朋友圈,截图发至公众号,即可获取干货链接; 2.互联网人交流群:关注微信公众号【非典型互联网】,在后台回复“入群”,人脉共享,一起交流; No.3 快速检测“伪好友” “伪好友”的意思是,实际上,那个人已经不是你的好友了,因为ta已经将你删了,但最恶心的是一般情况下只有自己与其进行聊天时才会发现ta是伪好友。所以我这里介绍简单的方法,在不打扰对方(即不通过聊天)来检测你觉得的潜在的伪好友是否真的存在——建群法。 发起群聊建群 选择可能存在的伪好友,如图中箭头所指那一名,以及至少一名好朋友(为了对比效果) 点击确定以后,群生成了,但是会发现:伪好友会有这此人“XXX拒绝加入群聊”标志语句,而正常的好友则是“XXX加入了群聊”,有拒绝标志语句的那个就是“伪好友” 发现伪好友之后,究竟怎么对待那就是仁者见仁,智者见智了,但是这里需要注意:这是正常的建群,只要建群者没有在群中说一句话,那么被邀请的人是是没感受到这个群的存在的;所以如果不想打扰其他正常好友或者不想被人知道这个测试的存在,那么请点击聊天框的右上角图标进行“删群退群”操作;否则会引来不必要的尴尬问号:“这个是什么群?” 伪好友的测试就轻而易举的完成了,也不用发一些测试好友的话导致不必要的聊天。 作者:魔术师JeffreyChu 文末福利: 1.近期整理了20G资源,包含产品/运营/测试/程序员/市场等,互联网从业者【工作必备干货技巧、行业专业书籍、面试真题宝典等】 获取方式:扫描下方二维码,关注微信公众号【非典型互联网】,将公众号最新的文章转发至朋友圈,截图发至公众号,即可获取干货链接; 2.互联网人交流群:关注微信公众号【非典型互联网】,在后台回复“入群”,人脉共享,一起交流;

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码