Android: combining text & image on a Button or ImageButton

For users who just want to put Background, Icon-Image and Text in one Button from different files: Set on a Button background, drawableTop/Bottom/Rigth/Left and padding attributes. <Button android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@drawable/home_btn_test” android:drawableTop=”@drawable/home_icon_test” android:textColor=”#FFFFFF” android:id=”@+id/ButtonTest” android:paddingTop=”32sp” android:drawablePadding=”-15sp” android:text=”this is text”></Button> For more sophisticated arrangement you also can use RelativeLayout (or any other layout) and make it clickable. … Read more

How to wrap text in LaTeX tables?

Use p{width} for your column specifiers instead of l/r/c. \begin{tabular}{|p{1cm}|p{3cm}|} This text will be wrapped & Some more text \\ \end{tabular} EDIT: (based on the comments) \begin{table}[ht] \centering \begin{tabular}{p{0.35\linewidth} | p{0.6\linewidth}} Column 1 & Column2 \\ \hline This text will be wrapped & Some more text \\ Some text here & This text maybe wrapped … Read more

How to remove spaces from a string using JavaScript?

This? str = str.replace(/\s/g, ”); Example var str=”/var/www/site/Brand new document.docx”; document.write( str.replace(/\s/g, ”) ); Update: Based on this question, this: str = str.replace(/\s+/g, ”); is a better solution. It produces the same result, but it does it faster. The Regex \s is the regex for “whitespace”, and g is the “global” flag, meaning match ALL … Read more

Limit text length to n lines using CSS

There’s a way to do it using unofficial line-clamp syntax, and starting with Firefox 68 it works in all major browsers. body { margin: 20px; } .text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; /* number of lines to show */ line-clamp: 2; -webkit-box-orient: vertical; } <div class=”text”> Lorem ipsum dolor sit amet, … Read more

Print string to text file

It is strongly advised to use a context manager. As an advantage, it is made sure the file is always closed, no matter what: with open(“Output.txt”, “w”) as text_file: text_file.write(“Purchase Amount: %s” % TotalAmount) This is the explicit version (but always remember, the context manager version from above should be preferred): text_file = open(“Output.txt”, “w”) … Read more

Difference between text and varchar (character varying)

There is no difference, under the hood it’s all varlena (variable length array). Check this article from Depesz: http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/ A couple of highlights: To sum it all up: char(n) – takes too much space when dealing with values shorter than n (pads them to n), and can lead to subtle errors because of adding trailing … Read more

MySQL: Large VARCHAR vs. TEXT?

TEXT and BLOB may by stored off the table with the table just having a pointer to the location of the actual storage. Where it is stored depends on lots of things like data size, columns size, row_format, and MySQL version. VARCHAR is stored inline with the table. VARCHAR is faster when the size is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)