Posts

Showing posts from July, 2010

C File processing and matching help -

i have assignment in college in required read in 2 .dat (aascii) files created earlier program, both of sorted. one client account file contains clients balance , account number , name, other transaction file contains account number , transactions account. this program has match account numbers , create new , updated clients file adding transaction amount balance of client based on accounts number. i have working fine except when there duplicate transaction example if transaction file contains 2 separate transactions 2nd client code print updated balance after both transactions instead of cumulative balance. i wondering if can shed light on how solve problem. code attached, in advance. #include <stdio.h> #include <conio.h> int main() { int account,matches=0; /* account number */ char date[ 30 ]; /* account date */ double balance, saleamount,total=0, x; /* account saleamount */ int transaccount; char name [ 30 ]; file *cfptr;

django-registration view customization -

i'm using django-registration (see: https://bitbucket.org/ubernostrum/django-registration ) on 1 of projects. standard setup django-registration add code below in urls.py file (r'^accounts/', include('registration.urls')) and customize templates in folder called registration . the code above creating links registration, login , password recovery fine. in project there other functions add views if add include('registration.urls') appears have no way of customizing views containing django-registration forms. is there way call forms used django-registration in view can add few more things on views ? the registration form provided registration backend. check out registration.backends.default.defaultbackend . there's method get_form_class(request) returns registration.forms.registrationform class. have create new backend, inherit defaultbackend , override get_form_class() method return new form class. you can pretty providing

Where is PDF image rotation information stored? -

i trying extract images stored in pdf stream. while can easily, not able accurate image rotation information. looking specific information such mediabox, rotate , landscape/portrait mode. when extract image, alignment not match end user sees pdf reader tool. i binary compared 2 pdfs (where image rotated 90 in former , same image rotated 270 in latter) , found difference in particular stream object. however, not able make out stream information is. here 2 documents talking about: http://bit.ly/eqzgkj http://bit.ly/g43whb the position, size , orientation of image when displayed on page determined current transformation matrix (ctm). have execute entire page content stream determine ctm in place when image displayed. it's virtual rendering of pdf page.

ios4 - in iphone 4 which method call when we close application -

i want know method call when in iphone , application close , again open. in iphone4 malty task felicity available . want background , foreground method application. - (void)applicationdidenterbackground:(uiapplication *)application when user quits application supports background execution. and - (void)applicationwillenterforeground:(uiapplication *)application method called part of transition background inactive state. can use method undo many of changes made application upon entering background.

iphone - ipad 3.2.2 loading in landscape -

i changed properties in info.plist support orientation in landscape thereby app opens in landscape mode well. problem face when app loads in landscape mode view aligned. there view on right side of split view not aligned properly. when load in portrait mode , landscape there no issue. can tell me if there additional properties or work around issue. as using splitview controller should not worry orientation. just see in view .nib file there 1 authosizing feature set u remove problem. this link may if dont know autosizing.

licensing - How can I distribute msvr71.dll (microsoft visual c++ runtime dll) -

i have application requires msvcr71.dll. in machines dll missing. instead of asking user install vc++ runtime, distribute dll (only 1 file msvcr71.dll) our application. gets copied application installation directory. from licensing point of view, doing correct? not find license agreement. the page has following note: for msvcr70.dll or msvcr71.dll, should install crt dll application program files directory. should not install these files windows system directories. msvcr80.dll , msvcr90.dll, should install crt windows side-by-side assemblies. there should redist.txt file in program files/microsoft visual studio .net 2003 states rules redistributing different files visual studio. http://msdn.microsoft.com/en-us/library/aa984372.aspx has list of locations check redist.txt .

c# - get xml node by order -

i have xml file like: <?xml version="1.0" encoding="utf-8" ?> <config> <metadataformconfig fieldinternalname="test"> <tabs> <tab title="a c" order="1"> <showparentterm>a</showparentterm> <showparentterm>b</showparentterm> <showparentterm>c1</showparentterm> </tab> <tab title="d e" order="2"> <showparentterm>d</showparentterm> <showparentterm>e</showparentterm> </tab> </tabs> </metadataformconfig> </config> i want tab element order. if changed tab title="a c" order 2 want node "d e" first "a c" can 1 me how this? you can linq xml: xdocument doc = xdocument.load(@"test.xml"); var tabs = do

database - Delete query in sqlite for child tables -

i have 3 tables, employee, department , electronics tables. electronics table child table department table , department table child table employee table. i want delete 1 record in employee table e_id=2 ( primary key) foreign key in department table (e_id foreign key , dept_id primary key) , dept_id foreign key in electronics table. first want delete related records in electronics table department table , employee table. please guide me how it. you can read more foreign key support in sqlite here: http://www.sqlite.org/foreignkeys.html but should able turn on: sqlite> pragma foreign_keys = on; and setup database schema deletes cascading: -- database schema create table employee( e_id integer primary key, name text ); create table department( dept_id integer primary key, name text, e_id integer references employee(e_id) on delete cascade ); create table electronics( elec_id integer primary key, name text, dept_id integ

sql server - set default schema for a sql query -

