Skip to content

Instantly share code, notes, and snippets.

View pwrliang's full-sized avatar

Liang Geng pwrliang

View GitHub Profile
@pwrliang
pwrliang / CMakeLists.txt
Created February 4, 2018 17:14
CudaWithMPI Example
cmake_minimum_required(VERSION 2.8)
project(MPITest)
find_package(CUDA QUIET REQUIRED)
find_package(MPI REQUIRED)
if (MPI_FOUND)
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
else (MPI_FOUND)
message(SEND_ERROR "This application cannot compile without MPI")
endif (MPI_FOUND)
# Specify binary name and source file to build it from
@pwrliang
pwrliang / PageRank.sql
Last active February 13, 2018 16:21
Implementing PageRank Algorithm in SQL
-- The graph data and algorithm source from the book "Mining of Massive Datasets", P175, http://infolab.stanford.edu/~ullman/mmds/book.pdf
-- This script has been verified the correctness in SQL Server 2017 Linux Version.
DROP TABLE Node;
DROP TABLE Edge;
DROP TABLE OutDegree;
DROP TABLE PageRank;
CREATE TABLE Node(id int PRIMARY KEY);
CREATE TABLE Edge(src int,dst int, PRIMARY KEY (src, dst));
CREATE TABLE OutDegree(id int PRIMARY KEY, degree int);
CREATE TABLE PageRank(id int PRIMARY KEY, rank float);
@pwrliang
pwrliang / Combinations.java
Last active September 20, 2018 08:17
Permutations And Combinations
class Combinations {
/*
a b c
0 0 0 -> []
0 0 1 -> [c]
0 1 0 -> [b]
...
1 1 0 -> [a b]
1 1 1 -> [a b c]
*/
@pwrliang
pwrliang / TopK.java
Created March 31, 2018 01:44
Select K'th smallest element
/**
* select k'th smallest element
* @param nums the array to select
* @param k 0 <= k < |nums|
* @return k'th element
*/
private int select(int[] nums, int k) {
int lo = 0, hi = nums.length - 1;
// If just one element, goto return directly;
@pwrliang
pwrliang / MatrixDFS.java
Created April 14, 2018 02:04
Matrix DFS
public class MatrixDFS {
int[] moveX = {0, 0, -1, 1};
int[] moveY = {1, -1, 0, 0};
boolean[][] visited;
public void search(int[][] matrix, int x, int y, String path) {
path += " -> " + y + "," + x;
if (y == 2 && x == 2) {
System.out.println(path);
System.out.println("--------------");
@pwrliang
pwrliang / note.txt
Created April 27, 2018 15:45
CUDA Project Compile commandline
sudo apt-get install libmpc-dev
sudo apt install gcc-multilib
wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
tar -zxvf gcc-5.4.0.tar.gz
cd gcc-5.4.0
./configure --prefix=/opt/gcc-5.4.0 --enable-languages=c,c++
make -j 8
sudo make install
@pwrliang
pwrliang / smb.conf
Last active December 9, 2018 05:49
Raspberrypi samba
[global]
netbios name = RASPBERRYPI
server string = The Raspberrypi File Center
workgroup = WORKGROUP
protocol = SMB3
smb encrypt = auto
# allow follow soft links
follow symlinks = yes
wide links = yes
unix extensions = no
#!/bin/bash
#set -e
# install-wifi - 19/10/2017 - by MrEngman.
UPDATE_SELF=${UPDATE_SELF:-1}
UPDATE_URI="http://downloads.fars-robotics.net/wifi-drivers/install-wifi"
ROOT_PATH=${ROOT_PATH:-"/"}
WORK_PATH=${WORK_PATH:-"${ROOT_PATH}/root"}
@pwrliang
pwrliang / TestClass
Created May 19, 2018 01:50
Put class method into map and call it (C++11)
class TestClass {
public:
enum MethodEnum {
METHOD_1,
METHOD_2,
METHOD_3
};
std::map<MethodEnum, std::function<void(void)>> method_map;
@pwrliang
pwrliang / client.sh
Last active November 25, 2018 13:06
ReportIP
url=https://***************/post_ip.php?ip=
while true
do
main_ipv4=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'|head -n 1`
main_ipv6=`ifconfig | awk '/inet6/{print $2}'|head -n 1`
curl -k $url"\"$main_ipv4-$main_ipv6\""
sleep 5
done
#crontab -e