[HBase] Filters not working for negative integers

[stackoverflow] HBase: Filters not working for negative integers

Easility say:
Since, Hbase has only BinaryComparators and not other ‘typed’ comparators, it fails to filter on Negative integers as it stores the 2’s compliment of the negative number. Further, the binary representation of a negative 2’s Complement Integer would be lexicographically after the largest positive number and that’s why it was not working.

The workaround is to change the signed bit of the number. Things are working fine after that. Please note that this is required only for integers and not for float types.

Posted in HBase | Leave a comment

[Shelll Script] check tomcat status

!/bin/bash

tomcat7=$(ps -ef | grep tomcat | wc -l)

echo ${#tomcat7}

if [ ${#tomcat7} -gt 0 ]; then
printf "tomcat is running\n"
else
printf "tomcat is not running\n"
fi

Posted in Linux, Shell Script, Tomcat | Leave a comment

[HBase] get the scan result without specific cq


scan 'TableName', FILTER=>"QualifierFilter(!=,'binary:QUALIFY2')"

Posted in HBase | Leave a comment

[JavaScript] cannot call methods on [Object] prior to initialization; attempted to call method ‘refresh’

try to force initialize the object first.

stackOverflow: selectmenu (‘refresh’, true)

Posted in JavaScript | Leave a comment

[Linux] more than one commands after the pipe

Source: How to merge and pipe results from two different commands to single command?

bash test.sh || { curl -X POST 'https://testurl' -d '{ "data": { "type": "type", "content": "測試" } }'; exit 1; }

Posted in Linux | Leave a comment

[Linux] use tee to write log

Source: stackoverflow: How do I write stderr to a file while using “tee” with a pipe?

sh test.sh 2>&1 | tee "test.log"

Posted in Linux | Leave a comment

[Git] remove local git tags that are not in remote

git fetch --prune origin "+refs/tags/:refs/tags/"

source: stockoverflow: Remove local tags that are no longer on the remote repository

Posted in Git | Leave a comment

[Windows Bash Script] convert csv to html table

source: How to find and replace a string in text file using batch file

just replace “,” with html table tag.

@echo off
setlocal enabledelayedexpansion
set txtfile=%~1
set newfile=Output.html
if exist "%newfile%" del /f /q "%newfile%"
echo ^<table border='1'^> >> %newfile%
for /f "tokens=*" %%a in (%txtfile%) do (
   set newline=%%a
   set newline=^<tr^>^<td^>!newline:,=^</td^>^<td^>!^</td^>^</tr^>
   echo !newline! >> %newfile%
)
echo ^</table^> >> %newfile%
Posted in Windows Bash Script | 1 Comment

Getting around Active Directory search size limit via ldapsearch


ldapsearch -E pr=500/noprompt -v -x -LLL -h host:port -D account -w password -b "DC=base,DC=dn" -s sub "(objectClass=user)"

-E pr=500/noprompt : 500 results per page, no prompt
-E pr=1000/prompt : 1000 results per page, show prompt

Source: Getting around Active Directory search size limit via ldapsearch

Posted in LDAP, Linux | Leave a comment

[Java] Convert Hex to String

<code>
public static byte[] hexStringToByteArray(String s) {
    int len = s.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i &lt; len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) &lt;&lt; 4)
          + Character.digit(s.charAt(i+1), 16));
    }
    return data;
}
</code>

stackoverflow: Convert a string representation of a hex dump to a byte array using Java?

Posted in Java | Leave a comment