Skip to content

Instantly share code, notes, and snippets.

View c0rp-aubakirov's full-sized avatar
🏠
Working from home

Sanzhar Aubakirov c0rp-aubakirov

🏠
Working from home
View GitHub Profile
@c0rp-aubakirov
c0rp-aubakirov / documentum_ucf_after
Last active August 29, 2015 14:10
This ghist is for post in my blog, about documentum problem
<?xml version="1.0" encoding="UTF-8"?>
<?dctm fileVersion="5.3.0.1" compatibilityVersion="5.3.0.1"?>
<ucfInstaller codebase="" loggerLevel="INFO">
<app id="shared" version="7.0.0000.0507a" compatibilityVersion="5.3.0"/>
<platform os="all" arch="all">
<runtime type="all" version="any">
<nativelibs>
<lib version="7.0.0000.0507" href="ucf-client-installer.zip"/>
</nativelibs>
<defaults>
@c0rp-aubakirov
c0rp-aubakirov / documentum_ucf_before
Last active August 29, 2015 14:10
This ghist is for post in my blog, about documentum problem
<?xml version="1.0" encoding="UTF-8"?>
<?dctm fileVersion="5.3.0.1" compatibilityVersion="5.3.0.1"?>
<ucfInstaller codebase="" loggerLevel="INFO">
<app id="shared" version="7.0.0000.0507" compatibilityVersion="5.3.0"/>
<platform os="all" arch="all">
<runtime type="all" version="any">
<nativelibs>
<lib version="7.0.0000.0507" href="ucf-client-installer.zip"/>
</nativelibs>
<defaults>
@c0rp-aubakirov
c0rp-aubakirov / daemon script for jboss
Created December 10, 2014 07:33
Jboss standalone-as.sh
#!/bin/sh
#
# JBoss standalone control script
#
# chkconfig: - 80 20
# description: JBoss AS Standalone
# processname: standalone
# pidfile: /var/run/jboss-as/jboss-as-standalone.pid
# config: /etc/jboss-as/jboss-as.conf
@c0rp-aubakirov
c0rp-aubakirov / ClientInfo.java
Last active March 29, 2024 06:50
How to get full client info using servlet request, including client IP, browser, os, use-agent and referer
public void printClientInfo(HttpServletRequest request) {
final String referer = getReferer(request);
final String fullURL = getFullURL(request);
final String clientIpAddr = getClientIpAddr(request);
final String clientOS = getClientOS(request);
final String clientBrowser = getClientBrowser(request);
final String userAgent = getUserAgent(request);
logger.info("\n" +
@c0rp-aubakirov
c0rp-aubakirov / Classify.java
Last active January 14, 2016 05:36
Lucene 5.3.1 Classification with Leave-one-out cross validation
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.classification.ClassificationResult;
import org.apache.lucene.classification.Classifier;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.SlowCompositeReaderWrapper;
import org.apache.lucene.search.*;
import org.apache.lucene.util.BytesRef;
@c0rp-aubakirov
c0rp-aubakirov / AnalyzerFactory.java
Last active January 20, 2016 18:27
To combine different type of analyzers
public class AnalyzerFactory {
public Analyzer analyzer(AnalyzerType type, FilterType filter) {
final CustomizableRussianAnalyzer analyzer = new CustomizableRussianAnalyzer();
switch (filter) {
case STEMMING_AND_REMOVE_SHORT:
analyzer.ifNeedStemming(true).ifNeedRemoveShort(true);
break;
case STEMMING_AND_NOT_REMOVE_SHORT:
@c0rp-aubakirov
c0rp-aubakirov / VotingClassifier.java
Created January 21, 2016 15:48
Combine Classifiers
package kz.moe.classifier.classifier;
import kz.moe.classifier.index.MessageIndexer;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.NotImplementedException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.classification.ClassificationResult;
import org.apache.lucene.classification.Classifier;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
@c0rp-aubakirov
c0rp-aubakirov / News
Created January 25, 2016 11:15
Структура сообщения. Видно стандартные поля сообщения
{
"date": "Dec 15, 2015 5:20:06 PM",
"title": "Пресс-тур в трассовый медико-спасательный пункт Жамбылской области",
"URL": "http://emer.gov.kz/index.php?option\u003dcom_content\u0026view\u003darticle\u0026id\u003d30909%3A2015-12-15-11-12-19\u0026catid\u003d20%3A2011-06-09-13-26-46\u0026Itemid\u003d5\u0026lang\u003dru",
"tags": [],
"type": "NEWS",
"notificationId": -1385396753,
"body": "\n   В настоящее время в Республике Казахстан функционирует сформировавшийся Центр медицины катастроф, находящийся в состоянии постоянного развития на основе передового международного опыта медицины в области ликвидации чрезвычайных ситуаций.\n   За годы существования служба медицины катастроф зарекомендовала себя, как самостоятельная отрасль здравоохранения страны, имеющая свой объект деятельности и присущие ей методы работы.\n   Одним из приоритетных направлений деятельности Центра медицины катастроф является совершенствование системы оказания медицинской и психологической помощи пострадавшим при дорожно-транспо
public static List<Message> readDocumentsFromFile() {
final List<Message> empty = new ArrayList<>();
final Gson gson = new GsonBuilder().create();
final Type listType = new TypeToken<List<CommonMessage>>() {
}.getType();
final File file = new File("/tmp/kznews.json");
try {
if (file.exists()) {
final FileReader fileReader = new FileReader(file);
final JsonReader reader = new JsonReader(fileReader);
@c0rp-aubakirov
c0rp-aubakirov / Check.java
Created February 9, 2016 11:17
Test what is faster: comparing big decimals or cast to int and compare
@Test
public void testBigDecimal() throws Exception {
final SecureRandom random = new SecureRandom();
for (int j = 0; j < 30; j++) {
Timer.executeFunctionWithTimer(() -> {
int value = 0;
for (int i = 0; i < 1000000; i++) {
value = new BigDecimal(random.nextInt()).intValueExact();
}
return value > 10;