Skip to content

Instantly share code, notes, and snippets.

View jp1017's full-sized avatar
:octocat:
Focusing

妙法莲华经 jp1017

:octocat:
Focusing
View GitHub Profile
@jp1017
jp1017 / Employee.java
Created June 5, 2016 08:47 — forked from greycode/Employee.java
Guava 开发
package org.yct.demo.guava;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import static com.google.common.base.Preconditions.*;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering;
public class Employee implements Comparable<Employee> {
private String name;
/**
* 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具
*
* 参考 https://github.com/wandergis/coordtransform 实现的Java版本
* @author geosmart
*/
public class CoordinateTransformUtil {
static double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
// π
static double pi = 3.1415926535897932384626;
@jp1017
jp1017 / getGPSInfo.java
Created May 23, 2016 06:35
利用 LocationManager 实时获取 GPS 定位信息,wgs84格式
/**
* 获取原生gps信息,代码放 MainActivity 里就可以
*/
public void getGPSInfo() {
LocationManager mManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
return;
@jp1017
jp1017 / BeanUtils.class
Last active May 16, 2016 11:54
Serializable 实现 java 深克隆: http://www.jianshu.com/p/c31e01a5d55d
public abstract class BeanUtils {
/**
* 只要要克隆的对象以及对象所包含的引用类型的成员对象所在的类实现了 java.io.Serializable 接口即可做到完美克隆。
*/
@SuppressWarnings("unchecked")
public static <T> T cloneTo(T src) throws RuntimeException {
ByteArrayOutputStream memoryBuffer = new ByteArrayOutputStream();
ObjectOutputStream out = null;
ObjectInputStream in = null;
#!/bin/bash
function count() {
local insert=0
local delete=0
while read line ;do
current=`echo $line| awk -F',' '{printf $2}' | awk '{printf $1}'`
if [[ -n $current ]]; then
insert=`expr $insert + $current`
fi
current=`echo $line | sed -n 's/.*, //p' | awk '{printf $1}'`
@jp1017
jp1017 / pre-commit
Created April 25, 2016 05:50
GitHook自动检查版本冲突问题 http://philo.top/2016/04/05/GitHook/
echo BEFORE COMMIT
ex=$(git remote -v | awk '{printf "%s\n",$1}' | grep wothing | wc -l)
if [[ $ex == 0 ]];then
git remote add wothing https://github.com/XXXXX/XXXX.git
fi
git fetch wothing
echo -e "UR \033[32m ahead $(git rev-list --left-only develop...wothing/develop | wc -l) \033[0m commits before"
echo -e "UR \033[31m behind $(git rev-list --right-only develop...wothing/develop | wc -l) \033[0m commits after"
@jp1017
jp1017 / CHexConver.java
Created April 18, 2016 08:32 — forked from alanland/CHexConver.java
java 中 Hex的转换
package mobi.dzs.util;
/**
* 16进制值与String/Byte之间的转换
* @author JerryLi
* @email [email protected]
* @data 2011-10-16
* */
public class CHexConver
{
@jp1017
jp1017 / Broadcaster.java
Created March 28, 2016 03:04
Android Socket 发送广播包的那些坑 http://ticktick.blog.51cto.com/823160/1707858
package com.example.test;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
@jp1017
jp1017 / AndroidCommonUtils.java
Last active May 30, 2016 01:03
安卓新手必备的常用代码片段整理
/*
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2015, 蒋朋, china, qd. sd
** All Rights Reserved
**
** By(******公司)
** http://www.******.com
**
**-----------------------------------版本信息------------------------------------
@jp1017
jp1017 / colors.xml
Created February 25, 2016 07:36
A list of colors for android res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
来源:https://github.com/wtsang02/colors/blob/master/color.xml
Version: 2
Organized by: Willie Tsang
-->
<resources>
<!-- Android style -->