Skip to content

Instantly share code, notes, and snippets.

package io.metadata;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.apache.commons.lang.StringEscapeUtils;
package io.github.czxttkl.stocks.old;
import io.github.czxttkl.stocks.auxi.JS;
import io.github.czxttkl.stocks.auxi.Stock;
import io.github.czxttkl.stocks.auxi.StockGlobal;
import io.github.czxttkl.util.UtilJava;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@czxttkl
czxttkl / gist:7945408
Last active December 31, 2015 06:09
这是一道检测inversion count的算法。它将检测输入序列中反序输入的个数,即检测其中有几对A[i] > A[j], i < j 比如输入4,3,2,1,输出应该为3+2+1=6.。 因为: 1. 4比3,2,1大,但4在输入序列中是第一位,比3,2,1的index都小 2. 3比2,1大 3. 2比1大
#!/usr/bin/python
############################################################
#
#
# author: [email protected]
# date: 03/12/2013
# purpose: count inversions in a given array of numbers
#
#
public class TestConSum {
public static void main(String... args) {
int[] arr = new int[]{-2,11,-4,13, -9, -10,99};
int negsum = 0;
int maxsum = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0) {
/**
* Return if the point is in the floor's contour +1: inside the contour -1: outside the contour 0:lies on the edge;
*
* @param openCvWidth
* The width in the opencv screen
* @param openCvHeight
* The height in the opencv screen
*/
public int isPointInFloor(int openCvWidth, int openCvHeight) {
return isPointInFloor(openCvWidth, openCvHeight, false);
public void setCurrentMode(int currentMode) {
this.currentMode = currentMode;
switch(mode) {
case MODE_MAIN_MENU:
OpenGLBugManager.generateMainMenuBug();
break;
case MODE_TUTORIAL_1:
public void setCurrentMode(int currentMode) {
this.currentMode = currentMode;
switch(mode) {
case MODE_MAIN_MENU:
OpenGLBugManager.generateMainMenuBug();
break;
case MODE_TUTORIAL_1:
public class TryJoin {
public static void main(String... arg) throws InterruptedException {
Thread a = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(5000);
@czxttkl
czxttkl / gist:6401314
Created August 31, 2013 23:30
Two linked lists (simple link, not double link) heads are given: headA, and headB; it is also given that the two lists intersect, thus after the intersection they have the same elements to the end. Find the first common element (without modifying the lists elements or using additional datastructures)
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class HomeWork1b {
private static <T> void findFirstSharedElement(LinkedList<T> linkA,
LinkedList<T> linkB) {
int offsetA = 0;
@czxttkl
czxttkl / gist:6398741
Created August 31, 2013 14:56
Two linked lists (simple link, not double link) heads are given: headA, and headB; it is also given that the two lists intersect, thus after the intersection they have the same elements to the end. Find the first common element (without modifying the lists elements or using additional datastructures)
package io.github.czxttkl.homework;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class HomeWork1b {
private static <T> void findFirstElement(LinkedList<T> linkA,
LinkedList<T> linkB) {