is there way set schema query in rest of query can refer tables name without prepending them schema name? for instance, this: use [schemaname] select * [tablename] as opposed this: select * [schemaname].[tablename] a quick google pointed me this page . explains sql server 2005 onwards can set default schema of user alter user statement. unfortunately, means change permanently, if need switch between schemas, need set every time execute stored procedure or batch of statements. alternatively, use technique described here . if using sql server 2000 or older this page explains users , schemas equivalent. if don't prepend table name schema\user, sql server first @ tables owned current user , ones owned dbo resolve table name. seems other tables must prepend schema\user.

mysql - Using JOIN'ed mapping tables better than multiple fields in the same table? -

i have table of 360,000 records , here's performing query on 2 indexed fields: select count(*) emails department_id in(1,2,3,4) , category_id in (5,6,7,8) (time: 0.9624802) id: 1 select_type: simple table: emails type: range possible_keys: emails_department_id_idx,emails_category_id_idx key: emails_category_id_idx key_len: 5 ref: null rows: 54018 extra: using so 1 index being used there. (i can index merge work when using simpler comparisons or range criteria, need checks against list of ids). here created 2 new tables map relationship, , using join's replicated same results: select count(*) emails left join email_to_department on (email_to_department.email_id = emails.id , email_to_department.department_id in (1,2,3,4)) left join email_to_category on (email_to_category.email_id = emails.id , email_to_category.category_id in (5,6,7,8)) email_to_department.department_id not null , email_to_cat

javascript - Validating time entered into textbox -

i have textbox in user can enter time (eg: 01:00) , drop down box entering am/pm fields. (since am/pm field used, 12-hour time format used.) the text box allows max entry of 5 chars (eg: 01:00). how can set 3rd char default colon : , user has enter time. how check if time entered user numeric or not?. autocomplete feature: example, if user enters 1 automatically set 01:00 javascript validations 12-hour format. eg: if user enters 13:00 should change 01:00 how can append text box time values am/pm value selected in drop down box?. once values appended, automatically populate text box (text box 2) result. eg: 01:00 + pm should set 01:00p in new text box (text box 2). any appreciated. better have textbox size , maxlength of 2 named "txthours", colon label (span tag) , textbox named "txtminutes". easier manage. instead of checking, have onkeypress code returns false when key pressed not number allowing digits. best done in onblur event, if

javascript - How to prepopulate few fields in a form, in a survey -

i have share point survey. when responding survey, know, open newform.aspx. page contains listformwebpart in questions survey list displayed. now, need add few labels before questions , these label values should prepopulated query string. trying achieve is, wll created link values in query string , send specific users. different users might have different values in query string. whenever click on link, should open survey prepopulated label values along questions in list. i not sure, how it. have tried add html control web part(using share point designer) , through javascript have tried set query string values. tried put asp controls , trued. didn't work. trying since last 2 days. no progress. using sharepoint 2003, wss2.0 can anybody, please me implement solution. you may find easier create webpart custom form enters data survey list. the survey lists useful quite flexible, solution make hard change list in future. means webpart specific survey may valid desig

php - Troubles with file protector server - readfile(); -

i wrote following script avoid exposing protected files users logged in web application. this works small files... on platforms, such ipad, android, internet explorer , safari sometimes (about 50% times) file served partially... connection stop in middle of trasfer. i'm running apache2.2/php 5.3 on ubuntu server 10.04. can suggest how improve it? thanks. <?php // bootstrap env vars // includes .. if(! @constant('app_base_path') ) { header('http/1.1 502 bad gateway'); die(''); } // allowed types $allowed_types = array( 'application/pdf', 'image/png', 'image/jpeg' ); // custom function check login if( isuserlogged($_session) ) { // if file exist if(! is_file( $file ) ) { header('http/1.1 400 bad request'); die('unable find target file'); } // if permitted $type = exec('file -bi ' . escapeshellarg($file) ); if(! in_array( $type, $allowed_types ) ) { head

why SOAP without WSDL? -

is there reason deploy or consume soap service without using wsdl "file"? explanation: i'm in situation 3rd-party has created soap service not follow wsdl file have created. think forced ignore wsdl file in order consume service. therefore i'm researching how this. what wondering why possible this? intention? is designed can use poor services made poor programmers? surely there must better reason. wish wasn't possible. demand write properly. the wsdl supposed public document describes soap service, describes signatures of methods available in service. of course there may service providers want expose service consumers, don't want make signature of service public, if make little bit harder people don't want using service find or attempt use it. signature of services might expose private information schema of data example. but don't see excuse writing wsdl doesn't match service. worry if can't wsdl right quality of serv

javascript - How to open documents that contain certain characters through WebDav? -

