Search Results

Search found 11178 results on 448 pages for 'syntax checking'.

Page 46/448 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • HABTM checking for match of latest 3

    - by user333614
    Here's an interesting one for you folks... I have a HABTM (has_and_belongs_to_many) relationship between "Dogs" and "Trips". My goal is to find two result sets: 1) Dogs that have been on at least 1 of the last 3 trips and call that @dogs_current 2) Dogs that have NOT been on any of the last 3 trips and call that @dogs_old I found that I can find what the last 3 trips are by doing this in the Trip model: named_scope :last3, :order => 'date DESC', :limit => 3 But not sure how to use that list get 1 and 2. This hack works, but it seems ugly. There must be a better way! :) @dogs_current = [] @dogs_old = [] @dogs.each do |dog| if (Trip.last3 - dog.trips).size < 3 then @dogs_current << dog else @dogs_old << dog end end Any ideas? Thanks! -Cam

    Read the article

  • Checking if mysql user exists

    - by sergiogx
    How can I check if a user exists? Im doing an installer for a mysql database, and I need to check if a user exits, if not create user, if yes delete user and create it again. this so i can execute the script without worries. thanks.

    Read the article

  • Checking sqlite datetime NULL with RoR

    - by Paul N
    RoR/SQL newbie here. My datetime column 'deleted_at' are all uninitialized. Running this query returns an error: SELECT * FROM variants v ON v.id = ovv0.variant_id INNER JOIN option_values_variants ovv1 ON v.id = ovv1.variant_id INNER JOIN option_values_variants ovv2 ON v.id = ovv2.variant_id INNER JOIN option_values_variants ovv3 ON v.id = ovv3.variant_id INNER JOIN option_values_variants ovv4 ON v.id = ovv4.variant_id WHERE v.deleted_at = NULL AND v.product_id = 1060500595 However, if I set my datetime values to 0, and set my query to v.deleted_at = 0, the correct variant is returned to me. How do I check for uninitialized/NULL datetimes?

    Read the article

  • Best Approach for Checking and Inserting Records

    - by nevets1219
    In one of our existing C programs which purpose is: Open connection to DB for record in all_record: if record contain certain data: if record is NOT in table A: // see #1 insert record information into table A and B // see #2 Close connection to DB select field from table where field=XXX 2 inserts This is typically done every X months to sync everything up or so I'm told. I've also been told that this process takes roughly a couple of days. There is (currently) at most 2.5million records (though not necessarily all 2.5m will be inserted). One of the table contains 10 fields and the other 5 fields. There isn't much to be done about iterating through the records since that part can't be changed at the moment. What I would like to do is speed up the part where I query MySQL. I'm not sure if I have left out any important details -- please let me know! I'm also no SQL expert so feel free to point out the obvious. I thought about: Putting all the inserts into a transaction (at the moment I'm not sure how important it is for the transaction to be all-or-none or if this affects performance) Using Insert X Where Not Exists Y LOAD DATA INFILE (but that would require I create a (possibly) large temp file) I read that (hopefully someone can confirm) I should drop indexes so they aren't re-calculated. mysql Ver 14.7 Distrib 4.1.22, for sun-solaris2.10 (sparc) using readline 4.3

    Read the article

  • XSLT Type Checking

    - by mo
    Hi Folks Is it possible to check an elements ComplexType? i have this (simplified): complexType Record complexType Customer extension of Record complexType Person extension of Record <xsl:template match="/"> <records> <xsl:apply-templates /> </records> </xsl:template> <xsl:template match="!!! TYPECHECK FOR RECORD !!!" name="Record"> <record><xsl:value-of select="." /></record> </xsl:template> is it possible to check elementstype incl. inheritence? i dont know the elements name only that they are a subtype of Record. schema 1: complexType name="Customer" extension base="Record" element name="customers" element name="customer" type="Customer" schema 2: complexType name="Person" extension base="Record" element name="persons" element name="person" type="Person" schema ?: complexType name="UnknownType" extension base="Record" element name="unknowns" element name="unknown" type="UnknownType" xml 1: <customers> <customer /> <customer /> </customers> xml 2: <persons> <person /> <person /> </persons> xml ?: <?s> <? /> <? /> </?s> the xml input ist custom so i have to match by the type (i think)

    Read the article

  • checking the return code using python (MAC)

    - by cyberbemon
    I have written a script that checks if an SVN Repo is up and running, the result is based on the return value. import subprocess url = " validurl" def check_svn_status(): subprocess.call(['svn info'+url],shell=True) def get_status(): subprocess.call('echo $?',shell=True) def main(): check_svn_status() get_status() if __name__ == '__main__': main() The problem I'm facing is that if I change the url to something that does't exist I still get the return value as 0, but if I were to run this outside the script, i.e go to the terminal type svn info wrong url and then do a echo $? I get a return value of 1. But I can't re-create this in the python. Any guidelines ?

    Read the article

  • Problems with this code?

    - by J4C3N-14
    I'm trying to use this code which is an example taken from here https://gist.github.com/2383248 , but it is coming up with a error on the public void onClick which is Multiple markers at this line - implements android.view.View.OnClickListener.onClick - Syntax error, insert "}" to complete MethodBody, but when I add the brace it just throws another error after many tries and fails of different suggestions and ideas. It may be a syntax error and bad coding from me (just started learning to program) but does anyone have any ideas how to resolve this or point me in the right direction I would be very grateful. public class ICSCalendarActivity extends Activity implements View.OnClickListener{ Button button1; int year1; int month1; int day1; int ShiftPattern; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1 = (Button)findViewById(R.id.openButton); button1.setText("open"); button1.setOnClickListener(this); Bundle extras = getIntent().getExtras(); year1 = extras.getInt("year1"); day1 = extras.getInt("day1"); month1 = extras.getInt("month1"); ShiftPattern = extras.getInt("ShiftPattern"); } public void onClick(View v){ private static void addToCalendar(Context ICSCalendarActivity, final String title, final long dtstart, final long dtend) { final ContentResolver cr = ICSCalendarActivity.getContentResolver(); Cursor cursor ; if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) cursor = cr.query(Uri.parse("content://com.android.calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null); else cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null); if ( cursor.moveToFirst() ) { final String[] calNames = new String[cursor.getCount()]; final int[] calIds = new int[cursor.getCount()]; for (int i = 0; i < calNames.length; i++) { calIds[i] = cursor.getInt(0); calNames[i] = cursor.getString(1); cursor.moveToNext(); } AlertDialog.Builder builder = new AlertDialog.Builder(ICSCalendarActivity); builder.setSingleChoiceItems(calNames, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues cv = new ContentValues(); cv.put("calendar_id", calIds[which]); cv.put("title", title); cv.put("dtstart", dtstart ); cv.put("hasAlarm", 1); cv.put("dtend", dtend); Uri newEvent ; if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) newEvent = cr.insert(Uri.parse("content://com.android.calendar/events"), cv); else newEvent = cr.insert(Uri.parse("content://calendar/events"), cv); if (newEvent != null) { long id = Long.parseLong( newEvent.getLastPathSegment() ); ContentValues values = new ContentValues(); values.put( "event_id", id ); values.put( "method", 1 ); values.put( "minutes", 15 ); // 15 minutes if (Integer.parseInt(Build.VERSION.SDK) >= 8 ) cr.insert( Uri.parse( "content://com.android.calendar/reminders" ), values ); else cr.insert( Uri.parse( "content://calendar/reminders" ), values ); } dialog.cancel(); } }); builder.create().show(); } cursor.close(); } } Thank you.

    Read the article

  • Disabled Select drop down checking through PHP

    - by user541597
    I have a couple of drop down boxes I access through POST with PHP. When the boxes are disabled and not equal to zero I have the program do something. However when they are disabled I do not want them to do anything. The way I check if the boxes are active is by using an if statement if ($_POST['box'] != "blank"){ //do something } So basically I check if the box is not in the default blank position run the if statement. However when it is disabled I am not sure how to check or what kind of value it returns if any. What can I add to the if statement so it will not go into the loop when the boxes are disabled? I tried: if ($_POST['box'] != "blank" || $_POST['box'] != ""){ //do something } But that did not work. Any ideas?

    Read the article

  • PHP checking if two dates differs at least tree months

    - by user2301515
    In php how to check if one date (given as string) differs to another date at least tree month (unable to find any examples): $date1 = "2013-11-05"; $date2 = "2013-11-19"; //both dates is in form yyyy.mm.dd differsTreeMonths($date1,$date2) { ???? return $differs; } differsTreeMonths("2013-11-05","2014-05-02");//true differsTreeMonths("2014-01-01","2014-04-01");//true differsTreeMonths("2014-01-01","2014-03-31");//false differsTreeMonths("2013-12-01","2014-01-15");//false etc Thank you

    Read the article

  • Checking for an "end of line" in a C-string

    - by Numerator
    I would really love your help with the following problem: I want to get as an input from the user a maximum length of 30 chars string and check whether it contains an end of line. This is what I tried to write so far: int main(void) { int i; char* command = (char*)calloc(31, sizeof(char)); while (0 < 1) { scanf("%s", command); for (i = 0; i <= strlen(command); ++i) { if (command[i] == '\n') printf("here"); } if (strcmp(command, "quit") == 0) break; } The idea is to check whether the command given by the user as input is "legal" - that is of length < 31. when i run this code, it never prints "here" regardless of the length of input.

    Read the article

  • Checking for attachments in JavaScript

    - by Sanjay
    Prior to submitting a form, I would like to check if a file has been attached and pop up a warning message saying that a file needs to be attached if it hasn't been. I was wondering how to accomplish this using JavaScript or Prototype or JQuery etc?

    Read the article

  • Script or Application that will do md5 checking

    - by shanghaiguy
    Is there a program, or a script out there that can compare the md5 checksum of files I tried to create my own, but i'm having problems with any files that have a space in them, so I was wondering if it'd be easier to just use an application. md5deep is something I downloaded that returns the checksum. rm md5mastervalue for i in `ls /media/disk`; do md5deep -rb /media/disk/$i >> md5mastervalue; done for d in 1 3 ; do cp -rf /media/disk/ /media/disk-$d & done wait rm md5valuet1 rm md5valuet3 for k in `ls /media/disk` do for f in 1 3; do md5deep -rb /media/disk-$f/$k >> md5valuet$f; done done for n in 1 3; do diff md5mastervalue md5valuet$n; done echo Finished

    Read the article

  • Checking if a function has C-linkage at compile-time [unsolvable]

    - by scjohnno
    Is there any way to check if a given function is declared with C-linkage (that is, with extern "C") at compile-time? I am developing a plugin system. Each plugin can supply factory functions to the plugin-loading code. However, this has to be done via name (and subsequent use of GetProcAddress or dlsym). This requires that the functions be declared with C-linkage so as to prevent name-mangling. It would be nice to be able to throw a compiler error if the referred-to function is declared with C++-linkage (as opposed to finding out at runtime when a function with that name does not exist). Here's a simplified example of what I mean: extern "C" void my_func() { } void my_other_func() { } // Replace this struct with one that actually works template<typename T> struct is_c_linkage { static const bool value = true; }; template<typename T> void assertCLinkage(T *func) { static_assert(is_c_linkage<T>::value, "Supplied function does not have C-linkage"); } int main() { assertCLinkage(my_func); // Should compile assertCLinkage(my_other_func); // Should NOT compile } Is there a possible implementation of is_c_linkage that would throw a compiler error for the second function, but not the first? I'm not sure that it's possible (though it may exist as a compiler extension, which I'd still like to know of). Thanks.

    Read the article

  • Selecting count(*) while checking for a value in the results

    - by Rob
    SELECT COUNT(*) as Count, IF(sch.HomeTeamID = 34,true,false) AS Hawaii FROM schedule sch JOIN schools s ON s.ID = 83 WHERE (sch.HomeTeamID = 83 OR sch.AwayTeamID = 83) AND sch.SeasonID = 4 I'm trying to use count() to simplify my result but also include a field that represents wether any of the results' specific column contained a certain value. Is this possible? I'd basically like a row response with all the info I need.

    Read the article

  • C++: Checking for non-numeric input and assigning to a double

    - by Brundle
    Here is the code I have at the moment: char ch; int sum = 0; double values[10]; int i = 0; cin >> ch; while (!isalpha(ch)) { values[i] = ch; sum += values[i]; i++; cin >> ch; } What is happening is that if I enter the value 1, that gets assigned to ch as a char. Now ch is assigning it's value to a double and doing an implicit cast. So it is assigning the ASCII value of '1' to values[i]. I want it to just assign 1 to values[i]. Is there a better way to do this? Or is there something that I'm missing?

    Read the article

  • Checking variable from a different class in C#

    - by Josh
    Greetings- I have 2 classes. One is called "Programs" and the other is called "Logs". The class called Programs has public const string m_sEnviron = ""; near the top and I need to check what the m_sEnviron variable is set to through my class called Logs. The variable m_sEnviron will get set from a scheduler called Tidal so how can I check its value from a different class. If this is not the best to do this then please let me know what the better ways are. Thanks in advance. Regards,

    Read the article

  • checking every digit in a number for oddness

    - by tryt
    Hello. I was writing a function which checks if every digit in a number is odd. I came accross this weird behaviour. Why does the second function return different (incorrect) results, eventhough its basically the same? (implemented in an opposite way) #include <stdio.h> int all_odd_1(int n) { if (n == 0) return 0; if (n < 0) n = -n; while (n > 0) { if (n&1 == 1) n /= 10; else return 0; } return 1; } int all_odd_2(int n) { if (n == 0) return 0; if (n < 0) n = -n; while (n > 0) { if (n&1 == 0) return 0; else n /= 10; } return 1; } int main() { printf("all_odd_1\n"); printf("%d\n", all_odd_1(-131)); printf("%d\n", all_odd_1(121)); printf("%d\n", all_odd_1(2242)); printf("-----------------\n"); printf("all_odd_2\n"); printf("%d\n", all_odd_2(131)); printf("%d\n", all_odd_2(121)); printf("%d\n", all_odd_2(2242)); return 0; }

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >