Install ibus-chewing
sudo apt-get purge hime hime-chewing
sudo apt-get install ibus-chewing
im-config -n ibus
ibus-setup
ibus restart
sudo apt-get purge hime hime-chewing
sudo apt-get install ibus-chewing
im-config -n ibus
ibus-setup
ibus restart
$ mkdir -p jfrog_data $ docker run --name jfrogartifactory -d -v jfrog_data:/var/opt/jfrog/artifactory -p 8085:8081 docker.bintray.io/jfrog/artifactory-oss
init: mkdir -p jfrog_data run: docker run --name jfrogartifactory -d -v `pwd`/jfrog_data:/var/opt/jfrog/artifactory -p 8085:8081 docker.bintray.io/jfrog/artifactory-oss stop: docker stop jfrogartifactory;docker rm jfrogartifactory clean: rm -rf jfrog_data docker rmi -f docker.bintray.io/jfrog/artifactory-oss backup: zip -r jfrog_data.zip jfrog_data
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.1"
}
}
artifactory_user=XXXX
artifactory_password=YYYY
artifactory_contextUrl=http://10.70.70.40:8085/artifactory
$ ./gradlew assembleRelease artifactoryPublish
repositories {
jcenter()
maven {
url "http:/[IP]:8085/artifactory/gradle-release-local"
}
}
Step 2: Import the library in your module and compile itcompile "com.pakcage:module:version"
It's done!$ apt-get update -qq $ apt-get install -qqy \ apt-transport-https \ ca-certificates \ curl \ lxc \ iptables $ curl -sSL https://get.docker.com/ | sh $ usermod -a -G docker $USER
$ docker pull tzutalin/opengrokAlternatively, you can check out my Dockerfile on Github, and build the image from scratch.
$ docker run -t -d --name=opengrok -v [Absolute path]:/src -p 8080:8080 tzutalin/opengroktzutalin/opengrok container will periodically update the index. So you didn't need to update index by yourself.
$ git clone https://github.com/tzutalin/labelImg.git
$ docker pull tzutalin/py2qt4Step3: Get started with the application and container
docker run -it \ --user $(id -u) \ -e DISPLAY=unix$DISPLAY \ --workdir=$(pwd) \ --volume="/home/$USER:/home/$USER" \ --volume="/etc/group:/etc/group:ro" \ --volume="/etc/passwd:/etc/passwd:ro" \ --volume="/etc/shadow:/etc/shadow:ro" \ --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ tzutalin/py2qt4Then, you will see that we can run GUI inside the container.
$ mkdir docker-registry;cd $_;mkdir dataCreate a docker-compose.yml for docker-compose.
Get any image from the hub and tag it to point to your registry:registry:restart: alwaysimage: registry:2ports:- 5000:5000environment:REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /datavolumes:- ./data:/data
$ docker pull ubuntu && docker tag ubuntu localhost:5000/ubuntu
$ docker push localhost:5000/ubuntu
DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=HOST:5000"
$ docker pull HOST:5000
/ubuntu
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins
sudo apt-get update sudo apt-get install jenkins
sudo usermod -a -G YOUR_USERNAME jenkins
HTTP_PORT=8080
HTTP_PORT=8880
sudo service jenkins restart
ANDROID_NDK_HOMEJAVA_HOME = /usr/lib/jvm/java-1.8.0-openjdk-amd64
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <sys/file.h> #include <iostream> void lockUnLock() { int fd, i; char path[] = "test.txt"; fd = open(path, O_WRONLY | O_CREAT); if (fd != -1) { std::cout << "open file " << path << std::endl; std::cout << "Please input a number to lock the file" << path << std::endl; scanf("%d", &i); if (flock(fd, 2) == 0) { std::cout << "The file was locked " << std::endl; } else { std::cout << "The file was not locked " << std::endl; } std::cout << "please input a number to unlock the file " << std::endl; scanf("%d", &i); if (flock(fd, 8) == 0) { std::cout << "The file was unlocked. " << std::endl; } else { std::cout << "The file was no unlocked. " << std::endl; } close(fd); } else { std::cout << "Cannot open file " << path << std::endl; } } int main() { lockUnLock(); return 0; }
jclass arrayListClass = env->FindClass("java/util/ArrayList");
....
env->DeleteLocalRef(arrayListClass);
Is it necessary to call DeleteLocalRef ? In fact, it is unnecessary to call DeleteLocalRef in most of the cases. However, JNI has a limited (but configurable) number of local references available. So, the best practice is to delete if the reference is created in a loop#pragma once
// A *string*, LIB_VERSION, in the form "x.y.[z]"
// where x is the major version number,
// y is the minor version number,
// and z is the patch level
#define LIB_VERSION_MAJOR 0
#define LIB_VERSION_MINOR 4
#define LIB_VERSION_PATCH 12
#define AUX_STR_EXP(__A) #__A
#define AUX_STR(__A) AUX_STR_EXP(__A)
#define LIB_VERSION AUX_STR(LIB_VERSION_MAJOR) "."
\ AUX_STR(LIB_VERSION_MINOR) "."
\ AUX_STR(LIB_VERSION_PATCH)
REG_VERSION_LINE = r"ASUS_VISION_LIB_VERSION_PATCH. +([0-9:]+)"
def changeSoVersion(versionFile):
# Read in the file
filedata = None
with open(versionFile, 'r') as file:
filedata = file.read()
matches = re.finditer(REG_VERSION_LINE, filedata)
for matchNum, match in enumerate(matches):
oldVersion = match.group(1)
newVersion = str(int(match.group(1)) + 1)
print oldVersion
print newVersion
if len(oldVersion) > 0 and len(newVersion) > 0:
filedata = filedata.replace(oldVersion, newVersion)
# Write the file out again
with open(versionFile, 'w') as file:
file.write(filedata)
public static void main(String[] args) {
char[] task = findBestTaskArrangement(String.valueOf("AAABBB").toCharArray(), 2);
System.out.println(task);
System.out.println("Total time: " + computeTatalTaskTime(task, 2));
// ABABAB
// Total time:8
}
public static char[] findBestTaskArrangement(char[] tasks, int k) {
int n = tasks.length;
Map<Character, Integer> map = new HashMap<>();
for (char task : tasks) {
map.put(task, map.getOrDefault(task, 0) + 1);
}
PriorityQueue<Task> queue = new PriorityQueue<>(new Comparator<Task>() {
@Override
public int compare(Task a, Task b) {
return b.frequency - a.frequency;
}
});
for (Map.Entry<Character, Integer> entry : map.entrySet()) {
queue.offer(new Task(entry.getKey(), entry.getValue()));
}
tasks = new char[n];
int i = 0;
while (!queue.isEmpty()) {
int c = 0;
List<Task> nextRoundTask = new ArrayList<>();
while(c++ < k && !queue.isEmpty()) {
Task task = queue.poll();
task.frequency--;
// Locate the next empty slot
tasks[i++] = task.id;
if (task.frequency > 0)
nextRoundTask.add(task);
}
for (Task task : nextRoundTask) {
queue.offer(task);
}
}
return tasks;
}
// helper class
public static class Task {
char id;
int frequency;
Task(char i, int f) {
id = i;
frequency = f;
}
}
public static int computeTatalTaskTime(char[] tasks, int k) {
HashMap<Character, Integer> taskLastTimeMap = new HashMap<>();
int currTime = 0;
for (char task : tasks) {
if (taskLastTimeMap.containsKey(task)) {
int exceptedTime = taskLastTimeMap.get(task) + k + 1;
if (exceptedTime > currTime) {
currTime = exceptedTime;
} else
currTime++;
} else {
currTime++;
}
taskLastTimeMap.put(task, currTime);
}
return currTime;
}
public static void main(String[] args) {
MinQueue queue = new MinQueue();
// Input 3 -> 1 -> 4 -> 2
queue.offer(3).offer(1).offer(4).offer(2);
// 0 0 0 1 1 1
while(queue.isEmpty() == false) {
System.out.println(queue.getMin());
queue.poll();
}
// Output should be 1 -> 1 -> 2 -> 2
}
static class MinQueue {
private Queue<Integer> mQueue = new LinkedList<>();
private Deque<Integer> mMinDeque = new ArrayDeque<>();
MinQueue offer(int val) {
int min = val;
while(!mMinDeque.isEmpty() && mMinDeque.getLast() > val) {
mMinDeque.pollLast();
min = val;
}
int size = mQueue.size() - mMinDeque.size();
for (int i = 0; i <= size; i++) {
mMinDeque.addLast(min);
}
mQueue.offer(val);
return this;
}
int poll() {
mMinDeque.poll();
return mQueue.poll();
}
boolean isEmpty() {
return mQueue.isEmpty();
}
int getMin() {
return mMinDeque.peek();
}
}
static class Point {
int x;
int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public double getDistFromCenter() {
return Math.sqrt(x * x + y * y);
}
}
public static void main(String[] args) {
Point[] points = new Point[7];
points[0] = new Point(0, 0);
points[1] = new Point(1, 7);
points[2] = new Point(2, 2);
points[3] = new Point(2, 2);
points[4] = new Point(3, 2);
points[5] = new Point(1, 4);
points[6] = new Point(1, 1);
int k = 3;
qSelect(points, k - 1);
for (int i = 0; i < k; i++) {
System.out.println("" + points[i].x + "," + points[i].y);
}
// Output will be
// 0,0
// 1,1
// 2,2
}
// in-place qselect and zero-based
static void qSelect(Point[] points, int k) {
int l = 0;
int h = points.length - 1;
while (l <= h) {
int partionInd = partition(l, h, points);
if (partionInd == k) {
return;
} else if (partionInd < k) {
l = partionInd + 1;
} else {
h = partionInd - 1;
}
}
}
static int partition(int l, int h, Point[] points) {
// Random can be better
// int p = l + new Random.nextInt(h - l + 1);
int p = l + (h - l) / 2;
int ind = l;
swap(p, h, points);
Point comparePoint = points[h];
for (int i = l; i < h; i++) {
if (points[i].getDistFromCenter() < comparePoint.getDistFromCenter()) {
swap(i, ind, points);
ind++;
}
}
swap(ind, h, points);
return ind;
}
static void swap(int i, int j, Point[] points) {
Point temp = points[i];
points[i] = points[j];
points[j] = temp;
}
static class TreeNode {
public TreeNode(char v) { val = v;}
char val;
TreeNode left;
TreeNode right;
}
static class MyIterator {
Stack<TreeNode> stack = new Stack<>();
MyIterator(TreeNode root) {
pullAll(root);
}
void pullAll(TreeNode node) {
while(node != null) {
stack.push(node);
node = node.left;
}
}
public TreeNode next() {
TreeNode next = stack.pop();
if (next.right != null) {
pullAll(next.right);
}
return next;
}
public TreeNode nextLeaf() {
while(hasNext()) {
TreeNode next = next();
if (next.left == null && next.right == null) {
return next;
}
}
return null;
}
boolean hasNext() {
return stack.isEmpty() == false;
}
}
public static void main(String[] args) {
TreeNode root1 = new TreeNode('A');
root1.left = new TreeNode('B');
root1.right = new TreeNode('C');
root1.left.left = new TreeNode('D');
root1.left.right = new TreeNode('E');
TreeNode root2 = new TreeNode('A');
root2.left = new TreeNode('D');
root2.right = new TreeNode('B');
char[] res = findFirstNonMatch(root1, root2);
System.out.println(res);
}
static char[] findFirstNonMatch(TreeNode root1, TreeNode root2) {
MyIterator iter1 = new MyIterator(root1);
MyIterator iter2 = new MyIterator(root2);
while(true) {
TreeNode leaf1 = iter1.nextLeaf();
TreeNode leaf2 = iter2.nextLeaf();
if (leaf1 == null || leaf2 == null) break;
if (leaf1.val != leaf2.val) {
return new char[] {leaf1.val, leaf2.val};
}
}
return new char[] {};
}
static class TreeNode {
public TreeNode(int v) { val = v;}
int val;
TreeNode left;
TreeNode right;
}
public static void main(String[] args) {
// 10
// 5 40
// 1 7 50
int pre[] = new int[] { 10, 5, 1, 7, 40, 50 };
int size = pre.length;
TreeNode root = constructTree(pre, 0, size - 1);
printInorder(root);
}
public static TreeNode constructTree(int[] pre, int l, int h) {
if (l > h) return null;
if (l == h) return new TreeNode(pre[l]);
TreeNode root = new TreeNode(pre[l]);
int ind = l + 1;
// Find the first index which is greater than or equal to root
for (int i = l + 1; i <= h; i++) {
if (root.val < pre[i]) {
ind = i;
break;
}
}
root.left = constructTree(pre, l + 1, ind - 1);
root.right = constructTree(pre, ind, h);
return root;
}
public static TreeNode constructTreeIterative(int[] pre, int l, int h) {
if (l > h) return null;
Stack<TreeNode> stack = new Stack<>();
TreeNode root = new TreeNode(pre[l]);
stack.push(root);
for (int i = l + 1 ; i <= h ; i++) {
int val = pre[i];
// Handle left side
if (stack.peek().val > val) {
TreeNode left = new TreeNode(val);
stack.peek().left = left;
stack.push(left);
} else {
// Handle right side and find its paraent
TreeNode rightParent = null;
while(!stack.isEmpty() && stack.peek().val < val) {
rightParent = stack.pop();
}
rightParent.right = new TreeNode(val);
stack.push(rightParent);
}
}
return root;
}
public static void printInorder(TreeNode node) {
if (node == null) {
return;
}
printInorder(node.left);
System.out.print(node.val + " ");
printInorder(node.right);
}
int n = 4;
int[][] relations = new int[][] { { 0, 1 }, { 1, 2 }, { 2, 3 } };
// Build a graph and initialize groups
HashMap<Integer, Set<Integer>> graph = new HashMap<>();
int[] group = new int[4];
Arrays.fill(group, -1);
for (int[] edge : relations) {
Set neighbors = graph.getOrDefault(edge[0], new HashSet<>());
neighbors.add(edge[1]);
graph.put(edge[0], neighbors);
}
// BFS, start with 0
Queue queue = new LinkedList<>();
queue.offer(0);
int groupdId = 0;
group[0] = groupdId;
while(queue.isEmpty() == false) {
int v = queue.poll();
groupdId = 1 - group[v];
// Get its neighbors
// No neighbors..
if (graph.get(v) == null) continue;
for (int neighbor : graph.get(v)) {
if (group[neighbor] == -1) {
group[neighbor] = groupdId;
queue.offer(neighbor);
} else if (group[neighbor] == group[v]) {
// It cannot be divided into two group. Invalid bipartite graph
break;
}
}
}
for (int g : group) {
System.out.println(g);
}
#include "flatbuffers/util.h"
flatbuffers::FlatBufferBuilder builder;
// Create something using builder
// ......
// Save to file
bool result = flatbuffers::SaveFile(filename.c_str(),
(const char *) builder.GetBufferPointer(),
(size_t) builder.GetSize(), true);
// Load from file
std::string buffer;
result = flatbuffers::LoadFile(fileName, true, &buffer);
printf("\nLoadFile Result = %d", result);
// You can write your own Save/load function
bool MySaveFile(const char *name, const char *buf, size_t len,
bool binary) {
std::ofstream ofs(name, binary ? std::ofstream::binary : std::ofstream::out);
if (!ofs.is_open()) return false;
ofs.write(buf, len);
return !ofs.bad();
}
bool MyLoadFileRaw(const char *name, bool binary, std::string *buf) {
std::ifstream ifs(name, binary ? std::ifstream::binary : std::ifstream::in);
if (!ifs.is_open()) {
return false;
}
if (binary) {
// The fastest way to read a file into a string.
ifs.seekg(0, std::ios::end);
auto size = ifs.tellg();
(*buf).resize(static_cast(size));
ifs.seekg(0, std::ios::beg);
ifs.read(&(*buf)[0], (*buf).size());
} else {
// This is slower, but works correctly on all platforms for text files.
std::ostringstream oss;
oss << ifs.rdbuf();
*buf = oss.str();
}
return !ifs.bad();
}