Skip to content

Instantly share code, notes, and snippets.

View lb5160482's full-sized avatar
🎯
Focusing

Bo lb5160482

🎯
Focusing
  • San Francisco Bay Area
View GitHub Profile
@lb5160482
lb5160482 / GetGCD.cpp
Created June 27, 2018 00:10
Get GCD(Greatest Comman Devider)
int getGcd(int a, int b) {
return b == 0 ? a : getGcd(b, a % b);
}
@lb5160482
lb5160482 / C++_priority_queue_overload_cmp.cpp
Created June 14, 2018 00:31
C++ priority_queue overload comparison function
struct com{
bool operator()( T &t1, T &t2) {
if(t1.x != t2.x) {
return t1.x < t2.x -->按x降序
}
return t1.y > t2.y -->x相等时按y升序
}
};
priority_queue<T, vector<T>, com> que;
@lb5160482
lb5160482 / TCPserver.java
Created January 15, 2018 21:59
TCP server JAVA Android
package com.dreamworldvision.trash;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
@lb5160482
lb5160482 / TCPclientC#.cs
Created January 15, 2018 21:58
TCP/IP C#
using System.Collections;
using UnityEngine;
using System;
using System.Threading;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
@lb5160482
lb5160482 / TCPclient.cpp
Last active January 15, 2018 21:56
TCP/IP c++
#include <WinSock2.h>
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
void main()
{
//¼ÓÔØÌ×½Ó×Ö
WSADATA wsaData;
char buff[1024];
@lb5160482
lb5160482 / rotm2quat.cpp
Created January 15, 2018 21:54
Rotation matrix to quaternion conversion c++
inline float SIGN(float x) {
return (x >= 0.0f) ? +1.0f : -1.0f;
}
inline float NORM(float a, float b, float c, float d) {
return sqrt(a * a + b * b + c * c + d * d);
}
// quaternion = [w, x, y, z]'
Mat mRot2Quat(const Mat& m) {