To resize the image proportionally using CSS: img.resize { width:540px; /* you can use % */ height: auto; } Control size and maintain proportion : #your-img { height: auto; width: auto; max-width: 300px; max-height: 300px; } … [Read more...]
What is the difference between “INNER JOIN” and “OUTER JOIN”?
Assuming you're joining on columns with no duplicates, which is a very common case: An inner join of A and B gives the result of A intersect B, i.e. the inner part of a Venn diagram intersection. An outer join of A and B gives the results of A union B, i.e. the outer parts of a Venn diagram union. Examples Suppose you have two tables, with a single column each, and data as … [Read more...]
Why do I get AttributeError: ‘NoneType’ object has no attribute ‘something’?
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None. That usually means that an assignment or function call up above failed or returned an unexpected result. You have a variable that is equal to None and you're attempting to access an attribute of it called 'something'. foo = None foo.something = … [Read more...]
Rotate an image in image source in html
If your rotation angles are fairly uniform, you can use CSS: CSS: .rotate90 { -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); } Otherwise, you can do this by setting a data attribute in your HTML, then using Javascript to add the necessary … [Read more...]
How do I copy folder with files to another folder in Unix/Linux? [closed]
The option you're looking for is -R. cp -R path_to_source path_to_destination/ If destination doesn't exist, it will be created. -R means copy directories recursively. You can also use -r since it's case-insensitive. To copy everything inside the source folder (symlinks, hidden files) without copying the source folder itself use -a flag along with trailing /. in the source … [Read more...]
printf() formatting for hexadecimal
The # part gives you a 0x in the output string. The 0 and the x count against your "8" characters listed in the 08 part. You need to ask for 10 characters if you want it to be the same. int i = 7; printf("%#010xn", i); // gives 0x00000007 printf("0x%08xn", i); // gives 0x00000007 printf("%#08xn", i); // gives 0x000007 Also changing the case of x, affects the casing of the … [Read more...]
Plot two graphs in same plot in R
lines() or points() will add to the existing graph, but will not create a new window. So you'd need to do plot(x,y1,type="l",col="red") lines(x,y2,col="green") You can also use par and plot on the same graph but different axis. Something as follows: plot( x, y1, type="l", col="red" ) par(new=TRUE) plot( x, y2, type="l", col="green" ) If you read in detail about par in R, … [Read more...]
How to convert string to binary?
Something like this? >>> st = "hello world" >>> ' '.join(format(ord(x), 'b') for x in st) '1101000 1100101 1101100 1101100 1101111 100000 1110111 1101111 1110010 1101100 1100100' #using `bytearray` >>> ' '.join(format(x, 'b') for x in bytearray(st, 'utf-8')) '1101000 1100101 1101100 1101100 1101111 100000 1110111 1101111 1110010 1101100 1100100' If by binary you mean bytes … [Read more...]
MIN and MAX in C
Where are MIN and MAX defined in C, if at all? They aren't. What is the best way to implement these, as generically and type safe as possible (compiler extensions/builtins for mainstream compilers preferred). As functions. I wouldn't use macros like #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)), especially if you plan to deploy your code. Either write your own, use something … [Read more...]
ERROR 1452: Cannot add or update a child row: a foreign key constraint fails
Taken from Using FOREIGN KEY Constraints Foreign key relationships involve a parent table that holds the central data values, and a child table with identical values pointing back to its parent. The FOREIGN KEY clause is specified in the child table. It will reject any INSERT or UPDATE operation that attempts to create a foreign key value in a child table if there is … [Read more...]