Wednesday, 15 February 2012

smtp - JavaMail network stutter -



smtp - JavaMail network stutter -

i've been looking @ network chatter between sample javamail send , several mail service servers , have found chatter. code sample can found on net too

package example; import java.util.properties; import javax.mail.message; import javax.mail.messagingexception; import javax.mail.session; import javax.mail.transport; import javax.mail.internet.internetaddress; import javax.mail.internet.mimemessage; public class sender { public static void main(string[] args) { properties props = new properties(); //props.put("mail.smtp.host", "localhost"); // local james props.put("mail.smtp.port", "25"); props.put("mail.smtp.from", "misterunsub@localhost"); props.put("mail.smtp.sendpartial", "false"); props.put("mail.smtp.ehlo", "false"); props.put("mail.debug", "true"); session session = session.getinstance(props,null); seek { message message = new mimemessage(session); //message.setfrom(new internetaddress("misterunsub@localhost")); message.addheader("list-unsubscribe", "<mailto:list-manager@localhost?subject=unsubscribe>"); message.setsubject("fancy mail service unsub"); message.settext("dear mail service crawler," + "\n\nno spam email, please!"); message.savechanges(); internetaddress[] alice = internetaddress.parse("alice@localhost"); transport t = session.gettransport("smtp"); t.connect(); t.sendmessage(message, alice); } grab (messagingexception e) { throw new runtimeexception(e); } } }

i've setup james on localhost receive traffic. (note james uses javamail send/forward mail service too, issue related javamail), james delegates sending javamail. , exhibits problem too. sample above sufficient prove see.

the traffic looks in wireshark

>> helo localhost << 250 localhost hello localhost (127.0.0.1 [127.0.0.1]) >> mail service from:<misterunsub@localhost> << 250 2.1.0 sender <misterunsub@localhost> ok >> rcpt to:<alice@localhost> << 250 2.1.5 recipient <alice@localhost> ok >> rset << 250 2.0.0 ok >> rset << 250 2.0.0 ok >> mail service from:<misterunsub@localhost> << 250 2.1.0 sender <misterunsub@localhost> ok >> rcpt to:<alice@localhost> << 250 2.1.5 recipient <alice@localhost> ok >> info << 354 ok send info ending <crlf>.<crlf> >> info >> . << 250 2.6.0 message recieved >> quit << 221 2.0.0 localhost service closing transmission channel

the oddity of communication first 'mail from:', 'rcpt to:', 'rset' , 'rset' rset rset causes bunch of overhead.

does know how avoid this? can confirm behavior?

update issue appears related vpn usage or loopback/localhost communication on windows. linux doesn't have issue @ all. bill shannon suggests anti-virus or firewall, might that. since anti-virus notice traffic.

thanks bill prompt replies.

javamail should not issuing rset in these cases. version of javamail using? debug output javamail show?

smtp javamail network-protocols

c# - Disabling a dynamic button -



c# - Disabling a dynamic button -

hi have little winforms programme develop more. programme has 2 panels panel1 , panel2 these panels populated dynamically form controls. first panel populated combo-boxes , sec grid of buttons. want accomplish able disable right button depending on user selects combobox. each column of grid represent day of week , combobox used disable wanted day selecting list if like.

to statically straight forward, programme expand can handle big database that's why doing dynamically. i'm stuck @ moment want disable right button.

below interface have far:

and code if help:

public form1() { initializecomponent(); } button[] btn = new button[2]; combobox[] cmb = new combobox[1]; private void form1_load(object sender, eventargs e) { placerows(); } public void createcolumns(int s) { (int = 0; < btn.length; ++i) { btn[i] = new button(); btn[i].setbounds(40 * i, s, 35, 35); btn[i].text = convert.tostring(i); panel1.controls.add(btn[i]); } (int = 0; < cmb.length; ++i) { cmb[i] = new combobox(); cmb[i].selectedindexchanged += new eventhandler(cmb_selectedindexchanged); cmb[i].text = "disable"; cmb[i].items.add("monday"); cmb[i].items.add("tuesday"); cmb[i].setbounds(40 * i, s, 70, 70); panel2.controls.add(cmb[i]); } } void cmb_selectedindexchanged(object sender, eventargs e) { combobox sendercmb = (combobox)sender; if (sendercmb.selectedindex == 1) { //messagebox.show("tuesday"); btn[1].enabled = false; } } public void placerows() { (int = 0; < 80; = + 40) { createcolumns(i); } } }

alternative 1

every command has tag property.

you can set tag property of buttons represent column in.

when selection made in combo box, search through all buttons, , enable or disable button based on whether each button's tag property matches selected text in combo box.

alternative 2

create

dictionary<string, list<button>> buttonmap;

where key value representing column ("tuesday") , value list of buttons tag. when creating buttons initially, populate dictionary.

if go alternative 2, you'll have remember selected value of checkbox can re-enable buttons no longer disabled.

if have lots of buttons, may find alternative 2 noticeably faster.

update

here's finish working sample of alternative 1.

public partial class form1 : form { public form1() { initializecomponent(); } const int rows = 2; const int cols = 2; button[,] btn = new button[rows,cols]; combobox[] cmb = new combobox[rows]; private void form1_load(object sender, eventargs e) { placerows(); } private readonly string[] cbtexts = new string[] { "monday", "tuesday" }; public void createcolumns(int rowindex) { int s = rowindex * 40; // original code kept overwriting btn[i] each column. need 2-d array // indexed row , column (int colindex = 0; colindex < cols; colindex++) { btn[rowindex, colindex] = new button(); btn[rowindex, colindex].setbounds(40 * colindex, s, 35, 35); btn[rowindex, colindex].text = convert.tostring(colindex); btn[rowindex, colindex].tag = cbtexts[colindex]; panel1.controls.add(btn[rowindex, colindex]); } cmb[rowindex] = new combobox(); cmb[rowindex].selectedindexchanged += new eventhandler(cmb_selectedindexchanged); cmb[rowindex].text = "disable"; foreach (string cbtext in cbtexts) { cmb[rowindex].items.add(cbtext); } cmb[rowindex].setbounds(40, s, 70, 70); cmb[rowindex].tag = rowindex; // store row index know buttons impact panel2.controls.add(cmb[rowindex]); } void cmb_selectedindexchanged(object sender, eventargs e) { combobox sendercmb = (combobox)sender; int row = (int)sendercmb.tag; (int col = 0; col < cols; col++) { button b = btn[row, col]; // these 3 lines can combined one. broke out // highlight happening. string text = ((string)b.tag); bool match = text == sendercmb.selecteditem.tostring(); b.enabled = match; } } public void placerows() { (int rowindex = 0; rowindex < 2; rowindex++) { createcolumns(rowindex); } } }

c# arrays winforms

objective c - Only first object of NSMutableArray is stored in NSUserDefaults -



objective c - Only first object of NSMutableArray is stored in NSUserDefaults -

i trying store queue of uilocalnotification solve limit problem. used this approach , archive , unarchive object first one.

how archive objects nsmutablearray?

code // init/unarchive queue if (self.queue == nil) { // seek loading stored array nsuserdefaults *currentdefaults = [nsuserdefaults standarduserdefaults]; nsdata *datarepresentingsavedarray = [currentdefaults objectforkey:@"localnotificationqueue"]; if (datarepresentingsavedarray != nil) { nsarray *oldsavedarray = [nskeyedunarchiver unarchiveobjectwithdata:datarepresentingsavedarray]; if (oldsavedarray != nil) { self.queue = [[nsmutablearray alloc] initwitharray:oldsavedarray]; } else { self.queue = [[nsmutablearray alloc] init]; } } else { self.queue = [[nsmutablearray alloc] init]; } } // add together [self.queue addobject:notif]; // store queue [[nsuserdefaults standarduserdefaults] setobject:[nskeyedarchiver archiveddatawithrootobject:self.queue] forkey:@"localnotificationqueue"];

if add together items 1,2,3. restart , load. have 3.

add 1,2,3. restart , load. have 3, 1, 2.

if matters. phonegap/cordova cdvplugin.

after

[[nsuserdefaults standarduserdefaults] setobject:[nskeyedarchiver archiveddatawithrootobject:self.queue] forkey:@"localnotificationqueue"];

you need phone call

[[nsuserdefaults standarduserdefaults] synchronize]

to save user defaults.

objective-c cordova archive

php - How can i pair images in my DB? -



php - How can i pair images in my DB? -

i had hard time giving question title, hope im clear enough. im using php & html mysql database.

see have fellow member site, every new fellow member gets randomly chosen football game player avatar. football game player avatar assigned folder named 'avatars'. 1 time user registered, avatar moved folder named 'used_avatars'. every image named football game player, because want display name of chosen player on users fellow member page.

here's real question: want add together flag representing players nationality on fellow member site. have several brazilian players , 1 brazilian flag. how pair 5 players 1 flag. thinking of naming images "brazil-ronaldo", "brazil-carlos" , in way in php separating country name , match them flag , avatar. create sense? there improve way of doing this? guess need create new table in database keeps record of flag , avatar match?

hope helps:

you need table players containing field nationality id , table nationalities names flags.

this way can select player , bring together nationality via id.

all have save player id in user "profile".

php html mysql database

ruby - Rails: ActionView::Template::Error - undefined method 'comment' -



ruby - Rails: ActionView::Template::Error - undefined method 'comment' -

i have problem rendering form input data. controller looks this:

class adscontroller < applicationcontroller def new @ad = current_user.ads.build() respond_to |format| format.html { render :layout => 'new' }# new.html.erb format.json { render json: @ad } end end end

in view (the relevant parts):

<%= form_for ([@ad.user, @ad]) |f| %> ... <%= f.label 'description' %></div> <%= f.text_area :comment, cols:35, rows:4 %> ... <% end %>

and model:

class advertisement < activerecord::base attr_accessible :title, :url, :comment, :category_id, :layout, :user_id ... end

when render form, error:

actionview::template::error (undefined method `comment' for

)

it's weird, because on localhost it's working, after uploading app heroku getting error.

where problem?

check migrations:

$ heroku run rake db:migrate:status

confirm you've ran migrations. heroku not automatically run migrations when force new code.

run $ heroku run rake db:migrate run them.

ruby-on-rails ruby heroku

c# - How do I save image URL in database? -



c# - How do I save image URL in database? -

i have tried save image url in sql database path.compain() not work , file name saved in database instead of path. can help me?

if (request.files.count > 0) { httppostedfilebase file3 = request.files[2]; if (request.files.count > 2 && file3.contentlength > 0 && (file3.contenttype.toupper().contains("jpeg") || file3.contenttype.toupper().contains("png") || file3.contenttype.toupper().contains("gif"))) { string filename = path.combine(server.mappath("~/advertimages/cars/mercedes"), path.getfilename(file3.filename)); file1.saveas(filename); modelcar.image3url = filename; } }

you can create new fileinfo object filename

fileinfo fi = new fileinfo(filename);

and utilize fi.fullname();

c# asp.net iis

javascript - when is triggered AJAX success? -



javascript - when is triggered AJAX success? -

i want load html document ajax, want show when images in document loded.

$('.about').click(function () { $(".back").load('tour.html', function () { $(".back").show(); }); });

".back" should visible when images in tour.html loaded, when triggered success event??

$(".back").load('tour.html', function (html) { var $imgs = $(html).find('img'); var len = $imgs.length, loaded = 0; $imgs.one('load', function() { loaded++; if (loaded == len) { $(".back").show(); } }) .each(function () { if (this.complete) { $(this).trigger('load'); }); });

this requires @ to the lowest degree 1 <img> in returned html.

javascript jquery ajax