How to use long id in Rails applications?

Credits to http://moeffju.net/blog/using-bigint-columns-in-rails-migrations class CreateDemo < ActiveRecord::Migration def self.up create_table :demo, :id => false do |t| t.integer :id, :limit => 8 end end end See the option :id => false which disables the automatic creation of the id field The t.integer :id, :limit => 8 line will produce a 64 bit integer field

C/C++ use of int or unsigned int

Using unsigned can introduce programming errors that are hard to spot, and it’s usually better to use signed int just to avoid them. One example would be when you decide to iterate backwards rather than forwards and write this: for (unsigned i = 5; i >= 0; i–) { printf(“%d\n”, i); } Another would be … Read more

Convert String to Integer in XSLT 1.0

Adding to jelovirt’s answer, you can use number() to convert the value to a number, then round(), floor(), or ceiling() to get a whole integer. Example <xsl:variable name=”MyValAsText” select=”‘5.14′”/> <xsl:value-of select=”number($MyValAsText) * 2″/> <!– This outputs 10.28 –> <xsl:value-of select=”floor($MyValAsText)”/> <!– outputs 5 –> <xsl:value-of select=”ceiling($MyValAsText)”/> <!– outputs 6 –> <xsl:value-of select=”round($MyValAsText)”/> <!– outputs 5 … Read more

Convert char array to a int number in C

I personally don’t like atoi function. I would suggest sscanf: char myarray[5] = {‘-‘, ‘1’, ‘2’, ‘3’, ‘\0′}; int i; sscanf(myarray, “%d”, &i); It’s very standard, it’s in the stdio.h library 🙂 And in my opinion, it allows you much more freedom than atoi, arbitrary formatting of your number-string, and probably also allows for non-number … Read more

Why is int typically 32 bit on 64 bit compilers?

Bad choices on the part of the implementors? Seriously, according to the standard, “Plain ints have the natural size suggested by the architecture of the execution environment”, which does mean a 64 bit int on a 64 bit machine. One could easily argue that anything else is non-conformant. But in practice, the issues are more … Read more

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