Posts

Showing posts from March, 2014

vb.net - adding vertical text each item in text file writeline with some text -

i populating listbox text & saving output textfile (sobj.txt) 'saving items of lb1 in file under c:\temp dim integer w = new io.streamwriter("c:\temp\sobj.txt") = 0 lb1.items.count - 1 w.writeline(lb1.items.item(i)) next w.close() this text file contains 3 (for example) entries, let's abc in 1st line, def in 2nd line & ghi in 3rd line. now want append text file (mpadd.txt) using sobj.txt entries such following: 'appending listbox items file mpadd.txt using sw new io.streamwriter("c:\temp\mpadd.txt", true) sw.writeline("some text" & abc & "some text") sw.writeline("some text" & def & "some text") sw.writeline("some text" & ghi & "some text") end using please in getting correctly. thanks. just read lines first file (just 3 lines not problem) , loop on these lines adding prefix , post

php - i want to display all checkboxes value which are checked -

i want display checked checkboxes in php. <script> function requestobject () { var returnvalue = null; try { returnvalue = new activexobject("microsoft.xmlhttp"); } catch (error) { try { returnvalue = new activexobject("msxml2.http"); } catch (error) { try { returnvalue = new xmlhttprequest(); } catch (error) { // failed return null; } } } return returnvalue; } var requestobj = null; function coajax(sender) { requestobj = requestobject(); if (requestobj) { sender.enabled = false; // user cannot change till request finished requestobj.open('get', '<?php echo get_template_directory_uri(); ?>/lunch_dinner.php

osx - Send email with c program in Mac OS X using MTA. -

the problem: failed invoke sendmail: invalid argument the code #include<stdio.h> #include<errno.h> #include<string.h> int add(char* to,char* from,char* subject,char* message) { int retval = -1; file *mailpipe = popen("/usr/lib/sendmail -t", "w+"); if (mailpipe != null) { fprintf(mailpipe, "to: %s\n", to); fprintf(mailpipe, "from: %s\n", from); fprintf(mailpipe, "subject: %s\n\n", subject); fwrite(message, 1, strlen(message), mailpipe); fwrite(".\n", 1, 2, mailpipe); pclose(mailpipe); retval = 0; } else { perror("failed invoke sendmail"); } return retval; } int main() { char to1[256]; char from1[256]; char message1[256]; char sub1[256]; int i; printf("hello\n"); scanf("%s",to1); scanf("%s",from1); scanf("%s",message1); scanf("%s",sub1); i=add(to1, from1, sub1, message1); return 0; } i tryed send email whith mac os x using c program. dont kno

java - How to work with long-lasting http requests -

i have long-lasting http request (a lot of computation in back-end). currently it's synchronous, while server computer, browser doesn't see output/result. after while, connection dropped , timeout error displayed in browser. i'd return info browser right away, , make wait result. how achieve this? please note, java back-end synchronous. solution require hack in servlet/front end possibly requiring javascript requests.. ? you want use comet pattern. it's ajax pattern, featuring long-held http requests simulate feed. see here detailed explanation. basically, fire off request, server holds it, replies when has of interest. @ point of receiving reply, fire off long-held request. this time-sequence makes feel feed. in case, return "yeah, i'm working on it" , reply "still processing 10% done dude" , on until "done". things node.js @ implementing kind of functionality. although, you're using synchronous java

c++ - Metaprogramming via macro -

i’d same stuff can d’s mixins c/c++ preprocessor. i’d write function generate parameter list. instance: #define mk_fn_foo(n,t) … mk_fn_foo(3,float) /* expand */ void foo(float x0, float x1, float x2) { /* else here */ } i have idea i’m facing issue. have recursion , have no idea how such thing: #define mk_foo(n,t) void foo(mk_foo_plist(n-1,t)) { } #define mk_foo_plist(n,t) t xn, mk_foo_plist(n-1,t) /* how stop that?! */ the boost libraries have vast extensive metaprogramming , else preprocessor library. possible kind of thing using utility preprocessor directives easier doing yourself, although still confusing :) i suggest start there: http://www.boost.org/doc/libs/1_53_0/libs/preprocessor/doc/index.html http://www.boost.org/doc/libs/?view=category_preprocessor edit: here tutorial them: boost.preprocessor - tutorial

javascript - How to play a video when param is active -

i'm using timesheets.js make smil-presentation. in javascript console see this: <div id="slide3" class="transition" smil="active"> <video id="foo" source type="video/mp4" src="foo.mp4"> </div> the parameter: smil="active" either active or done . i want play foo.mp4 when smil="active" i've added this: <script> $(document).ready(function () { $('#foo').prop('autoplay', true); }); </script> but plays video when page loaded, when smil="active" video has ended. how can fix this? edit: this js that fires state = "active": var state = ""; this.isactive = function() { return (state == "active"); }; this.show = function() { if (state == "active") return; state = "active"; if (0) try { consolelog(domnode.nodename + "#" + d

php - regular expressions multiple statements -

Image
i have half problem working. problem is: need match words either 7 letters long , starting st or 9 letters long ending tion. have code works first half of question: st\w{5}\s . match 7 letter word such 'startin' in example: start startin starting. however cant seem add second half. (st\w{5}\s)|(tion\w{5}) not work in trying find 'startin' , 'attention' out of: start startin starting attention. thanks. you'll want word boundaries \b(?:(st\w{5})|(\w{5}tion))\b

java - struts generating form elements from bean -

Image
i have struts 1.2 bean , bean code below in jsp page checkbox.jsp <logic:iterate property="userlist" id="userdet" name="userdetails"> <html:checkbox property="checked" name="userdet" indexed="true"> <bean:write property="username" name="userdet"></bean:write> </html:checkbox> </logic:iterate> the above code brings output below now when submit form want carry out javascript validation using ids of checkbox. how can generate id check box generated in jsp page bean?is possible generate id attribute dynamically ? try using 'indexid' attribute (the name of page scope jsp bean contain current index of collection on each iteration. ) of <logic:iterate> and use inside 'styleid' attribute of <html:checkbox> like this: <logic:iterate property="userlist" id="userdet" name="userdetails&q

lowercase - Grails lower() in query not working -

let's have code this: def c = account.createcriteria() def results = c { between("balance", 500, 1000) eq("branch", "london") or { like("holderfirstname", "fred%") like("holderfirstname", "barney%") } maxresults(10) order("holderlastname", "desc") } i want use lower() function transforming data lower case def c = account.createcriteria() def results = c { between("balance", 500, 1000) eq("branch", "london") or { like("lower(holderfirstname)", "fred%") like("lower(holderfirstname)", "barney%") } maxresults(10) order("holderlastname", "desc") } my code doesn't work. correct syntax? have problem umlauts don't want use ilike to use database functions in criteria need use sqlrestriction() add's

Render clipping of near polygon objects in Processing -

Image
i'm modelling 3d objects in processing , have issue whereby when objects close camera renders clipped (i.e. closest bits of object camera not rendered). happens both in p3d , opengl modes. right-hand image below illustrate: any idea how stop happening? code below, , testable online @ openprocessing.org . many in advance. void setup() { size(600, 400, p3d); stroke(0); rectmode(center); fill(200); // initialise camera variables scaley = pi/height; scalex = 2*pi/width; camdir = pi/3; camelev = pi/2; mousex = width/2; mousey = height/3; turncamera(); camf_rel = setvector(camdir, camelev); } void draw() { background(255); // camera & control operations mousex = constrain(mousex, 0, width); mousey = constrain(mousey, 0, height); setcamera(); camera(camp.x, camp.y, camp.z, camf_abs.x, camf_abs.y, camf_abs.z, 0, 0, -1); // draw environment // checkered plane fill(150,200,255); (int i=-10; i<10; i++) { (int j=-10; j<

objective c - NsWorkspace iconForFile returns image of low quality -

i'm using iconforfile: selector of nsworkspace class, returns image of low quality. can tell me why happening? there switch or flag framework return image in different format... the docs state returned icon's size 32x32, can use -[nsimage setsize:] , may load larger representation: nsimage * iconimage = [[nsworkspace sharedworkspace] iconforfile:file]; [iconimage setsize:nsmakesize(128, 128)]; you can use icon services (e.g. geticonreffromfileinfo ) or quicklook (e.g. qlthumbnailimagecreate ) file's icon or preview icon @ larger size.

jsf 2 - ui:include value is evaluated before preRenderView -

page1.xhtml <h:body> <h:link outcome="page2.xhtml> <f:param name="id" value="1"/> </hlink> </h:body> page2.xhtml <h:body> <f:metadata> <f:event type="prerenderview" listener="#{mybean.init}"/> </f:metadata> <ui:include src="#{mybean.mystring}"/> </h:body> mybean.java public void init(componentsystemevent e){ map<string,string> params = facescontext.getexternalcontext().getrequestparametermap(); string myid = params.get("id"); int id = integer.parseinteger(myid); if(id==1) setmystring = "mypage.xhtml"; } while navigating page1.xhtml page2.xhtml sending id parameter according id display page the problem page cannot find i printing in console what's happening found is evaluating getmystring() before going prerenderview init why happening this i tried post construct returned error in

ssis - DTS_E_PRIMEOUTPUTFAILED with error code 0xC0202091 when loading flat file -

i error message when try run ssis package error is: [flat file source [1]] error: column delimiter column "column 8" not found. [flat file source [1]] error: error occurred while skipping data rows. [ssis.pipeline] error: ssis error code dts_e_primeoutputfailed. primeoutput method on component "flat file source" (1) returned error code 0xc0202091. component returned failure code when pipeline engine called primeoutput(). meaning of failure code defined component, error fatal , pipeline stopped executing. there may error messages posted before more information failure. most of csv files load no problem handful of csv files don't , prior package has been working fine years. encountered error too, turned out skipping data rows because csv file has missing columns. try checking if columns in file correct.

ios - Scroll outer scrollview, then scroll the inner -

Image
i have view looks below: outer uiscrollview uiimageview inner uicollectionview i when user scrolls, should reach end of outer scrollview , starts scrolling inner scrollview, , vice versa(when user scrolls up, reaches top of inner scrollview , starts scrolling outer view). all neccessary smooth. smooth, mean user able start decelerating outer scrollview, , deceleration moved within innerview. i hope clear, since not easy explain. sorry if such question exists, couldn't find same. appreciate link and/or example. thanks in advance :) edit: wouldn't single collection view header view, containing image, reasons, not mentioned here. wouldn't use approach, using header cell. give outer scrollview contentsize that's equal image’s size plus collection view’s contentsize. forbid scrolling on collectionview. implement outer scrollview’s delegate scrollviewdidscroll method update: the image’s transform(so have illusion stays still) the col

c# - Converting base64 value to number -

i receiving data regarding vehicle speeds. have no control on input format, need use data. the data sent me base64 encoded values. apparently, data started out number in little endian format. currently, code this: public int b64toint(string input){ byte[] output = convert.frombase64string(input); array.reverse(output); if (output.length == 1) { return (int)output[0]; } else if (output.length == 2) { return (int)bitconverter.toint16(output, 0); } else { return bitconverter.toint32(output, 0); } } this works values receive, not all. way, convert value mph, need divide 1150.78. the following value works: aab6qg== converts 27.19720537374 mph. the following value not work: aa09 apparently, length of output array 3 bytes , don't know how handle situation. the error message is: "destination array not long enough copy items in collection. check array index , length." you build n

Integration of outlook into asp.net -

my requirement integration of outlook application. inorder start integration, first adding com library references of outlook referencs. actually requirement dont know version of outlook client has installed on workstyation? programming purpose if add outtlook 2007 dll (outlook 12.0 library) client has outlook 2003 (outlook 11.0 library) can't access application.it throw exceptions. how can fix problem? can add outlook references dynamically based on installed outlook version? how solve please me? with system.reflection namespace classes, you can load dll's dynamically . have through reflection. in specific case, though, have references there statically (unless it's huge load, reference every available outlook dll). gets down using design patterns use right version each situation code handle.

ruby on rails - Best ability based authorization -

i have rails 3 app, use cancan authorization, looking suits needs better. authorizations not role based, more situational. the application managing daily dinner clubs @ college/dorm, people takes turn making dinner rest. chef have therefore more permissions dinner club responsible (like changing menu), , participant have more permissions (like adding guests) 1 not participating in single dinner club. what need therefore authorization system depends on relationship between user , dinner club or kitchen (a kitchen have many dinner clubs), not users role. if helps, current cancan abilities here (as see pretty complex) # in ability.rb def initialize(user) # edit (like changing time or menu) dinner club can :edit, dinnerclub |dinner_club| dinner_club.is_chef?(user) && !dinner_club.canceled? end # open or close dinner club can [:open, :close], dinnerclub |dinner_club| !dinner_club.passed? && dinner_club.is_chef?(user) end # cancel

jboss7.x - JBoss deployment credetials via maven -

gcurrently trying make deployment of web-project (ear packed) jboss, , met next problem: settings.xml: <settings> ... <servers> <server> <id>default</id> <password>xxx</password> <username>xxx</username> </server> </servers> ... </settings> what need write in jboss-as-maven-plugin configuration in maven pom.xml make take credentials section? example, tomcat < server> parameter. tried "server","serverid","id", changing "username" "name" in settings.xml - no effect. the reason security measure - lets wanna post project on github etc, don't want keeping credentials @ file. of-course, googled around, so, how handle via command line - therefore, can handled via ide. in case of many projects etc?... change everywhere?.. if you're using latest plugin, 7.4.fin

actionscript 3 - AS3 - Can Bitmap classes dispatch mouse events? -

i'm trying learn as3 , have run small problem. i have bitmap class add mouseevent.click listener, event doesn't seem dispatched. i use flashdevelop write as3 code , flex compile. i have 2 classes, enemy.as , player.as the player.as looks this: package player { import flash.display.sprite; import flash.events.mouseevent; [embed(source="../../assets/leek.swf", symbol="leek")] public class player extends sprite { public function player() { trace("player constructed"); addeventlistener(mouseevent.click, handleclick); } private function handleclick(e:mouseevent):void { trace("clicked player"); } } } the enemy.as looks this: package enemies { import flash.display.bitmap; import flash.events.mouseevent [embed(source="../../assets/gardengnome.png")] public class enemy extends bitmap { public function enemy() { trace("enemy constructed&

iphone - iOS: keeping property values while switching between UITabBarItem's -

i have uitabbarcontroller linked 2 uiviewcontrollers , , in "first" uiviewcontroller have properties values need maintained when switch other view controller , back. instead, value of properties reset every time switch view controllers. how fix that? thanks! edit: heres code in uiviewcontroller (the scrollview under tab bar , navigation bar have on top): splitbillviewcontroller.m @interface splitbillviewcontroller () @property (nonatomic) nsmutablearray *defpricesarray; @property (nonatomic) nsmutablearray *defqtyarray; @property (nonatomic) nsmutablearray *deftickarray; @property (nonatomic) nsmutablearray *defpeoplearray; @end @implementation splitbillviewcontroller - (void)viewdidload{ [super viewdidload]; } -(nsmutablearray *)defpeoplearray{ if(!_defpeoplearray){ _defpeoplearray=[[nsmutablearray alloc] initwithobjects:@"1", nil]; } return _defpeoplearray; } -(nsmutablearray *)defqtyarray{ if(!_defqtyarray){

javascript - Need to have an iPad friendly (html) header file load when detected instead of regular flash header -

i have client wants make website ipad/iphone friendly. website has menu header made in flash. converted file using google's swiffy flash_1.html file. when website detects ipad/iphone want load swiffy flash_1.html file. otherwise, should load site normal. i having trouble doing this, writing correct if/else statement , having work. realize have change body tag onload regular site else since it's going function. sort of problem i'm running into. anyways, input or appreciated! xd this have far: <script type="text/javascript"> if ((navigator.useragent.indexof('iphone') != -1) || (navigator.useragent.indexof('ipod') != -1) || (navigator.useragent.indexof('ipad') != -1)) { document.location = "mobile/"; $(function{ $("#includedcontent").load("flash_1.html"); }); else the regular site's code looks this: ***note: not code appear correctly in text window, made image. (the informati

How to get rank using mysql query with PHP -

i have following code, , league rank of user based on total balance. how can this? // set league rank user global $post; $post_author = $post->post_author; $post_status = 'publish'; $meta_key = 'balance'; $rank = $wpdb->get_var( $wpdb->prepare( " select *, @rownum := @rownum + 1 ( select sum(meta_value) balance, {$wpdb->postmeta} pm inner join {$wpdb->posts} p on pm.post_id = p.id join (select @currow := 0) r; pm.meta_key = %s , p.post_author = %s , p.post_status = %s order balance desc)x, (select @rownum := 0) r ", $meta_key, $post_author, $post_status ) ); can me? thank you. try that: select round (sum(meta_value),2) balance, @currow := @currow + 1 rank {$wpdb->postmeta} pm inner join {$wpdb->posts} p on pm.post_id = p.id join (select @currow := 0) r; pm.meta_key = %s , p.post_author = %s , p.post_status = %s order balance desc i might misund

c# - Collecting data from a strongly typed razor view -

it's first asp.net mvc application @ all. i'm using mvc 3 , razor views. specific view have problem strongly-typed view (at least think is) accepts type of kind : @model list<list<dataaccess.mcs_documentfields>[]> i made several partial view because main view customized , need lot of different logic different parts of data. partial view typed (again think correct say) of type : @model list<dataaccess.mcs_documentfields>[] everything need build view in : @using (html.beginform("actionmethodname", "forms", formmethod.post)) { <div id="drawform"> <table border="1"> inside hhtml.beginform build table data comes controller. on submit : <button type="submit">submit</button> i'm looking best way data, , update in database changed. in controller have method : [httppost] public actionresult actionmethodname(formcollection collection) {

canvas - KineticJS - Multiple transforms applied serially -

i'm using kineticjs allow users manipulate images -- crop, rotate, scale, flip, etc. when apply transform image, works great. when apply second transform acts upon original, untransformed image, not new one. here's simplified jsfiddle: http://jsfiddle.net/sdwpj/ click scale button twice - should keep increasing size. click rotate button twice, should keep image onscreen. i know why happening. it's because transforms aren't changing actual image, they're changing way see image. want change actual image. maybe can save image after each transform or flatten stage? how can multiple transforms serially? here's code fiddle: html: <button id="scale">scale</button> <button id="rotate">rotate photo</button> <div id="container"></div> javascript: var photopath = "http://www.html5canvastutorials.com/demos/assets/yoda.jpg"; var stage; var photo; stage = new kinetic.stage({

ios - iPad displaying a selected pic from a popover -

after researching uiimagepickercontroller, got code select image popover , display in myparticularimageview. this viewcontroller.m: @interface viewcontroller () { uiimagepickercontroller *imagepickercontroller; uipopovercontroller *popover; } @end - (ibaction)chooseimagebuttonpressed:(id)sender { uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init]; popover = [[uipopovercontroller alloc] initwithcontentviewcontroller:imagepicker]; [popover setdelegate:self]; [popover presentpopoverfromrect:((uibutton *)sender).frame inview:self.view permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; } //then dismiss popover , display pic -(void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { uiimage *image = [info objectforkey:uiimagepickercontrolleroriginalimage]; [[self myparticularimageview] setimage:image]; [popover dismisspopoveranimated:yes]; } @end the problem have when tap on pic

java - Best way to upload/deploy jar files in Github -

Image
i've used in past google code , had ability upload runnable jar files download, using github , understand had download tab developers able upload files (i.e. runnable jar file), unfortunately deprecated now. is there another/better way deploy/upload runnable jar files on github download (for non developers download whole project zip file , compile it, bit complicated). i hear suggestions. since 2d july 2013 , have new way "upload runnable jar files download" , through release . releases , workflow shipping software end users. releases first-class objects changelogs , binary assets present full project history beyond git artifacts. they're accessible repository's homepage: releases accompanied release notes , links download software or source code. following conventions of many git projects, releases tied git tags. can use existing tag, or let releases create tag when it's published. you can attach binary assets (such compiled e

php - Using flush on apache as cgi -

i using php cgi on apache webserver. writing text files using scripts. flush() did not work. to make flush() work changed php "apache module". flush works, cannot access files anymore(permission denied). how can both use flush , access files used before? you need ensure apache user has write permissions on files , directory using. the user can different when running fcgi module

jquery - Why do I have a JavaScript parser error with this mask code? -

i have javascript parser plug-in in visual studios 2012 , throwing error @ line 30 of code, closing curly brace $.mask piece mr. bush: /* masked input plugin jquery copyright (c) 2007-2013 josh bush (digitalbush.com) licensed under mit license (http://digitalbush.com/projects/masked-input-plugin/#license) version: 1.3.1 */ (function($) { function getpasteevent() { var el = document.createelement('input'), name = 'onpaste'; el.setattribute(name, ''); return (typeof el[name] === 'function') ? 'paste': 'input'; } var pasteeventname = getpasteevent() + ".mask", ua = navigator.useragent, iphone = /iphone/i.test(ua), android = /android/i.test(ua), carettimeoutid; $.mask = { //predefined character definitions definitions: { '9': "[0-9]", 'a': "[a-za-z]", '*&

c# - MVC 4 Submit button in each row of a "grid" - how to? -

how can have submit button in each row of "grid", where, when button clicked, can post 3 pieces of data in row controller? here's scenario: a screen shows system's users in html table "grid". 1 link in each row says "associate customer". goes screen showing list of customers user can associated with. userid in url associatecustomer/14 on second screen, want display in html grid, customerid, customername, , link/button either: says "associate" if aren't associated customer, or says "disassociate" if associated customer i got working, don't know next part: when user clicks button on grid, need pass customerid, userid, , "associate/disassociate" controller. how can in mvc way? something like: @ html.actionlink("click me!","associate","somecontroller",new{userid=item.userid,customerid=item.customerid}) you don't have post form asking (though 1 way it).

android - Accessing GPS is not working. Application uses network to getting location -

Image
my app doesnt want use gps , using network location instead. checked analysing latitude , longtitude, they're little bit random (like network location). if use app using gps (e.g endomondo sports tracker) see characteristic mark, means, gps working: when launch application, there's no mark @ all. i'm using following code (code lars vogella, source: http://www.vogella.com/articles/androidlocationapi/article.html ): import android.app.activity; import android.content.context; import android.location.criteria; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.os.bundle; import android.widget.textview; import android.widget.toast; public class showlocationactivity extends activity implements locationlistener { private textview latitutefield; private textview longitudefield; private locationmanager locationmanager; private string provider; /** called when activity first cre

Android backwards compatibility: reflection versus simple conditional check -

i understand there (at least) 2 ways runtime checks ensure code doesn't call apis don't exist: use conditional version number check, la if (build.version.sdk_int >= build.version_codes.jelly_bean) use java.lang.reflect , wrapper class techniques explained here: http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html but don't understand when 1 technique should used in lieu of other. reflection seems necessary when trying use android classes may not exist, since loading such class referenced in code cause fatal error. calling method belonging class know exists? example, on device running 2.2 (api 8): protected void oncreate(bundle savedinstancestate) { if (build.version.sdk_int >= build.version_codes.froyo) { actionbar actionbar = getactionbar(); } ... is always safe, or there circumstances crash happen? there reason check if "getactionbar" method exists in activity using reflection instead o

How to scroll a ListView until I see a specific string with Calabash-Android -

i have exact same question post below, except need work android , post below ios. have tried both solutions given in post, don't seem work android. appreciated! how scroll uitable view down until see cell label "value" in calabash you can add new step definition , should trick android: then /^i scroll until see "([^\"]*)" text$/ |text| q = query("textview text:'#{text}'") while q.empty? scroll_down q = query("textview text:'#{text}'") end end it works me , hope same you!

javascript - Is there a way to tell what direction the state is going with history.js? -

like title says, i'd able perform different onstatechange event if pushstate function called, instead of back function. or, if go function negative or positive. example: if history.pushstate() or history.go(1) called, want statechange event's callback forwardpushstate if history.back() or history.go(-1) called, want statechange event's callback backwardspushstate a state data related page (as user see in browser). if user wants in page, page same, either if coming button click or forward button click, think. pushstate pushes new state in stack. has no relationship back , go . back , go functions navigate on pushed states in stack. because in edit, looks thinking pushstate , go(1) equivalent. maybe if want know direction user coming, should analyse onstatechange event know if takes parameter stores direction. still don't know how do. the main thing think, has no relationship go (-1) or go(1) or back .

c++ - how to code this northwest method -

i'm student trying learn programming , have never done complex coding before. lecturer gave me task on northwest corner method. followed code found on internet there seems problems code cannot figure out i'm still beginner. did readings still couldn't figure out problems , quite sure there many problems lies coding. i'm thankful willing take on coding. in advance. :) #include "stdafx.h" int _tmain(int argc, _tchar* argv[]) { return 0; } using namespace std; #include <iostream> #include <fstream> const int row_max =4; const int col_max =4; int i,j; //create supply_array , require_array float supply_array[row_max]; float require_array[col_max]; //creating cost matrix , unit matrix float cost_matrix[row_max][col_max]; float unit_matrix[row_max][col_max]; //initialize cost_matrix int main() { for(i=0 ; i<=row_max ; i++) { for(j=0 ; j<=col_max ; j++) { cin >> cost_matrix[i][j]; }

java - getting the desired aspect ratio for BufferedImage -

Image
i using following codes resize image, can same aspect ratio original image using getscaledinstance function setting 1 parameter negative, automatically maintains other paramter aspect ratio. problem facing bufferedimage , cannot set desired aspect ratio because don't know beforehand values of height generate(width have set 500).i have included image can getting result of running following code. bufferedimage have set 800x600 because have no other option.my previous question resizing image without compromising aspect ratio public class resizeimage { public static void main(string[] args) throws ioexception { bufferedimage img1 = new bufferedimage(800, 600, bufferedimage.type_int_rgb); img1.creategraphics() .drawimage( imageio.read( new file( "c:/users/public/pictures/sample pictures/desert.jpg"))

C# PInvoke flushall not giving any output, return value is 2 -

i trying follow simple tutorial on c# pinvoke, , created following program should output test string. [dllimport("msvcrt.dll", callingconvention = callingconvention.cdecl)] public static extern int puts(string c); [dllimport("msvcrt.dll", callingconvention = callingconvention.cdecl)] internal static extern int _flushall(); public static void main() { puts("test"); int x = _flushall(); console.readkey(); } when run program, don't see output in console window, or output window in visual studio. the return value _flushall call 2. have not yet been able find reference on msvcrt.dll see functions/entry points available, , return values mean.

http - what is cdn prefix instead of www in web address -

in place of missing www prefix see cdn . is special service or program, different webserver ? there list of common leftmost subdomains/domain prefixes? cdn stands content delivery network used application services (such cloud based services google or microsoft). don't know of list out there of prefixes, there may 1 haven't ran across yet.

What is the rule for jQuery callback function $(this) context -

it seems context $(this) changes during circumstances class selector. spent number of hours trying debug below javascript, not at: $.fn.specialbutton = function(callback) { $(this).bind('click', function() { // $(this) a.button, expected $.ajax({ url: 'ajax.php', data: callback(); // context pitfall }).done(function(response) { $(this).html(response); // context changed unknown }) }); } $('a.button').specialbutton(function() { // context pitfall return { id: $(this).data('id'); // $(this) not expect }; }); eventually figure solution save context , use explicit calling of callback: $.fn.specialbutton = function(callback) { $(this).bind('click', function() { // $(this) a.button, expected var $this = $(this); // save context; $.ajax({ url: 'ajax.php', data: callback.call($this); // explicitly spec