This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double getShannonEntropy_Image(BufferedImage actualImage){ | |
List<String> values= new ArrayList<String>(); | |
int n = 0; | |
Map<Integer, Integer> occ = new HashMap<>(); | |
for(int i=0;i<actualImage.getHeight();i++){ | |
for(int j=0;j<actualImage.getWidth();j++){ | |
int pixel = actualImage.getRGB(j, i); | |
int alpha = (pixel >> 24) & 0xff; | |
int red = (pixel >> 16) & 0xff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Available context bindings: | |
* COLUMNS List<DataColumn> | |
* ROWS Iterable<DataRow> | |
* OUT { append() } | |
* FORMATTER { format(row, col); formatValue(Object, col) } | |
* TRANSPOSED Boolean | |
* plus ALL_COLUMNS, TABLE, DIALECT | |
* | |
* where: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET QSQL_CACHE_CSV="/qfs/tmp/user/xshi/domain.txt"; | |
SELECT bidrequestadsize, bidurl, cache_map_get(key) into workdir.url_all_size from adtrain.last_2_days WHERE label = 'Impression.QC' AND bidurl LIKE 'http%' and getDomain(bidurl) not LIKE '%mail%' | |
and CHAR_LENGTH(bidurl) < 1000 and | |
bidurl like cache_map_keyset(); | |
SELECT | |
bidrequestadsize, | |
bidurl, | |
count(1) cnt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
f=open('/Users/xshi/Downloads/domain.txt') | |
s=[l.strip() for l in f.readlines()] | |
f.close() | |
conn = psycopg2.connect("dbname='creativeapp' user='creativeapp' host='creative-db-staging.advertise.quantcast.com' password='creativeapp'") | |
cur = conn.cursor() | |
def domain_exists(domain): | |
cur.execute("SELECT id FROM cpat.domain WHERE domain = %s", (domain,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from xml.dom.minidom import parse,Document | |
import sys | |
import codecs | |
def escape_xml(file, lang_tag): | |
xml = parse(file) | |
doc = Document() | |
elements=xml.getElementsByTagName(lang_tag) | |
print len(elements) | |
beg_tag = "<%s>"%lang_tag |