Posts

ruby on rails 3 - Why is user.save true but email shows as nil? -

I am using a nested model form for sign-up and working through kinks as a start I am A problem that came up specially, although I do not actually find it returning as user.email back to zero . Before I started playing with the nested model form, I can make a record in the console for a problem. Now, though I can not create records and the latest records are made in their email as zero (I'm not sure there is nothing with the model in it, but this is my reference point When he starts messing up.) If I go to Rail Console to create a new user / profile, I follow this process: user = user. New user.mail = "" user.password = "" user.profile = profile.new user.profile.first_name = "" ... user.profile.save user.save Everything goes fine up to user.save, which gives me an error named : Undefined local variable or # & lt; User: & gt; For the method 'parameter' in the Rail Console, it pins user.rb: create_profile in 25 ...

debugging - How to use break command in idb(intel compiler debugger) for fortran executable file? -

I am new to idb / gdb debugger, so I apologize for the bad questions in advance. I am trying to set a breakpoint in a function called set_time_i which is using idb in the file named time_manager.f90. However, idb gives me an error message and prevents me from setting the HTE breakpoint. Do I know I have done something wrong? I tried all these commands: 1) (idb) break time_manager.F90: set_time_i 2) (idb) break time_manager: set_time_i 3 (Idb) break_set_time_i 4) (idb) break time_manager_: set_time_i _ is an error message "break time_manager: set_time_i ^ Unable to parse the form or the FORTRAN expression. " There is no work above. Do I remember something when I use it? Thanks command, break File: function does not work for FORTRAN (be it GDB or IDB). I usually start the third version of Intel Debugger and my congratulations functions in GDB mode. [shell] $ idbc -gdb a.out # command-line, breaking gdb mode (idb) set_time_i

recursion - Abstracting a loop -

I sometimes feel like writing a loop within my work (recursive work) it creates weird codes like this Is: value = REC loop one = if ... then another loop AB loop a I know I go can move the loop out of the binding, but it is the only objective to calculate tied value. So I thought I could summarize the loop in a different function: let's go f = a rq a = a = match with f a. Some B - & gt; Aux B None - & gt; One aux a I could then: value = one |> Maybe it's better - at least this function is more than definition As an assignment I & lt; These are my questions: Is there a recursive function in Is there any compulsion for any code odor? Is there a better way of refactor If not, can my loop function be normalized, or improved in some way? No I think what you are doing, I got it Is okay Here's how I do it: REC loop guard step init = if guard init then init else loop guard step step init) Assume = a | & Gt; Loop (f...

objective c - How to append the bytes of a bit-field to NSMutableData -

मेरे पास एक स्ट्रक्चर typedef struct {int8_t foo: 1; } बार; मैंने बाइट्स को एक NSMutableData ऑब्जेक्ट के समान जोड़ने की कोशिश की है: NSMutableData * data = [[NSMutableData alloc] init]; बार अस्थायी; Temp.foo = 1; [डेटा संलग्नक: & amp; temp.foo लंबाई: sizeof (int8_t)]; लेकिन मुझे बिट-फील्ड का पता करने का एक त्रुटि प्राप्त हुई। मैं बाइट को कैसे जोड़ सकता हूं? बाइट को इंगित करें, आवश्यक बिट को मुखौटा दें, और चर संलग्न करें एक बाइट के रूप में: टाइपिंगफ़ाइल संरचना {int8_t foo: 1; } बार; NSMutableData * डेटा = [[NSMutableData alloc] init]; बार अस्थायी; Temp.foo = 1; Int8_t * p = (int8_t *) (और अस्थायी + 0); // बाइट को शिफ्ट करें आपको int8_t pureByte = * p & amp; 0x01; // मास्क को आप की ज़रूरत होती है [डेटा एपेंडबिट्स: & amp; शुद्धबैटे लंबाई: आकारफ (int8_t)];

PHP mysql - Creating next and previous link (error with my solution) -

This is the sequel to another question I asked: Let me address this solution next and previous. Now I need to transform it into some useful PHP code. Then there is a Heres solution: Select the CD from the database WHERE (id = (SELECT MAX (id) database from WHERE id & lt; c.id and language = ' N ') or id = (select WHERE id from the MIN (id) database> c.id and language =' n ')) I will put a next and previous link from this How to make What I tried: $ result = mysql_query ("Select ID from database id ASER WHERE (ID = (Select MAX ID) from the database WHERE ID & Lt; c.id and language = 'n') or id = (select WHERE id from the MIN (id) database> c.id and language = 'n')) "); While ($ line = mysql_fetch_array ($ result)) {$ nextlink = "& lt; a href = 'http: //www.domain.com/". $ Line ['c.id']. ".html '& gt; Next & lt; / a & gt;"; Echo $ nextlink; } It does not show ...

Unsigned Bytes in Java -

Bytes in Java are signed by default. I look at other posts, which is a sort of workaround for an unsigned byte: int num = (int) cutting & amp; 0xFF Would anyone explain to me why this works and changes a signed byte to an unsigned byte and its associated integer? ANDing Results in the same byte with a byte 11111111 - correct? A. Typecast has a higher priority than the and operator For the first time, casting an int, and then ending all the high-order bits set up to make a mask, which includes the two-digit "sign bit" of Java usage, in which you can only use the positive value Is left with the original byte example: let's by x = 11111111 = -1 again (int) x = 1111111111111111111111111 1111111 and X & amp; 0xFF = 00000000 00000000 0000000011111111 = 255 And you have effectively removed the signature from the original byte.

Functions vs Scripts - Unix Bash Programming -

I am quite new about programming (one year with java) and about a very new session (about six weeks). I wrote a small application that does some things, and it is entirely the idea of ​​scripts not a function. I know that I can have a file with all the functions but why and / or when. For example, I have a script called getID, which calls the "validateID" script to ensure that the ID is valid 3 numbers pre 827 395 148), then for a specific ID, a " ID "and if the ID is valid and found, then it returns the correct. Then I have another script which is called getID2 which validates the ID and returns the correct ID if it is not found. I've got getopt command recently where i can getID -f say true if to get back and getID -n return to true if not got or i get a function getid write (I can get 0) and if I get, then gives 1. I am currently trying to write applications with better logic. I will accept any advice for any part of the program, but I would really li...