Search Results

Search found 324 results on 13 pages for 'joseph reeves'.

Page 11/13 | < Previous Page | 7 8 9 10 11 12 13  | Next Page >

  • rails, activerecord callbacks not saving

    - by Joseph Silvashy
    I have a model with a callback that runs after_update: after_update :set_state protected def set_state if self.valid? self.state = 'complete' else self.state = 'in_progress' end end But it doesn't actually save those values, why not? Regardless of if the model is valid or not it won't even write anything, even if i remove the if self.valid? condition, I can't seem to save the state. Um, this might sound dumb, do I need to run save on it?

    Read the article

  • No transperancy in Bitmap loading from MemoryStream

    - by Jogi Joseph George
    Please see the C# code. When i am writing a Bitmap to a file and read from the file, i am getting the transperancy correctly. using (Bitmap bmp = new Bitmap(2, 2)) { Color col = Color.FromArgb(1, 2, 3, 4); bmp.SetPixel(0, 0, col); bmp.Save("J.bmp"); } using (Bitmap bmp = new Bitmap("J.bmp")) { Color col = bmp.GetPixel(0, 0); // ------------------------------ // Here col.A is 1. This is right. // ------------------------------ } But if I write the Bitmap to a MemoryStream and read from that MemoryStream, the transperancy has been removed. All Alpha values become 255. MemoryStream ms = new MemoryStream(); using (Bitmap bmp = new Bitmap(2, 2)) { Color col = Color.FromArgb(1, 2, 3, 4); bmp.SetPixel(0, 0, col); bmp.Save(ms, ImageFormat.Bmp); } using (Bitmap bmp = new Bitmap(ms)) { Color col = bmp.GetPixel(0, 0); // ------------------------------ // But here col.A is 255. Why? i am expecting 1 here. // ------------------------------ } I wish to save the Bitmap to a MemoryStream and read it back with transperancy. Could you please help me?

    Read the article

  • how to put jcheckbox to table cell?

    - by joseph
    Hello, I cannot put jChceckBox to jTable cell. More likely I can put checkBox to table, but when I run module with that table, the cell where should be checkBox shows text "true" or "false". The behaviors of that cell are the same like checkbox, but it shows text value instead of checkbox. Here is the code. DefaultTableModel dm = new DefaultTableModel(); dm.setDataVector(new Object[][]{{"dd", "Edit", "Delete"}, {"dd","Edit", "Delete"}}, new Object[]{"Include","Component", "Ekvi"}); jTable1 = new javax.swing.JTable(); jTable1.setModel(dm); JCheckBox chBox=new JCheckBox(); jTable1.getColumn("Include").setCellEditor(new DefaultCellEditor(chBox)); jScrollPane1.setViewportView(jTable1);

    Read the article

  • How to make "Open File..." window in netbeans PLATFORM?

    - by joseph
    Hello, I need to create something like internal frame in netbeans platform, which loads file from any location. I tried it by jInternalFrame, but I was not able to find some container to which I can add my frame. I am working in netbeans platform, which has own pre-created main window. Pease help me by any advice, I am dealing with this about 10 hours, still without result.

    Read the article

  • Drupal : Custom views filter

    - by Joseph
    Hi, First thing I would say is that I am a Drupal newbie. So, I would appreciate your answer in a detailed step by step process. I am using Drupal 6 and location module. There are two main content types - user profile (using content profile module) and event content type. Both have one field for location. Now, lets suppose in his profile, user is selecting city as Toronto and province as Ontario. And some events have been added for Toronto city. I need one Views, which will display events from user city. So, if user is from Vancouver, and they click on "my city events", they will see list of events from their city. Someone told me that I can achieve this using arguments/ relationships, but I don't know how to do that. Can someone please help me out? I am not good at PHP either :(

    Read the article

  • Polymorphic associations in CakePHP2

    - by Joseph
    I have 3 models, Page , Course and Content Page and Course contain meta data and Content contains HTML content. Page and Course both hasMany Content Content belongsTo Page and Course To avoid having page_id and course_id fields in Content (because I want this to scale to more than just 2 models) I am looking at using Polymorphic Associations. I started by using the Polymorphic Behavior in the Bakery but it is generating waaay too many SQL queries for my liking and it's also throwing an "Illegal Offset" error which I don't know how to fix (it was written in 2008 and nobody seems to have referred to it recently so perhaps the error is due to it not having been designed for Cake 2?) Anyway, I've found that I can almost do everything I need by hardcoding the associations in the models as such: Page Model CREATE TABLE `pages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created` datetime NOT NULL, `updated` datetime NOT NULL, PRIMARY KEY (`id`) ) <?php class Page extends AppModel { var $name = 'Page'; var $hasMany = array( 'Content' => array( 'className' => 'Content', 'foreignKey' => 'foreign_id', 'conditions' => array('Content.class' => 'Page'), ) ); } ?> Course Model CREATE TABLE `courses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `created` datetime NOT NULL, `updated` datetime NOT NULL, PRIMARY KEY (`id`) ) <?php class Course extends AppModel { var $name = 'Course'; var $hasMany = array( 'Content' => array( 'className' => 'Content', 'foreignKey' => 'foreign_id', 'conditions' => array('Content.class' => 'Course'), ) ); } ?> Content model CREATE TABLE IF NOT EXISTS `contents` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `class` varchar(30) COLLATE utf8_unicode_ci NOT NULL, `foreign_id` int(11) unsigned NOT NULL, `title` varchar(100) COLLATE utf8_unicode_ci NOT NULL, `content` text COLLATE utf8_unicode_ci NOT NULL, `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) <?php class Content extends AppModel { var $name = 'Content'; var $belongsTo = array( 'Page' => array( 'foreignKey' => 'foreign_id', 'conditions' => array('Content.class' => 'Page') ), 'Course' => array( 'foreignKey' => 'foreign_id', 'conditions' => array('Content.class' => 'Course') ) ); } ?> The good thing is that $this->Content->find('first') only generates a single SQL query instead of 3 (as was the case with the Polymorphic Behavior) but the problem is that the dataset returned includes both of the belongsTo models, whereas it should only really return the one that exists. Here's how the returned data looks: array( 'Content' => array( 'id' => '1', 'class' => 'Course', 'foreign_id' => '1', 'title' => 'something about this course', 'content' => 'The content here', 'created' => null, 'modified' => null ), 'Page' => array( 'id' => null, 'title' => null, 'slug' => null, 'created' => null, 'updated' => null ), 'Course' => array( 'id' => '1', 'title' => 'Course name', 'slug' => 'name-of-the-course', 'created' => '2012-10-11 00:00:00', 'updated' => '2012-10-11 00:00:00' ) ) I only want it to return one of either Page or Course depending on which one is specified in Content.class UPDATE: Combining the Page and Course models would seem like the obvious solution to this problem but the schemas I have shown above are just shown for the purpose of this question. The actual schemas are actually very different in terms of their fields and the each have a different number of associations with other models too. UPDATE 2 Here is the query that results from running $this->Content->find('first'); : SELECT `Content`.`id`, `Content`.`class`, `Content`.`foreign_id`, `Content`.`title`, `Content`.`slug`, `Content`.`content`, `Content`.`created`, `Content`.`modified`, `Page`.`id`, `Page`.`title`, `Page`.`slug`, `Page`.`created`, `Page`.`updated`, `Course`.`id`, `Course`.`title`, `Course`.`slug`, `Course`.`created`, `Course`.`updated` FROM `cakedb`.`contents` AS `Content` LEFT JOIN `cakedb`.`pages` AS `Page` ON (`Content`.`foreign_id` = `Page`.`id` AND `Content`.`class` = 'Page') LEFT JOIN `cakedb`.`courses` AS `Course` ON (`Content`.`foreign_id` = `Course`.`id` AND `Content`.`class` = 'Course') WHERE 1 = 1 LIMIT 1

    Read the article

  • Difficulty determining the file type of text database file

    - by Joseph Silvashy
    So the USDA has some weird database of general nutrition facts about food, and well naturally we're going to steal it for use in our app. But anyhow the format of the lines is like the following: ~01001~^~0100~^~Butter, salted~^~BUTTER,WITH SALT~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87 ~01002~^~0100~^~Butter, whipped, with salt~^~BUTTER,WHIPPED,WITH SALT~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87 ~01003~^~0100~^~Butter oil, anhydrous~^~BUTTER OIL,ANHYDROUS~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87 ~01004~^~0100~^~Cheese, blue~^~CHEESE,BLUE~^~~^~~^~Y~^~~^0^~~^6.38^4.27^8.79^3.87 With those odd ~ and ^ separating the values, It also lacks a header row but thats ok, I can figure that out from the other stuff on their site: http://www.ars.usda.gov/Services/docs.htm?docid=8964 Any help would be great! If it matters we're making an open/free API with Ruby to query this data. Additionally I'm having a tough time posing this question so I've made it a community wiki so we can all pitch in!

    Read the article

  • Bypassing Browser popup blocking when automatic session timout occurs

    - by Joseph
    Hi all, Please help regarding the following issue. I have enabled the "Block popup" option in browser. We are doing a session validation using a background ajax call to check the session is active or not. If the session is not active for a desired interval a popup window will come for notification. Now comming to the problem . since the session notification popup is comming automatically without any client interaction, This popup is blocked by the browser. But if a client clicks anyother popup window in the form that popup window will not be blocked by the browser.

    Read the article

  • how to write own serializer/deserializer?

    - by joseph
    Hello, I need to save objects - instances of classes - in my app like some filetype. How I can write own serializer/deserializer for it? Or exist some easier way how to save objects to some filetype? Using of io.serialization was commented as not so good solution for "real" app. Why?

    Read the article

  • Can't get values from Sqlite DB using query

    - by Sana Joseph
    I used sqlite to populate a DB with some Tables in it. I made a function at another javascript page that executes the database & selects some values from the table. Javascript: function GetSubjectsFromDB() { tx.executeSql('SELECT * FROM Subjects', [], queryNSuccess, errorCB); } function queryNSuccess(tx, results) { alert("Query Success"); console.log("Returned rows = " + results.rows.length); if (!results.rowsAffected) { console.log('No rows affected!'); return false; } console.log("Last inserted row ID = " + results.insertId); } function errorCB(err) { alert("Error processing SQL: "+err.code); } Is there some problem with this line ? tx.executeSql('SELECT * FROM Subjects', [], queryNSuccess, errorCB); The queryNSuccess isn't called, neither is the errorCB so I don't know what's wrong.

    Read the article

  • Automatic upload of 10KB file to web service?

    - by Joseph Turian
    I am writing an application, similar to Seti@Home, that allows users to run processing on their home machine, and then upload the result to the central server. However, the final result is maybe a 10K binary file. (Processing to achieve this output is several hours.) What is the simplest reliable automatic method to upload this file to the central server? What do I need to do server-side to prevent blocking? Perhaps having the client send mail is simple and reliable? NB the client program is currently written in Python, if that matters.

    Read the article

  • Nested Resource testing RSpec

    - by Joseph DelCioppio
    I have two models: class Solution < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => :user_id end class User < ActiveRecord::Base has_many :solutions end with the following routing: map.resources :users, :has_many => :solutions and here is the SolutionsController: class SolutionsController < ApplicationController before_filter :load_user def index @solutions = @user.solutions end private def load_user @user = User.find(params[:user_id]) unless params[:user_id].nil? end end Can anybody help me with writing a test for the index action? So far I have tried the following but it doesn't work: describe SolutionsController do before(:each) do @user = Factory.create(:user) @solutions = 7.times{Factory.build(:solution, :owner => @user)} @user.stub!(:solutions).and_return(@solutions) end it "should find all of the solutions owned by a user" do @user.should_receive(:solutions) get :index, :user_id => @user.id end end And I get the following error: Spec::Mocks::MockExpectationError in 'SolutionsController GET index, when the user owns the software he is viewing should find all of the solutions owned by a user' #<User:0x000000041c53e0> expected :solutions with (any args) once, but received it 0 times Thanks in advance for all the help. Joe

    Read the article

  • Rails, destroy if blank

    - by Joseph Silvashy
    This might sound odd, but is there a 'Rails way' to have a model destroyed if a certain attribute is blank? Say I have a model like tags with just a name attribute or something, if the user edits the tag and deletes all the text out of the name field in the form I'd like the model to just be deleted. I'm aware of the reject_if method, but that doesn't seem to work.

    Read the article

  • Algorithm for Determining Variations of Differing Lengths

    - by joseph.ferris
    I have four objects - for the sake of arguments, let say that they are the following letters: A B C D I need to calculate the number of variations that can be made for these under the following two conditions: No repetition Objects are position agnostic Taking the above, this means that with a four object sequence, I can have only one sequence that matches the criteria (since order is not considered for being unique): ABCD There are four variations for a three object combination from the four object pool: ABC, ABD, ACD, and BCD There are six variations for a two object combination from the four object pool: AB, AC, AD, BC, BD, and CD And the most simple one, if taken on at a time: A, B, C, and D I swear that this was something covered in school, many, many years ago - and probably forgotten since I didn't think I would use it. :-) I am anticipating that factorials will come into play, but just trying to force an equation is not working. Any advice would be appreciated.

    Read the article

  • Parse (extract) DTMF in Python

    - by Joseph
    If I have a recorded audio file (MP3), is there any way to get the figure out the DTMF tones that were recorded in pure Python? (If pure python is not available, then Java is okay too. The point being that it should be able to run in Google Appengine)

    Read the article

  • JNI: dll function works ok in C++ main, but not with dll wrapper

    - by Joseph Lim
    I have an a.dll (not modifiable as i do not have the source) with a function bool openPort(DWORD mem).I wrote a c++ main, loaded this dll using LoadLibrary, and the function works well.It returns true. Now, I need to call this function from Java via JNI. I wrote another b.dll with a function like so JNIEXPORT void JNICALL Java_MyClass_openPortFunc (JNIEnv *env, jobject obj, jint pMemPhy) { hInstLibrary = LoadLibrary("a.dll"); typedef bool (*openPort)(DWORD); openPort _openPort; _openPort = (openPort)GetProcAddress(hInstLibrary, "openPort"); DWORD memAddr = 0xda000; if(_openPort(memAddr)){ cout << "ok" << endl; }else{ cout << "failed " << endl; } } This however, causes the openPort to return false despite using the same parameters. I hope someone can advise me. Thank you. :)

    Read the article

  • Magento - Data is not inserted into database, but the id is autoincremented

    - by Joseph
    I am working on a new payment module for Magento and have come across an issue that I cannot explain. The following code that runs after the credit card is verified: $table_prefix = Mage::getConfig()->getTablePrefix(); $tableName = $table_prefix.'authorizecim_magento_id_link'; $resource = Mage::getSingleton('core/resource'); $writeconnection = $resource->getConnection('core_write'); $acPI = $this->_an_customerProfileId; $acAI = $this->_an_customerAddressId; $acPPI = $this->_an_customerPaymentProfileId; $sql = "insert into {$tableName} values ('', '$customerId', '$acPI', '$acPI', '3')"; $writeconnection->query($sql); $sql = "insert into {$tableName} (magCID, anCID, anOID, anObjectType) values ('$customerId', '$acPI', '$acAI', '2')"; $writeconnection->query($sql); $sql = "insert into {$tableName} (magCID, anCID, anOID, anObjectType) values ('$customerId', '$acPI', '$acPPI', '1')"; $writeconnection->query($sql); I have verified using Firebug and FirePHP that the SQL queries are syntactically correct and no errors are returned. The odd thing here is that I have checked the database, and the autoincrement value is incremented on every run of the code. However, no rows are inserted in the database. I have verified this by adding a die(); statement directly after the first write. Any ideas why this would be occuring? The relative portion of the config.xml is this: <config> <global> <models> <authorizecim> <class>CPAP_AuthorizeCim_Model</class> </authorizecim> <authorizecim_mysql4> <class>CPAP_AuthorizeCim_Model_Mysql4</class> <entities> <anlink> <table>authorizecim_magento_id_link</table> </anlink> </entities> <entities> <antypes> <table>authorizecim_magento_types</table> </antypes> </entities> </authorizecim_mysql4> </models> <resources> <authorizecim_setup> <setup> <module>CPAP_AuthorizeCim</module> <class>CPAP_AuthorizeCim_Model_Resource_Mysql4_Setup</class> </setup> <connection> <use>core_setup</use> </connection> </authorizecim_setup> <authorizecim_write> <connection> <use>core_write</use> </connection> </authorizecim_write> <authorizecim_read> <connection> <use>core_read</use> </connection> </authorizecim_read> </resources> </global> </config>

    Read the article

  • Reset selection of wx.lib.calendar.Calendar control?

    - by Joseph
    I have a wx.lib.calendar.Calendar control (not wx.lib.calendar.CalendarCtrl!). I am selecting a number of days using the following function call: self.cal.AddSelect([days], 'green', 'white') This works, and draws the days highlighted. However, I cannot work out how to reverse this (i.e., clear the selection so the days go back to their normal colouring). Any hints, please?

    Read the article

< Previous Page | 7 8 9 10 11 12 13  | Next Page >