Posts

php - Which MySQL datatype to use for an IP address? -

possible duplicate: how store ip in mysql i want ip address $_server['remote_addr'] , other $_server variables, datatype right 1 this? is varchar(n) ? since ipv4 addresses 4 byte long, use int ( unsigned ) has 4 bytes: `ipv4` int unsigned and inet_aton , inet_ntoa convert them: insert `table` (`ipv4`) values (inet_aton("127.0.0.1")); select inet_ntoa(`ipv4`) `table`; for ipv6 addresses use binary instead: `ipv6` binary(16) and use php’s inet_pton , inet_ntop conversion: 'insert `table` (`ipv6`) values ("'.mysqli_real_escape_string(inet_pton('2001:4860:a005::68')).'")' 'select `ipv6` `table`' $ipv6 = inet_pton($row['ipv6']);

code first - EF 4 CTP 5: Trouble trying to remove an entity -

i have created model poco class called recipe ; corresponding reciperepository persists these objects. using code first on top of existing database. every recipe contains icollection<recipecategory> of categories link recipes , categories table in many-to-many relationship. recipecategory contains corresponding 2 foreign keys. a simplified version of controller , repository logic looks (i have commented out checks authorization, null objects etc. simplicity): public actionresult delete(int id) { _reciperepository.remove(id); return view("deleted"); } the repository's remove method nothing following: public void remove(int id) { recipe recipe = _context.recipes.find(id); _context.recipes.remove(recipe); _context.savechanges(); } howevery, code above not work since receive system.invalidoperationexception every time run it: adding relationship entity in deleted state not allowed. what error message stand , how can solve ...

c++ - OpenCV and Eclipse CDT -

i have installed latest versions of opencv , eclipse cdt , not able make opencv used within eclipse cdt. any ideas on how can that? thanks lot. what platform? see http://opencv.willowgarage.com/wiki/eclipseopencvlinux ? otherwise run cmake in top of opencv source dir , select compiler want, eclipse that's possibly mingw (unless there eclipse specific version)

Get tree path in MySQL table -

perhaps easiest approach manage hierarchical data in mysql databases adjacency list model . is, give every node parent: create table category( category_id int auto_increment primary key, name varchar(20) not null, parent int default null); it easy parent node, or if there maximum tree depth, can whole tree using this: select concat_ws('/', `t3`.`name`, `t2`.`name`, `t1`.`name`) `path` category t1 left join category t2 on t2.parent = t1.category_id left join category t3 on t3.parent = t2.category_id left join category t4 on t4.parent = t3.category_id t1.name = 'xxxxx'; that's enough in many cases, how can generalize solution trees deeper 3 nodes? i.e. may have path "electronics/audio/transmiter/fm/motorola". is possible 1 query? here's simple non recursive stored procedure job: drop table if exists employees; create table employees ( emp_id smallint unsigned not null auto_increment primary key, name varchar(255) not null, boss_i...

android - Why doesn't the tabwidget remain modified? -

in android have tabactivity (a) in create single tab called loading activity b. from activity b modify tabwidget tabactivity add more tabs via static reference tabhost in tabactivity a. after start new activity c , press tabwidget has 1 single tab called loading. i've tried in onresume method of activity b recreate tabs doesn't work anymore. does know why , how can fix it? relying on static variables pointing ui components (like tabhost ) can lead produce memory leaks. don't it. instead register broadcastreceiver in tabactivity add new tabs. way, instead of modifying static variable, send broadcast ( context#sendbroadcast(intent) ) tell tab activity want new tab. also, make sure save state of tabactivity , can restore if android os destroys activity reason. recommend using onretainnonconfigurationinstance ... this: private state mstate; public void oncreate(bundle b){ // somewhere in oncreate mstate = (state) getlastnonconfigurationinstanc...

checkbox - Can I use radio buttons/checkboxes in place of textboxes in a Javascript calculator? -

i have javascript calculator in users can enter quantities of products/features, , multiply quantity set price. then, result shows in textbox below. 2 questions are: i can use <select> options , specify value each 1 this: <select name="site_em_4.99" onchange="calculatetotal(this.form)"> <option value=""> - select - </option> <option value="1">yes</option> <option value="0">no</option> </select> however, won't let me same checkboxes/radio buttons. how can that? two : can change script total shows actual text, vs in text field? thanks! p.s. script can found here . instead of having input total switch span (or else) id (let's "total"), , replace innerhtml <script> function calculatetotal(frm) { ... document.getelementbyid('total').innerhtml = round_decimals(order_total, 2); ...

radix sort in c on floating points numbers -

okay have create radix sort both unsigned ints , floating point numbers. unsigned ints version works should, having little trouble getting work floating points values though. sorts values of array whole number value of floating point number doesn't sort based on decimal value. (ex. 36.65234 appear before 36.02311 if comes first in unsorted array) code segment bit manipulations , masking, pretty sure problem is. /* loop create bin */ for(int i=0; i<n; i++){ temp_int = (((unsigned int)(list[i]))>>bitwise)&0xff; bin[temp_int] = bin[temp_int]+1; } /*for loop map */ (int i=0; i<256; i++) { map[i+1] = bin[i]+count; count = map[i+1]; } /* loop copy "sorted" values other array */ (int i=0; i<n; i++) { temp_int = (((unsigned int)(list[i]))>>bitwise)&0xff; int buf_loc = map[temp_int]; temp_arr[buf_loc] = list[i]; map[temp_int] = map[temp_int]+1; } thanks in advance! radix sort linear sort...