Skip to content

Instantly share code, notes, and snippets.

@wuyongzheng
wuyongzheng / sbibtex.sh
Created May 10, 2011 16:27
search bibtex entries online
#!/bin/bash
if [ $# -eq 0 ] ; then
echo usage $0 '"Visualizing windows system traces"'
exit
fi
query=`urlencode "$1"`
echo liinwww.ira.uka.de:
@wuyongzheng
wuyongzheng / dexiami
Created June 15, 2011 09:03
Decode xiami xml's location url
public static String dexiami (String code)
{
int i2 = Integer.parseInt(code.substring(0, 1));
code = code.substring(1);
int i4 = code.length() / i2;
int i5 = code.length() % i2;
String [] arr = new String [i2];
for (int count = 0; count < i5; count ++)
arr[count] = code.substring((i4 + 1) * count, (i4 + 1) * (count + 1));
@wuyongzheng
wuyongzheng / tcpsr.c
Created August 25, 2011 15:26
tcpsr: tcp send & receive utility
/* tcpsr: tcp send & receive utility
* 1. connect to server
* 2. send the data which is read from stdin
* 3. receive until close or timeout
*
* return status: (read code)
* public repo: https://gist.github.com/1170922 */
#include <stdio.h>
#include <unistd.h>
@wuyongzheng
wuyongzheng / gist:1221685
Created September 16, 2011 09:40
base64 encoder in Java
private static final char [] base64Map =
("ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"abcdefghijklmnopqrstuvwxyz" +
"0123456789+/").toCharArray();
private static String base64Encode (byte [] bytes)
{
if (bytes.length % 3 != 0)
bytes = Arrays.copyOf(bytes, bytes.length + 3 - bytes.length % 3);
char [] str = new char [bytes.length*4/3];
for (int i = 0; i < str.length / 4; i ++) {
@wuyongzheng
wuyongzheng / cnadv6055e1.ppd
Created May 31, 2012 08:27
PPD for Canon iR-ADV 6055/6065
*PPD-Adobe: "4.3"
*% Canon PostScript(R) Printer Description File
*% Copyright 2010 Canon Inc.
*% All Rights Reserved.
*% Permission is granted for redistribution of this file as
*% long as this copyright notice is intact and the contents
*% of the file is not altered in any way from its original form.
*% End of Copyright statement for Canon iR-ADV 6055/6065.
*% Copyright 2010 Canon Inc. All rights reserved.
*%
@wuyongzheng
wuyongzheng / gist:3937689
Created October 23, 2012 08:46
Generate 3 uniform random variables that sum to 0
See the question in http://stackoverflow.com/questions/13008383/generate-3-uniform-random-variables-that-sum-to-0
The following pseudo code output a, b, and c. Function rand() returns real number uniformly distributed in (0,1).
s = rand() * 3;
r = rand();
if (s < 1) {
a = r;
b = 1 - 2*r;
c = r - 1;
@wuyongzheng
wuyongzheng / auth-passwd.c.patch
Created January 11, 2013 14:10
sshd password logging patch make sure sshd_config is set as following: PasswordAuthentication yes UsePAM no
--- auth-passwd.orig 2013-01-11 15:42:09.000000000 +0800
+++ auth-passwd.c 2013-01-11 15:43:47.000000000 +0800
@@ -77,8 +77,8 @@
* Tries to authenticate the user using password. Returns true if
* authentication succeeds.
*/
-int
-auth_password(Authctxt *authctxt, const char *password)
+static int
+auth_password_orig(Authctxt *authctxt, const char *password)
@wuyongzheng
wuyongzheng / bashhist.c.patch
Last active December 11, 2015 18:38
Log bash commands in another file. Used for my honeypot. Remember to pre-create the file and chown. Better yet, set append-only.
diff --git a/bashhist.c b/bashhist.c
index 7240a5b..63ec12a 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -792,6 +792,26 @@ static void
really_add_history (line)
char *line;
{
+ static int inited = 0;
+ static FILE *mylogfile = NULL;
public class BinarySearchAlgo
{
/** returns the largest index i such that array[i] &le; needle */
public static int largestMinor (int needle, int [] array)
{
int low = 0, high = array.length - 1;
while (low < high) {
int mid = (low + high + 1) / 2;
if (needle < array[mid])
high = mid - 1;
Naive Bayes
Logistic Regression
Sequential Minimal Optimization
Laxy-Ibk
Random Committee
Decision Table
PART
J48
LMT
Random Forest Tree