Skip to content

Instantly share code, notes, and snippets.

@redcho
redcho / LogisticRegression.py
Created April 5, 2016 13:03
Logistic Regression
def sigmoid(X):
return 1 / (1 + (e ** (-1*X)))
def gradient(theta, x, y):
grad = np.zeros(theta.shape).flatten()
m = y.size
h = sigmoid(x.dot(theta))
for jth in range(x.shape[1]):
xjth = x[:, jth]
@redcho
redcho / func.java
Last active October 1, 2016 21:53
Find first keyword in message
public static String getKeyword(String msg, ArrayList<String> keywordList){
for(String key : keywordList){
if(msg.toLowerCase().contains(key.toLowerCase())){
return key;
}
}
return "";
}
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
public class Main {
public static void main(String[] args) throws IOException {
String luceneIndexPath = "my-elasticsearch/data/nodes/0/indices/eCCAJ-x6SOuN6w7vqr4tGQ/0/index";
Directory index = FSDirectory.open(Paths.get(luceneIndexPath));
for(int i = 0; i < reader.maxDoc(); i++){
if(((DirectoryReader) reader).isCurrent()){
Document document = reader.document(i);
String source = document.getBinaryValue("_source").utf8ToString();
System.out.println(source);
}
}
FROM alpine:3.7
COPY rootfs /
RUN apk --update add --no-cache \
curl=7.61.1-r2 \
openvpn=2.4.4-r1 \
supervisor \
openssh