i use activexobjects edit documents through webdav using online service according to: function openwithwebdavcallback(data, xmlobj) { var document = new activexobject("sharepoint.opendocuments.2"); var documentpath = xmlobj.getelementsbytagname('davurl')[0].firstchild.nodevalue; document.editdocument(documentpath); } however documentpath contain number sign (#) results in editdocument crashing , not allowing access document. i've tried replacing number sign "& # 3 5 ;" without success. how can allow special characters #, ?, = etc. used in document names , still allow user access them through webdav? a # means "start fragment identifier" in url. you need encode urls, not html. in javascript: encodeuricomponent

CorePlot - iPhone Graphs -

Image
i getting error coreplot-cocoatouch.h: no such file or directory". have kept coreplot0.2.2 folder in desktop. used following path set header path. "/users/giri/desktop/iphonegraph/coreplot 0.2.2/source/framework is correct ? please me. in advance. @girija you need add core plot framework project adding existing framework , in target click on app name, click on info button on middle top of xcode , in general tab add core plot framework linked libraries.

php - Using Zend_Auth to secure all controllers -

how globally secure controllers (except login controller) ensure application secure @ points (no hidden backdoor ajax calls, etc). thought might put in bootstrap file, doesn't feel right? i'm trying avoid adding code each controller. suggestions? edit : complement of @singles response. you must understand there 2 different things. auth , acl . auth tells user, , can example redirect user having no auth login controller, , set auth identity after login. acl system take yes/no decisions based on auth data (could user id or role, stored in auth storage. on nice solution have 2 controllers plugins (registered in order on bootstrap, auth acl). if not use controller plugins you'll have call acl check in each controller, when needed. if need it, use plugins. implement predispatch() in auth plugin set example anonymous identity if have no identity return zend_auth. code snippet of real one: public function predispatch(zend_controller_request_abstract $req

hibernate - HQL JoinTable not accessible -

i have many many relationship between media , tags: medium: @manytomany(fetch=fetchtype.eager) @indexcolumn(name="tags_index_column") @jointable(name="tag_map", joincolumns={@joincolumn(name="tag_id")}, inversejoincolumns={@joincolumn(name="item_id")}) private list<tag> tags; tags: @manytomany(mappedby="tags") @jointable(name="tag_map", joincolumns={@joincolumn(name="item_id")}, inversejoincolumns={@joincolumn(name="tag_id")}) private list<medium> media; i try query join table hql exception: string resultquerystring = "from tag_map" query resultquery sessionfactory.getcurrentsession().createquery(resultquerystring); exception: org.springframework.orm.hibernate3.hibernatequeryexception: tag_map not mapped [from tag_map]; nested exception org.hibernate.hql.ast.querysyntaxexception: tag_map not mapped [from tag_map]

jQuery UI Dialog and IE -

i'm using jquery ui dialog project , having problems ie8 (haven't tested on ie7 , below did tested on chorme , ff). i use code in js: var dialogobj = $("#dialog").dialog({autoopen: false, title: id, modal: false, width: 600, height: 400}); the dialog filled through ajax. in ie8 title not showing correctly. it's narrow , doesn't show title's text. also have problem in ie: whenever press element shows dialog have error message: webpage error details user agent: mozilla/4.0 (compatible; msie 8.0; windows nt 6.1; trident/4.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; tablet pc 2.0; infopath.3) timestamp: wed, 9 feb 2011 11:27:22 utc message: unexpected call method or property access. line: 103 char: 460 code: 0 uri: http://localhost/js/jquery.js which @ line: return this.dommanip(arguments,true,function(a){this.nodetype===1&&this.appendchild(a)})}, char 460 starts here: this.nodet

Is there a library for Python that gives the script name for a given unicode character or string? -

is there library tells script particular unicode character belongs to? for example input "u'ሕ'" should return ethiopic or similar. you can parse scripts.txt file: # -*- coding: utf-8; -*- import bisect script_file = "/path/to/scripts.txt" scripts = [] open(script_file, "rt") stream: line in stream: line = line.split("#", 1)[0].strip() if line: rng, script = line.split(";", 1) elems = rng.split("..", 1) start = int(elems[0], 16) if len(elems) == 2: stop = int(elems[1], 16) else: stop = start scripts.append((start, stop, script.lstrip())) scripts.sort() indices = [elem[0] elem in scripts] def find_script(char): if not isinstance(char, int): char = ord(char) index = bisect.bisect(indices, char) - 1 start, stop, script = scripts[index] if start <= char

iphone - UIITabelViewCell displaying incorrect images -

hi friends displaying image on table cell table have 10 cell but displaying images on 2 cell when scroll table view images come 1 one on cell so what's doing wrong here. static nsstring* identifier = @"celltypelabel"; // create custom cell customizedtablecells* cell = nil; if (cell == nil) cell = [[[customizedtablecells alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:identifier] autorelease]; // cell accessory type cell.accessorytype = uitableviewcellaccessorydisclosureindicator; cell.imageview.image = nil; nyhtrappdelegate *appdelegate = (nyhtrappdelegate *)[[uiapplication sharedapplication] delegate]; nsxmlelement* node = [appdelegate.items objectatindex:indexpath.row]; nslog(@"\n output :: %@ :: ", [node xmlstring]); // set lable name cell if(node != null) { int width = cell.contentview.bounds.size.width-50; if([[[node elementforname:@"pubdate"] stringvalue]length] > 0)

objective c - Reordering cells in UITableView -

i have tableview 10 sections , each section has 3 rows. is possible reoder section using tableviewdelegate methods -(bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath { return yes; } -(void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { } right if dragging row 1 section , dropping on section, being added section. footer view not being selected reordering, , remains in original section. any ideas? thanks check out tutorial: add, delete & reorder uitableview rows . there's working project @ end of tutorial.

java - how to use swc file in flash builder project -

hi.. have swc file have added file project using http://interactivesection.files.wordpress.com/2008/11/use_flash_code_library_in_flex.jpg how can use component in flash builder project. thanks after adding swc project shown in screengrab, can use of classes in swc other class in project: as: import some.package.in.my.swc.someclass; private var someclass:someclass; mxml: add namespace top level tag points package in swc, such xmlns:library="some.package.in.my.swc.*", add tags so: <library:somecomponent/> hope helps.

c# - Change Windows 7 Serial Number -

i want make little licene management c#. with common pc-image, set workstations without serial number , want change serial number c# daemon. my question: how can change serial number , activate windows 7 using c#? thank you! you're looking slmgr.vbs . can call using process.start .

java - Eclipse p2 : Difference between category.xml and site.xml -

p2 repository creation ant tasks eclipse.publish.featuresandbundles seem take site.xml or category.xml file specifies category information. i see contents of site.xml , category.xml eclipse generates same right down tags. so difference between two? edit - clear : additions/subtractions present in category.xml differentiate site.xml apart filenames? the main difference between site.xml provides information update site , other repo information can structured, , part of update site, of 3.4 has been replaced content.xml , artifacts.xml in categories xml file describing categories, can consumed during p2 build , produces categories seen in help>install new software dialog. again p2, categories.xml can replaced child repo in composite repo containing information expect.

java - How to add a LineBreak (\n) to a String.format with fixed String as format? -

in code below, message final string have \n inside it, , doesn't work. message = format = "blah %d blah blah \nblah blah %s blah" interventionsize = number userid = string string.format(dic.message,interventionsize,userid) how can make line break in case, cannot find answer. btw, cannot use kind of framework or external jar (old code) have use plain old java. having \n in format string fine. perhaps should try platform specific new-line. format strings can use %n . that is, try following: string.format(dic.message.replace("\\n", "%n"), interventionsize, userid);

.net - How to (easily) find the proper assembly for a given namespace -

i have problems attributes. can't find proper assembly. can't find them on google either: [key, column(order = 0)] [databasegenerated(databasegenerationoption.none)] in this code following namespaces declared: using system.data.entity.database; using system.data.entity.infrastructure; where can find assemblies these namespaces? isn't there easy way find assembly besides searching namespace on google? in case have assembly referenced: go declaration. ( f12 in visual studio when cursor on definition searching for.) the object browser should pop up. @ root of tree can see assembly. when did not reference assembly: you can still use object browser search assembly ( view -> object browser ). in dropdown box, select "all components" , ... , search. when classes looking aren't microsoft: it seems classes looking aren't microsoft. in case can create 'custom component set' in object browser . can add third party

Remove element from array in mongodb -

i new in mongodb , want remove element in array. my document below { "_id" : objectid("4d525ab2924f0000000022ad"), "name" : "hello", "time" : [ { "stamp" : "2010-07-01t12:01:03.75+02:00", "reason" : "new" }, { "stamp" : "2010-07-02t16:03:48.187+03:00", "reason" : "update" }, { "stamp" : "2010-07-02t16:03:48.187+04:00", "reason" : "update" }, { "stamp" : "2010-07-02t16:03:48.187+05:00", "reason" : "update" }, { "stamp" : "2010-07-02t16:03:48.187+06:00", "reason" : "update" } ] } in document, want remove first element(reason:n

javascript - window.onbeforeunload ajax request in Chrome -

i have web page handles remote control of machine through ajax. when user navigate away page, i'd automatically disconnect machine. here code: window.onbeforeunload = function () { bas_disconnect_only(); } the disconnection function send http request php server side script, actual work of disconnecting: function bas_disconnect_only () { var xhr = bas_send_request("req=10", function () { }); } this works fine in firefox. chrome, ajax request not sent @ all. there unacceptable workaround: adding alert callback function: function bas_disconnect_only () { var xhr = bas_send_request("req=10", function () { alert("you're been automatically disconnected."); }); } after adding alert call, request sent successfully. can see, it's not work around @ all. could tell me if achievable chrome? i'm doing looks legit me. thanks, i having same problem, chrome not sending ajax request server in window.unload eve

internet explorer 7 - Forcing IE7 into standards rendering mode (not quirks) -

i'm having display issues in ie7 due rendering in quirks mode. i've confirmed displaying "document.compatmode" , getting "backcompat" opposed "css1compat". using ie8 , reverting ie7 works, because keeps out of quirks. in plain ie8 have fixed forcing rendering mode x-ua-compatible header, not work ie7. other browsers display in quirks, unlike ie not put them pseudo-ie5.5 mode, still render fine. how can force ie7 render in standards rendering mode , not quirks? i've tried setting doctype number of different options , i'm not adding xml prologue. in advance replies. did try xhtml 4 strict dtd ? <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml/dtd/xhtml1-strict.dtd"> also beware if there before dtd declaration, ie7 still stay in quirk mode. in other words: ie7: strict <?xml version="1.0" encoding="utf-8"?> <!doctype html pu

PHP: generate a number from xyz0000 to xyz9999 -

i trying generate list of numbers (that can use in for/foreach cycle). any number should 10 digits long , have initial prefix (i.e. 0851) 0851xxxxxx , go 0851000000 0851999999 range('0851000000','0851999999') however array take as 84mb in memory (as reported memory_get_usage(1) ) less memory consuming way generate these numbers on fly, while iterate in loop. for example for($a = 851000000; $a <= 851999999; $a++) { $number = '0'.(string)$a; dosomethingwith($number); }

c# - Sharepoint 2007 Current User -

i'm trying use object model of sharepoint 2007 make changes on list , read users , groups web settings... for developed web service (wcf) stored in same web application sharepoint site in iis. thats working. i call inside web service spcontext.current.web.currentuser and thats user not me, "sharepoint\system" why? other thing web try users using spcontext.current.web.users that contain "sharepoint\system", not others. why!!! i give full trust in web.config , use ntlm authentication method. it sounds me issue account web service running under. change application pool web service using , set identity named account. then, when query current user in sharepoint, should see named account identified in application pool.

installation - hadoop install on round-robin DNS -

i want install hadoop on round-robin dns environment. have bunch of machines sharing common user environment , common name. these machines equal. round-robin dns runs on branch of machines. each machine has own ip address , host name. our school's machines. these machines share common name. when login, terminal shows machine on. the problem make change on 1 machine, changes applies other machines. i follow instruction of michael-noll's multi-node hadoop. need configure master node. did master node applies slave nodes. said, cannot differentiate master , slave nodes. so, can install hadoop in such environment? i'm not quite sure why want install hadoop using round-robin dns, no, cannot hadoop. every single node needs have unique host name.

replace - Is it possible with Eclipse to only find results in string literals? -

lets assume have following java code: public string foo() { // returns foo() string log = "foo() : logging something!" return log; } can search in eclipse foo() occurring in string literal, not anywhere else in code? in example here eclipse should find third occurrance of foo() , not first one, function name , not second one, comment. edit: simple regular expressions won't work, because find foo() in line like string temp = "literal" + foo() + "another literal" but here foo() function name , not string literal. you can try this: "[^"\n]*foo\\(\\)[^"\n]*" you have escape brackets, plus regex not match new lines or additional quotes, prevent wrong matches.

perl - How to enumerate all possible combinations of elements -

i want enumerate possible combinations of elements array. example: have array: $r = ('a1','a2','a3' ...). i want print combinations of element arrays: a1a2, a1a3, a1a2a3, etc . a1a2 != a2a1, a1a2a3 != a1a3a2 ... it turns out there's a module that: use math::combinatorics; @r = qw(a1 a2 a3 ...); #@all_combinations_of_r = map { combine($_,@r) } 1..@r; @all_permutations_of_r = map { permute(@$_) } map { combine($_,@r) } 1..@r;

multithreading - when a thread is blocked.can cause the blocking of another thread in the same process or the whole process? -

when thread being blocked necessary thread blocks other threads in same process or process?is happening every time? sure. wouldn't have cope deadlock if wasn't case. scenario blocked thread acquired synchronization object thread tries acquire well. block. okay, question now. generally, yes. other code needs run release blocking condition. non-obvious cases kernel threads run code in drivers if thread blocked on i/o. or thread scheduler, in case thread blocked because waiting acquire processor or waiting non-infinite time-out.

Create 10,000 non-repeating random numbers in PHP -

i need work out way create 10,000 non-repeating random numbers in php, , put database table. number 12 digits long. what best way this? this assumes can generate 12 digit random number without problems (use getrandmax() see how big can get....according php.net on systems 32k large number can get. $array = array(); while(sizeof($array)<=10000){ $number = mt_rand(0,999999999999); if(!array_key_exists($number,$array)){ $array[$number] = null; } } foreach($array $key=>$val){ //write array records db. } you use either rand() or mt_rand(). mt_rand() supposed faster however.

Can I "combine" 2 regex with a logic or? -

i need validate textbox input credit card number. have regex different credit cards: visa: ^4[0-9]{12}(?:[0-9]{3})?$ mastercard: ^([51|52|53|54|55]{2})([0-9]{14})$ american express: ^3[47][0-9]{13}$ and many others. the problem is, want validate using different regex based on different users. example: user1, visa , mastercard available, while user2, visa , american express available. generate final regex string dynamically, combining 1 or more regex string above, like: user1regex = visa regex + "||" + mastercard regex user2regex = visa regex + "||" + american express regex is there way that? thanks, you did not state language whatever reason suspect it's javascript. var user1regex = new regexp('(' + visaregex + ")|(" + mastercardregex + ')'); can use (?:) speedier execution (non-capturing grouping) have omitted readibility.

c# - Where does DataRowCollection.Add method insert the new row? -

i'm trying figure out datarowcollection.add(datarow row) inserts new row datatable. @ end of table, append? random? also, want use while i'm looping through datatable. if condition exists, add new row containing different data run through loop end of datatable. there specific problems approach? how else might handle it? edit: looping through .net datatable stored in memory. i'm not touching database original data stored during looping operation. datatable populated prior loop , not problem. here relavant code: datatable machineandlastdate = new datatable(); //populate machineandlastdate (int = 0; < machineandlastdate.rows.count; i++) { lastfuturedate = datetime.parse(machineandlastdate.rows[i]["maxduedate"].tostring()); newdatetime = lastfuturedate.adddays(frequency); //this new date created. machineserial = machineandlastdate.rows[i]["machineserial"].tostring(); if (newdatetime < datetime.now) {

vba - Assigning values to a user defined data type -

i assign values of range user defined data type. i have dataset of measurements taken @ mutliple times on course of week stored in excel sheet. have created variable range of data set. created user defined data type date , single types. assign values of range user defined data type. data set: 02/11/2011 3.8 02/11/2011 2.4 02/11/2011 8.9 02/12/2011 5.7 02/12/2011 4.6 02/12/2011 2.6 i've made user define data type: type phdata dy date ph single end type and created variable of phdata type , matched size range: dim dailydata() tradedata dim nrec integer nrec = datarng.rows.count redim dailydata(nrec) and defined range of dataset on excel spreadsheet: dim datarng range set datarng = range("a2", range("a2").end(xldown).end(xltoright)) and assign values in range phdata type. can assign 1 value @ time using: dailydata(1).dy= datarng(1).value but need more efficient have 4,000 records. try this: dim rngdata rang

varbinary - Working with Binary Data in MySQL -

Image
select 0x0000987c col1, substr(binarydata,1,4) col2, cast(0x0000987c signed) col3, cast(substr(binarydata,1,4) signed) col4 ( select 0x0000987c00000000 binarydata ) d returns col1 col2 col3 col4 ---- ---- ----- ---- blob blob 39036 0 when @ blob viewer col1 , col2 both appear identical (screenshot below). so why different results col3 , col4? i think has data types. binarydata has integer data type, substr(binarydata,1,4) expects string. cast gets confused result. also, cast parses strings using base 10, need little bit of work. try this: cast(conv(substr(hex(binarydata),1,8), 16, 10) signed) col4 it's monster, should give want.

java - Stop Executor when a Callable returns a specific result -

i'd stop executor running more future objects if have been submitted executor. getting multiple threads running though executor works fine , executor should stop when 1 of callable's returns boolean true. it's fine current running future's complete waste of time continue rest. set<future<boolean>> calculationset = new hashset<future<boolean>>(); threadpool = executors.newfixedthreadpool(3); int x = nextx(); int y = nexty(); { callable<boolean> mathcalculation = new mathcalculation(x, y); future<boolean> futureattempt = threadpool.submit(mathcalculation); calculationset.add(futureattempt); x = nextx(); y = nexty(); } while (runsomemore()); where mathcalculation implements callable interface , call() method returns boolean value. searching through calculationset on each iteration isn't option since set become quite large , not work because of multi threaded situation. there way achieve this? you

Problem with setLayoutParams method in android UI -

i making application in have change ui programmaticaly. needed change layout_height , layout_width xml attributes. but when use setlayoutparams method, app runs , give message has unexpectedly stopped working , have force close. i have tried setting layoutparams viewgroup.layoutparams well. nothing works. kindly check attached code , guide. this java code. private void fixlayoutvmain(){ listview lv; imagebutton rev,stop,play,forw; lv=(listview)findviewbyid(r.id.listmain); rev=(imagebutton)findviewbyid(r.id.rev); stop=(imagebutton)findviewbyid(r.id.stop); play=(imagebutton)findviewbyid(r.id.plpa); forw=(imagebutton)findviewbyid(r.id.forw); log.d("dev1","id's have been assigned"); layoutparams lp=new layoutparams(w, ((75*h)/100)); log.d("dev1","param object created"); lv.setlayoutparams(lp); log.d("dev1","listview param set"); lp.heigh

proximity - SQL - find row with values of two columns closest to X and Y -

i building website on wich people can infos based on weight , height. how 1 structure query give me row 2 specific values closest ones users enter? i found this on stackoverflow , helpful. trying accomplish similar 2 values insted of 1. if weight , height of equal importance, can use (linear) select top 1 * tbl order abs(weight-@weight) + abs(height-@height) a better option weigh differences, on scale, such making 0.01m (1cm) of height of equal importance 1kg. square both sides well, deviation of 5cm , 5kg seen "closer" 10cm , 0kg. (assuming inputs in kg , metres) select top 1 * tbl order abs(weight-@weight)^2 + (abs(height-@height)*100)^2

c++ - How to make policy dictate a member variable type? -

while trying apply policy-based design, got stuck on 1 (simplified): template <class tprintpolicy, typename t> struct : private tprintpolicy { using tprintpolicy::print; t t; void foo() { print(t); } }; struct intpolicy { void print(int n) { std::cout << n << std::endl; } }; int main(int argc, char* argv[]) { a<intpolicy, int> a; a.foo(); return 0; } and here's question: how should redefine class possible provide policy parameter template, let infer t on own, this: a<intpolicy> a; preferrably, policy definition should not more complicated now. ideas? edit: forgot mention not want policy export typedef. of course easy solution, cannot infer type of t on own? make typedef within each policy gives policy's data type. template <class tprintpolicy> struct : private tprintpolicy { using tprintpolicy::print; typename tprintpolicy::data_type t; void foo() {

html - Save multiple selection of dropdown list to variables using Javascript -

i have there dropdown lists values, , 1 textarea write valuse in. when press button writes values of 3 selected dropdown lists, every time when press button (it 3 times). pice of code writes values of dropodown lists, this: button pressed first time: "conntent of dropdown lists" undefinedundefined button pressed second time: undefined"conntent of dropdown lists"undefined button pressed third time: undefinedundefined"conntent of dropdown lists" but want values of dropdown list not "undefined" what can think of? var = 0; function inc(){ i++; if (i == 1){ var ukupnaporudzbina1 = vrstename + ' -> ' + podvrstename + ' -> ' + velicinename + i; }else if (i == 2){ var ukupnaporudzbina2 = vrstename + ' -> ' + podvrstename + ' -> ' + velicinename + i; }else if (i == 3){ var ukupnaporudzbina3 = vrstename + ' -> ' + podvrstename + ' -> ' + velicinename + i; } var porudzba = ukupnapo

android - Custom titlebar - system titlebar being shown for a brief moment? -

i've got custom layout want use titlebar of android app. technique found (linked @ bottom) works, system titlebar displayed before oncreate() called. looks pretty jarring, moment system titlebar shown, custom titlebar shown: // styles.xml <resources> <style name="mytheme"> <item name="android:windowtitlesize">40dip</item> </style> </resources> // 1 of activities, mytheme applied in manifest. protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_custom_title); setcontentview(r.layout.my_activity); getwindow().setfeatureint(window.feature_custom_title, r.layout.my_custom_header); } i hide system titlebar , display own in-line perhaps each , every layout, but, that's not friendly. thanks http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/ i think it's framework limitation. had same p

python - What are the default URLs for Django's User Authentication system? -

django's user authentication system ( http://docs.djangoproject.com/en/dev/topics/auth/ ) incredibly helpful in working users. however, documentation talks password reset forms , makes seem takes care of same way user login/logout. the default url login , logout is /accounts/login/ & /accounts/logout are there defaults changing password, or have build functionality? if @ django.contrib.auth.urls can see default views defined. login , logout , password_change , password_reset . these urls mapped /admin/urls.py. urls file provided convenience want deploy these urls elsewhere. file used provide reliable view deployment test purposes. so can hook them in urlconf: url('^accounts/', include('django.contrib.auth.urls')), as want customize views (different form or template), in opinion redefine these urls anyway. it's starting point nevertheless.

java - CTR mode use of Initial Vector(IV) -

from know, ctr mode doesn't use initial vector. takes counter, encrypts given key , xor's result plaintext in order ciphertext. other block cipher modes cbc before doing encryption xor plaintext initial vector. so here problem. have following code in java(using bouncycastle library): cipher cipher = cipher.getinstance("aes/ctr/pkcs5padding", "bc"); cipher.init(cipher.encrypt_mode, key); byte[] result = cipher.dofinal("some plaintext"); every different call of above code same key gives different output! when doing: byte[] iv = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; cipher cipher = cipher.getinstance("aes/ctr/pkcs5padding", "bc"); cipher.init(cipher.encrypt_mode, key, iv); byte[] result = cipher.dofinal("some plaintext"); i take same result in every call of above code. why this? mean, ctr doesn't need iv, why when don't give iv in every call different result , when given

php - what's the point of serializing arrays to store them in the db? -

i see people store arrays like: a:6:{i:0;s:5:"11148";i:1;s:5:"11149";i:2;s:5:"11150";i:3;s:5:"11153";i:4;s:5:"11152";i:5;s:5:"11160";} why can't be: 11148,11149,11150,11153... and have sql "type" "array" ? this way it's shorter , can change values directly in databse without having alter "s:" or "i:". i've not seen whole lot. it's done implementation ease. serializing data allows store quasi binary data. your second example csv scheme. workable storing confined string lists. while it's easier query or modify within database, makes more effort unmarshalling from/to database api. there limited list support anyway. http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set however, true, serialized data unneeded in example. it's requirement if need store complex or nested array structures. , in such cases data blob

Mysql unique values query -

i have table name-value pairs , additional attribute. same name can have more 1 value. if happens want return row has higher attribute value. table: id | name | value | attribute 1 | set1 | 1 | 0 2 | set2 | 2 | 0 3 | set3 | 3 | 0 4 | set1 | 4 | 1 desired results of query: name | value set2 | 2 set3 | 3 set1 | 4 what best performing sql query desired results? this solution perform best: select ... table t left join table t2 on t2.name = t.name , t2.attribute > t1.attribute t2.id null another solution may not perform (you need evaluate against data): select ... table t not exists ( select 1 table t2 t2.name = t.name , t2.attribute > t.attribute )

xaml - Resize image from url for panorama background -

i'm working on first wp7 app , i'm exploring world of panorama control. i've loaded object rest service , i've set background of panorama image url in object. var brush = new imagebrush() { imagesource = new bitmapimage(new uri(_group.photo_url, urikind.absolute)) }; grouppanorama.background = brush; the problem have image arbitrary size on server , case ends being squished (horizontally) , tiled without filling width of screen horizontally. i'm assuming need re-size dimensions control supports, not sure how go this. assume pretty common task. many thanks! edit: including snip-it of xaml. pretty generic: <!--layoutroot contains root grid other page content placed--> <grid x:name="layoutroot"> <controls:panorama name="grouppanorama" title="" selectionchanged="grouppanorama_selectionchanged"> <!--panorama item one--> <controls:panoramaitem header="main"

php - Multiple commands atomically -

i'm using php , mysql call couple of commands. there group-employee cross-reference table, , employees may added or removed group. i'm writing feature first removing employees , adding in each employee in table if group modified. want make sure commands go through or else have table roll back. how can make sure commands happen atomically? you're looking transactions unless i'm mistaken. here's great place start: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-transactions.html

scala - How to make an sbt project reference external java sources -

could post code example of how reference external java source directory in sbt project? if following override def mainsourceroots = super.mainsourceroots +++ externalsourcepath the sbt compile task find , compile java sources fail. e.g. [info] compilation successful. java.lang.runtimeexception: path /full/path/to/java/class/com/foo/bar/someclass.java not in . sbt 0.9 support external sub-projects. until then, suggest build other 1 jar, , drop results ./lib .

How can I see the values of the variables from a Perl trace? -

my target debug (step step) sample.pl script below. the problem: don’t real values of variables ($top_number , $x , $total). my question: how see real integer values of ($top_number , $x , $total) trace output? what needs change in perl -d:trace in order numbers, , not: $top_number , $x , $total ? example trace output: [root@linux /tmp]# perl -d:trace ./sample.pl >> ./sampl.pl:9: $top_number = 100; >> ./sampl.pl:10: $x = 1; >> ./sampl.pl:11: $total = 0; >> ./sampl.pl:12: while ( $x <= $top_number ) { >> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x; >> ./sampl.pl:14: $x += 1; # follow short form? >> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x; >> ./sampl.pl:14: $x += 1; # follow short form? >> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x; >> ./sampl.pl:14: $x += 1;

ruby on rails - Why do hidden fields produce hashes? -

my hidden field: - @calc.results.each |k, v| = hidden_field :calc_result, :value => "#{k[:total_interest]}" which returns : "calc_result"=> {"value214.14"=>"", ... how can write hidden_field produces : "value" => "214.14" you don't need pass :value, this: = hidden_field_tag :calc_result, "#{k[:total_interest]}" that should want.

sql server - access unkown columns of a table and insert them into a new one -

i have table like: item1 item2 item3 item4... itemn 1 2 3 4... n if need calculus variables lets powers , sqrt item1,item3, , insert in column 1 of new table, , same operations item2 , item4 , insert in column 2 of new table,... like: new table column1 column2 column3 .. columnsn-1 columnsn item1*item3 item2*item4 item3*item5 .. itemn-1*item1 itemn *item2 but column names variable (aka different tables) dont know how accomplish , values of specific columns, please me? this way extract name , order of column: select name, colorder syscolumns id = (select id sysobjects name = [tablename]) you can use manipulate data refering order in table instead of name

compilation - Considerations for compiling Fortran code to 64bit? -

i'm working on scientific/engineering programs written in fortran 32bit unix system , have recompile new 64bit cluster , having trouble making sense of errors , changes should make. i compile fortran programs 32-bit or 64-bit oses , haven't encountered problems. errors have seen? changing parallel program? a program implemented best design philosophy of fortran >=90 requests numeric types according precision needs, e.g., using "selected_real_kind" specify number of digits needed in real type. compiler (on os , host computer) provides requested precision if can, or otherwise program refuses run. if requested precisions sufficient compute answer, approach should make portable program. isn't perfect since numeric computing model isn't totally specified.

java - guess words using dictionary -

i guessing key of less-simple simple substitution ciphertext. rule evaluate correctness of key number of english words in putative decryption. are there tools in java can check number of english words in string. example, "thefoitedstateswasat"-> 4 words "thefortedxyzstateswasathat"->5 words. i loaded words list , using hashset dictionay. dont know inter-word spaces belong in text, can't validate words using simple dictionary. thanks. i gave answer similar question here: if word made of 2 valid words it has java-esque pseudocode in might adaptable solves problem.

Weird list behavior in android -

i have imageview on top of listview , whenever there long running process populate list hide listview , make imageview visible. i tried things setvisibility() i'm getting messed scroll behavior list. i'm using asynctask manage don't think that's causing messed scrolling behavior. ideas on how can display busy spinner while list being populated , not inconsistent scrolling behavior list? as far weird scrolling behavior may need set property on listview android:cachecolorhint #00000000 otherwise weird things when there image under listview while scrolling.

How does Google Chrome Instant Omnibox work? -

how omnibox instant in google chrome 9 work ? enabled developer panel , checked, didn't find xhrs being fired... omnibar hidden developer panel ? this part done in c++, won't see in developer panel; can use google codesearch chromium view chromium source code. of interest may instantcontroller , templateurlfetcher . it's not easiest code follow, because written in asynchronous style (the instant bits register observer gets invoked when suggest url has been fetched).

iphone - Customize map annotations from plist -

i found short guide on how load "annotation data" plist , add annotations (pins) mapview. my question if can tell me how customize pins easily? example, define color , image in plist , have set when adding pins. the pins added this: myannotation.m: @implementation myannotation @synthesize title, subtitle, coordinate; -(void) dealloc { [super dealloc]; self.title = nil; self.subtitle = nil; } myannotation.h #import <foundation/foundation.h> #import <mapkit/mapkit.h> @interface myannotation : nsobject<mkannotation> { cllocationcoordinate2d coordinate; nsstring *title; nsstring *subtitle; } @property (nonatomic, assign) cllocationcoordinate2d coordinate; @property (nonatomic, copy) nsstring* title; @property (nonatomic, copy) nsstring* subtitle; running through plist in viewdidload in mapviewcontroller.m (array containg dictionaries each pin) , adding annotations. nsstring *path = [[nsbundle mainbundle] pathforres