Posts

html - Apply a particular style to an element only if that element is overflowing -

is there way apply particular style element conditionally on overflowing? e.g. if have say: <div> text long, no extremely long; goes on , on , on , on. might it's bit duracell(r) bunny, without batteries, , floppy ears. </div> and div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } // todo: there way apply rule if text overflowing? div { background-color: red; } is there way using pure css have background-color: red rule apply if text overflowing? note: can see way of doing using javascript; want know if there pure css way it.

java - getContentType method returning always 'application/force-download' -

i have url file can download. looks this: http://<server>/recruitment-mantis/plugin.php?page=bugsynchronizer/getfile&fileid=139&filehash=3e7a52a242f90c23539a17f6db094d86 how content type of file? have admin in case simple: url url = new url(stringurl); urlconnection urlconnection = url.openconnection(); urlconnection.connect(); string urlcontent = urlconnection.getcontenttype(); returning me application/force-download content type in every file (no matter jpg or pdf file). want cause want set extension of downloaded file (which can various). how 'get around' of application/force-download content type? in advance help. check urlconnection.getheaderfield("content-disposition") filename. header used attachments in multipart content, doesn't hurt check. if header not present, can save url temporary file, , use probecontenttype meaningful mime type: path tempfile = files.createtempfile(null, null); try (inputs...

Can we call a python method from java? -

this question has answer here: calling python in java? 9 answers i know jython allows call java method java's classfile if written python, reverse possible ??? i have many algorithms written in python, work pretty python , jython lack proper gui. planing bring gui java , keep python library intact. not able write gui jython or python , cannot write algorithm python. solution found merge java's gui , python's library. possible. can call python's library java. yes, can done . done creating pythoninterpreter object , calling python class using . consider following example : java : import org.python.core.pyinstance; import org.python.util.pythoninterpreter; public class interpreterexample { pythoninterpreter interpreter = null; public interpreterexample() { pythoninterpreter.initialize(system.getproper...

iphone - How to attach multiple files in single mail in iOS -

i want send multiple attachment files in single mail in ios programatically. have tried following far: // give file array nsstring *str_mail = [readingemfreading objectatindex:0]; // here can encode file nsdata *mydata = [str_mail datausingencoding:nsutf8stringencoding] //here can attach file extance of .csv [controller addattachmentdata:mydata mimetype:@".cvs" filename:retriveemail] //here can set body mail [controller setmessagebody:@"file" ishtml:no]; //here code sent mail if (controller) [self presentviewcontroller:controller animated:yes completion:nil]; by using code, can send 1 attachment. want send multiple files however. how can achieve this? you add many time addattachmentdata , add muliple file try code :- add line nsstring *str_mail = [readingemfreading objectatindex:0]; // here can encoded file nsdata *mydata = [str_mail datausingencoding:nsutf8stringencoding] nsdata *mydata1 = [str_mail datausingencoding:nsutf8stringen...

python - SQLAlchemy not producing proper SQL statement for multi column UniqueConstraints -

below 2 different attempts have made in trying achieve multi-column unique constraint in sqlalchemy, both of seems have failed since proper sql statement not being produced. the attempts: from sqlalchemy import column, integer, string, text, foreignkey, datetime, create_engine, uniqueconstraint, boolean sqlalchemy.orm import relationship, backref, sessionmaker sqlalchemy.ext.declarative import declarative_base sqlalchemy.interfaces import poollistener import sqlalchemy class foreignkeyslistener(poollistener): def connect(self, dbapi_con, con_record): db_cursor = dbapi_con.execute('pragma foreign_keys=on') engine = create_engine(r"sqlite:///" + r"d:\\foo.db", listeners=[foreignkeyslistener()], echo = true) session = sessionmaker(bind = engine) ses = session() base = declarative_base() print sqlalchemy.__version__ class foo(base): __tablename__ = "foo" id = column(integer, primary_key=true) du...

How to speed up array intersection in Java? -

arrays below sorted without duplicates (contain unique positive integers) of small size (less 5000) , intersection (see below) called billion of times micro-optimization matter. article nicely describes how speed below code in c language. int = 0, j = 0, c = 0, la = a.length, lb = b.length; intersection = new int[math.min(la, lb)]; while (i < la && j < lb) { if (a[i] < b[j]) i++; else if (a[i] > b[j]) j++; else { intersection[c] = a[i]; i++; j++; c++; } } int[] intersectionzip = new int[c]; system.arraycopy(intersection, 0, intersectionzip, 0, c); in java guess impossible call low-level instructions. mention "it possible improve approach using branchless implementation". how 1 it? using switch ? or maybe substitute a[i] < b[j] , a[i] > b[j] or a[i] == b[i] comparisons binary operations on integer operands? binary search approach (with complexity o(la log(lb)) ) not case because la not << lb . inte...

algorithm - METIS serial graph partitioner -

metis graph partitioning algorithm used partitioning large graph. have graph forest. know how metis partitions in case ? well, indeed, metis can partition large graphs doesn't mean can not manage smaller graphs or different types of graphs. forest special type of graph without cycles, can have disconnected parts... as other type of graph, metis going perform 3 level partitioning algorithm: coarsening (in case, have forest graph, may finish because type of graph going have small number of edges or connections) initial partitioning uncoarsening + fine-grained balancing. so basically, going work type of graph. and personal experience, did find out metis didn't give me optimal results when working disconnected graphs (and forest disconnected graph), implemented own logic finding groups of vertices connected , used metis partition group (which connected)... i recommend reading metis metis library documentation .