Posts

Showing posts from June, 2013

android - Unable to find Custom Style -

one of xml files not find attributes definied in style. think style correct, works other files. not single style work. says need define layout_width , layout_height attributes, did in style. i think it's simpler give 1 example. if need whole xml file, no problem. <relativelayout style="@style/relativelayout_multiplechoicefrage_aufloesung_content" > <style name="relativelayout_multiplechoicefrage_aufloesung_content"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:orientation">vertical</item> <item name="android:layout_marginleft">@dimen/frage_content_marginleft</item> <item name="android:layout_marginright">@dimen/frage_content_marginright</item> </style> i cleaned project, didn't work. hopefully can find solution.

amazon web services - AWS Identity TVM registration from android -

in identity tvm registration, instead of redirecting user identity tvm register.jsp register, can directly username , password of user through application(because user must register use application) , send them identity tvm registration registered. if yes, how it? i had same problem. answer came send http post request within app replicates happens on registration form. you need create new layout captures username , password (i copied file login_menu.xml, renamed register_menu.xml , changed of widget ids) in original login.java file changed onclick action register button redirect new activity called register.java in register.java use register_menu.xml layout file , when person clicks register button following code run (it gets run within asynctask): string registration_url = (propertyloader.getinstance().usessl() ? "https://" : "http://") + propertyloader.getinstance().gettokenvendingmachineurl() + "/registeruser"; url

java - Query creation in Spring Data - dynamic where clause -

is there way in spring data dynamically form clause? what want have method (which findby / method) runs , and using mentioned properties not null. for example, consider object person [firstname, lastname, age, gender] our method looks this findby_ifnotnullfirstname_andifnotnulllastname_andifnotnullage_andifnotnullgender(string firstname, string lastname, integer age, string gender) thanks. take @ jpa specification , predicate, , better querydsl, there both supported spring data repositories. article provide example: http://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/

Android - Application onCreate method - does it ALWAYS get called first? -

i preparing new version of 1 of apps, , made such huge changes in app, need data conversion after update of app absolutely first thing (before doing else). figured out, best place in class (which extends application) in oncreate() method. tested few times, , seems work ok, read documentation: base class need maintain global application state. can provide own implementation specifying name in androidmanifest.xml's tag, [b]which cause class instantiated when process application/package created[/b]. it looks right, not quite sure. can confirm/disprove it? the application constructor called first. application::oncreate() method called. exception know of if application contains contentprovider, can receive calls before application does. this here: http://developer.android.com/reference/android/app/application.html#oncreate() public void oncreate () added in api level 1 called when application starting, before activity, service, or rece

java - Keep out of reach of Children: Removing protected fields from inheritance -

in spirit of designed oo, class extending has marked 1 of fields protected. class has generously provided public setter, yet no getter. i extending class base class in turn extended several children. how can restrict access protected variable children while still being able manipulate privately , set publicly? see example below: public abstract class thirdpartyclass { protected map propertymap; public void setpropertymap(map propertymap){ this.propertymap= propertymap; } // other methods use propertymap. } public abstract class mybaseclass extends thirdpartyclass{ // accessor methods entries in propertymap. public getfoo(){ propertymap.get("foo"); } public getbar(){ propertymap.get("bar"); } // etc... } public class oneofmanychildren extends mybaseclass { // should access propertymap via methods in mybaseclass. } i have found can revoke access making field private final in mybaseclass . hinders using setter provided

sql server - SQL queries slowing down every few days -

i have query has been running fine years, started slowing down lot. instant 25 seconds. after research turned out problem "broken" indexes. reorganizing , rebuilding indexes of 4 tables query uses fixed problem. great, done thought. after few days same problem again. rebuilding index fixed started coming every few days. query slows down => rebuild indexes. tables pretty constant, few hundred items added in week , have 300k records. what cause of this? edit: it's query, have no idea how make more efficient without breaking things alter procedure [dbo].[odat_pricesbydealer] ( @dealer_id int, @dealergroup_id int, @startdate datetime, @pricetype_id int, @product_groep nvarchar(30) ) set nocount on if @pricetype_id = 0 set @pricetype_id = null if @product_groep = '0' set @product_groep = null select a.price_id , a.make_id , e.make_code_name

node.js - Why is "exports" not defined in my karma Node unit test and what is preventing requirejs from working as expected -

i've been trying unit tests working node application , have followed guide here searched on , google , unclear doing wrong or if trying right. i have created own module simplicity called mymodule.js , contains: exports.mul = function (a, b){ return * b; }; i have set karma init allow requirejs see config file , test-main.js karma.config.js : // karma configuration module.exports = function(config) { config.set({ basepath: '', frameworks: ['jasmine', 'requirejs'], files: [ {pattern: 'lib/**/*.js', included: false}, {pattern: 'src/**/*.js', included: false}, {pattern: 'test/**/*spec.js', included: false}, 'test/test-main.js', ], exclude: [ 'src/main.js' ], reporters: ['progress'], port: 9876, colors: true, loglevel: config.log_info, autowatch: true, browsers: ['chrome'], capturetimeou

python - Pattern for '.' separated words with arbitrary number of whitespaces -

it's first time i'm using regular expressions in python , can't work. here want achieve: want find strings, there word followed dot followed word. after unknown number of whitespaces followed either (off) or (on) . example: word1.word2 (off) here have come far. string_group = re.search(r'\w+\.\w+\s+[(\(on\))(\(off\))]', analyzed_string) \w+ first word \. dot \w+ second word \s+ whitespaces [(\(on\))(\(off\))] (off) or (on) i think last expression might not doing need to. implementation right now, program find right place in string, output of string_group.group(0) is just word1.word2 ( instead of whole expression i'm looking for. please give me hint doing wrong? [ ... ] used character class, , match one character inside them unless put quantifier: [ ... ]+ 1 or more time. but adding won't work... \w+\.\w+\s+[(\(on\))(\(off\))]+ will match garbage stuff word1.word2 )(fno(nofn too, don't want use

svn - How to import an unversioned directory in to local repository in smartsvn? -

Image
i'm starting use smartsvn , can't import directory local repository. gives me error shown in figure. i have configured c:\repo local directory don't know how choose in step in import repository dialog. could tell me how select local repository import projects? smartsvn does not support local repository access (aka file://) protocol . you'll need start server use repository on local machine. based on screenshot appear using windows. easiest process download windows vanilla subversion installer wandisco . once that's installed should able start svnserve command prompt so: svnserve -d -r c:\repo then you'll able access repository via svn://127.0.0.1/ in smartsvn. if svnserve stopped or computer restarted you'll need repeat process. if want more permanent setup i'd suggest setting svnserve service on windows covered in svn book .

java - How to extract numbers from a string using regex? -

this question has answer here: how extract numbers string 2 answers string = "sin(23)+cos(4)+2!+3!+44!"; a.replaceall("(\d+!)",""); current output = sin(23),+,cos(4),+,+,+ i want result 2!,3!,44! please help string = "sin(23)+cos(4)+2!+3!+44!"; pattern number = pattern.compile("\\d+!"); matcher matcher = number.matcher(a); while (matcher.find()) { system.out.println(matcher.group()); }

openwrt - Where can I get sources or detailed documentation of /usr/sbin/nas -

i tried /usr/bin/nas sources http://downloads.openwrt.org/sources/nas-4.80.9.1.tar.gz found contains compiled elf binaries. tried dd-wrt sources (with hope find nas there) using instruction on page http://www.dd-wrt.com/wiki/index.php/development crucial instruction svn co http://svn.dd-wrt.com/dd-wrt return error stating no source. i need either detailed parameters of /usr/sbin/nas (as specified nas --help or man nas if dd/open-wrt had man pages) or nas sources. the "source" code nas in dd-wrt can found here: http://svn.dd-wrt.com/browser#src/router/nas openwrt have seen. to me appears nas (possibly closed source?) binary has been repackaged these 2 distributions binary blob, obtained somewhere else. after bit more digging found source code appears same program on github, answers question: https://github.com/jcolp/rtn66u/tree/master/release/src/router/nas tbh, guessed running strings on nas binary , discovered c source files nas_wksp.c , n

mysql - selecting last n dated records for each in a group -

i hope can help. have table.... name date number john 2014-01-01 5 sally 2014-01-01 7 john 2013-12-24 2 sally 2013-12-24 7 john 2013-11-10 1 sally 2012-11-10 8 i want latest 2 (or x) records each person eg john 2014-01-01 5 john 2013-12-24 2 sally 2014-01-01 7 sally 2013-12-24 7 i don't know start. if can shed light on grateful. (if have time) if explain solution learning purposes! many thanks jules select x.* my_table x join my_table y on y.name = x.name , y.date >= x.date group x.name , x.date having count(*) <= 2 order name,date desc;

continuous integration - Have sbt fail when project loading fails (rather than awaiting user input)? -

i'm configuring our ci infrastructure , when project loading fails sbt asks do: project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? this hangs build waits process return. is there way tell sbt stop without asking when loading fails? invoke sbt -batch option. still print prompt not wait reply, instead exit non-0 status.

javascript - bgiframe with jquery browser -

here old jquery code using jquery 1.5 version. works jquery.fn.showpagemask = function() { var maskheight = $(document).height(); if ($.browser.msie && parseint($.browser.version) < 7) { $('#pagemask').bgiframe(); } $('#pagemask').css({ 'filter': "alpha(opacity=50)" }); $('#pagemask').css({ '-moz-opacity': "0.6" }); $('#pagemask').css({ '-khtml-opacity': "0.6" }); $('#pagemask').css({ 'opacity': "0.6" }); $('#pagemask').show(); $(window).resize(function() { $('#pagemask').setfullwidth(); }); now updated jquery 1.9.1 , getting error $.browser here instead of checking browser version , name, should check feature support. dont understand, how can check below scenario feature.. feature should detect? if ($.browser.msie && parseint($.browser.version) < 7) { $

ios - Updating NSDictionary inside an NSArray -

i have nsarray of nsdictionaries . need updated nsarray of nsdictionaries value of 1 of dictionary key updated new value. please see below nsarray structure. want update value key3 inside structure if key1 matches value (e.g. 2). fastest way of doing this. not want use traditional loop. [myarray valueforkeypath:@"@unionofobjects.key3"]; <__nscfarray 0xe70c10>( { key1 = 1; key2 = "new location"; key3 = ( data1, data2, data3 ); }, { key1 = 2; key2 = "old location"; key3 = ( data1, data2, data4 ); } ) we can solve using predicates: nsarray *dictionaryarray; nsnumber *key =@2; nspredicate *predicate =[nspredicate predicatewithformat:@"key1=%@",key]; nsarray *result =[dictionaryarray filteredarrayusingpredicate:predicate]; result array has dictionaries having (key1 = 2) dictionarys can't edited directly, must nsmutabledictio

python - best mechanism for post and comment in django -

i'm going write mechanism writing models , views django create post/comment in blog in full options. explain mechanism example? take @ django tutorial: https://docs.djangoproject.com/en/1.6/intro/tutorial01/

java - loops binary tree in jstl -

i create binary tree , display result in jsp conditions. each node has 4 elements (id, question, answer, , leftnode rightnode) if user clicks "yes", program goes left of tree , if answers "no" right of tree. for example, initial question "you're man?" if answers "yes" go left , page view "you're singer?" if answers "no" page displays "you're french? ". in java, original question. cursor [i]. getquestion () then yes cursor [i] getquestion. getleftnode () and no cursor [i]. getrightnode (). getquestion until the, works normally, when want loop until there no longer issue by <c:when test="${not empty cursor[i].getquestion() }"> the program stops @ first loop , stops cursor not empty here complete code jstl <c:choose> <c:when test="${not empty cursor[i].getquestion() }"> <c:if test="${param.btn eq 'oui'}" var=&

ruby on rails - Does carrierwave support git/svn as a storage repository -

does carrierwave support git/svn storage repository instead of file operating system. does carrierwave support versioning of image. i.e. stored foo.png / version1 , made changes , store foo.png / version2. given foo.png should able retrieve version1/version2. check out http://rubydoc.info/gems/carrierwave/frames if want change storage directory: class myuploader < carrierwave::uploader::base def store_dir 'public/my/upload/directory' #where want story images, works cloud storage end end if want version control, using thumbnail example: class myuploader < carrierwave::uploader::base include carrierwave::rmagick process :resize_to_fit => [800, 800] version :thumb process :resize_to_fill => [200,200] end end the rubydocs have information , more check out. another resource ryan bates rails casts: http://railscasts.com/episodes/253-carrierwave-file-uploads - free http://railscasts.com/episodes/383-uploading-to-amazo

recursion - NSFetchRequest with sort descriptors for recursive CoreData Entity relationship -

Image
i have got simple coredata entity "myentity" recursive relationship: (the relation one-to-one relation in case) imagine had created 5 objects of entity: objecta -> objectb -> objectc -> objectd -> objecte ( objectb child of objecta , on) i create nsfetchrequest nssortdescriptors return objects in correct order (from root last child): objecta objectb objectc objectd objecte is possible? (my specific problem more complex, think can done if got simple 1 solved) why bother, fetch parent object , it's child , child's child property (relationship) directly. if need them in array use while loop traverse hierarchy until child = nil.

python - Encoding error in Pandas DataFrame -

in pandas dataframe, when writing csv can encode file adding argument encoding='utf-8' however there issue this. if getting data directly database , placing directly dataframe, when writing csv, encoding error: unicodeencodeerror: 'ascii' codec can't encode characters in position 24-25: ordinal not in range(128) so decoding/encoding needs happen prior placing data datframe. does have simple solution this? if creating dataframe database, can use read_sql : df = pd.read_sql('select * foo', con) here con connection object, e.g. created using sqlite3 or mysqldb.

c++ - Why we use reference return in assignment operator overloading and not at plus-minus ops? -

as read in books , in web, in c++ can overload "plus" or "minus" operators these prototypes (as member functions of class money ): const money operator +(const money& m2) const; const money operator -(const money& m2) const; and assignment operator with: const money& operator =(const money& m2); why use reference money object return value in assignment operator overloading , not in plus , minus operators? returning reference assignment allows chaining: a = b = c; // shorter equivalent "b = c; = b;" (this work (in cases) if operator returned copy of new value, that's less efficient.) we can't return reference arithmetic operations, since produce new value. (sensible) way return new value return value. returning constant value, example does, prevents move semantics, don't that.

Ruby Gem not install dependency -

i created ruby gem , published it. tried downloading , keep getting cannot require dependent gem. code @ https://github.com/wallerjake/toolshed , gem in question httparty. error getting is ~/.rvm/gems/ruby-2.0.0-p353@sullivan_cotter/bundler/gems/toolshed-46404c5af06d/lib/toolshed.rb:2:in `require': cannot load such file -- httparty (loaderror) i have updated https://github.com/wallerjake/toolshed/blob/master/toolshed.gemspec use add_dependency instead doesn't seem helping. conflicting other gems? the version on rubygems still old 1 development dependencies. worked fine when downloaded , built gem github.

javascript - How do I persist the checkbox status after click event/jQuery/ajax call -

i have following event code reloads code section on page. problem that, if check box checked, can't find way re-check after reload. jquery(this.el).find('.view_all_future_filter').click(function () { todonote.view_all_future_filter = jquery(this).prop('value'); _this.parent.reload(); }) i tried following, check box keeps being reset unchecked: if(this.view_all_future_filter == "on") { this.query_string += '&view_all_future_filter=' + this.view_all_future_filter; var show_state = "checked"; } else { var show_state = ""; } this.load(); jquery('#view_all_future_filter').prop('checked', show_state); any appreciated! you can use sessionstorage save data , after reload content: if (window.sessionstorage) { var checkedstate = jquery('#view_all_future_filter').attr('checked'); sessionstorage.setitem("somecheckboxstate", checkedstate); }

java - Best ways to use the lazy load -

i have long chain of objects, of loaded lazily. use jpa(out of luck on fetchmodes) in few cases dont have load full object graph, in these cases performance good. in few other cases, might have load full object graph below. below classes representational purpose only firstobject.java @lazy private set<secondobject> secondobject.java @lazy private set<thirdobject> // may load 20-30 objects @lazy private set<fourthobject> // may load 20-30 objects thirdobject.java @lazy private set<fourthobject> // may load 10 - 100 records fourthobject.java @lazy private set<fifthobject> // may load 10-100 records . . . (the list goes on) edge case if see, each child loads several children , there no way avoid. imagine user trying load firstobject.java , needs full object graph until fifthobject.java graph. firstobject = session.get(firstobject.class, 10); //because children lazy, tries initialize them below. firstobject.getsecondob

Downward pointing arrow in Google Maps -

Image
i'm using google maps v3. regardless of position, there's arrow in screen. default add white downward arrow in left of maps? attached image. regardless of position, there's arrow in screen. absolutely not special location. knows how remove it? appreciate it. thanks. the reason behind opened info window (without markups) unintentionally; remove info window , arrow disappear.

rdf - In an ontology, how to define a property's value as a datetime -

Image
when writing ontology , want create class , property relating time/date, assume you'll have structurally (psuedo code) : class:project label: project property:duedate label: expected completion time , date of project domain: project range: datetime (?) i've googled around , found owl-time ontology, use case confusing me because looks i'm supposed define quite few things. on right track here? you haven't mentioned how you're constructing ontology. if you're writing owl hand (e.g., functional syntax), you'd 1 way; if you're writing rdf, you'll (you'd write rdf encoding of owl axiom). easiest way see how these done defining ontology using protégé, or similar graphical editor, , @ resulting code. assume since used term datetime, you're @ data property values should literals of datatype xsd:datetime . in protégé in protégé you'd this: in owl functional syntax the syntax data property range axioms given

c - Creating a simple gtk list -

i create simple table in gtk following content: | test name | 0 | 10 | i want create this, gtk doesn't make easy. have made gtkliststore contains information need, apparently need create gtktreeviewcolumn well. need pass values gtk_tree_view_column_new_with_attributes, problem don't know attribute names , can't find them anywhere. attribute found "text", pass unsigned integers well. tell me these attributes are, , how create simple table? (i read https://developer.gnome.org/gtk3/stable/treewidget.html btw) enum { file_name = 0, file_offset, file_size }; gtkwidget* tree; gtkliststore* store; gtktreeiter iter; gtkcellrenderer* renderer; gtktreeviewcolumn* column; store = gtk_list_store_new (3, g_type_string, g_type_uint, g_type_uint); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, file_name, "test name", file_offset, 0, file_size, 10, -1); tree = gtk_tree_view_new_with_model

ruby on rails - Create key if it doesn't exist in nested hashes -

i've been trying figure out how write ruby code more eloquently. have better solution? a[:new] = {} if a[:new].nil? a[:new].merge!( { new_key => new_value } ) is there way write in more elegant way? come across lot when dealing nested hashes need check whether key exist , if not, create it. write below taking of hash#to_h , nilclass#to_h a[:new] = a[:new].to_h.merge( { new_key => new_value } ) example : hsh1[:a] # => nil hsh1[:a] = hsh1[:a].to_h.merge({1=>2}) hsh1[:a] # => {1=>2} hsh2 = {:a => {'k' => 2}} hsh2[:a] # => {"k"=>2} hsh2[:a] = hsh2[:a].to_h.merge({1=>2}) hsh2 # => {:a=>{"k"=>2, 1=>2}}

phpmyadmin - Updating multiple rows in SQL -

using phpmyadmin, want update multiple rows of data new information. the 'uid' unique each record. 'pid' field same records. i modified insert statment after exported data database. update `tabme_name` set (`uid`, `pid`, `title`, `category`) values (230952, 1902, 112, 27634), (230953, 1902, 179, 27641), (230954, 1902, 75, 27630), (230955, 1902, 38, 27626); i can find information on updating 1 record, or updating records same information. show me correct sql statment? havn't got clause in it!?! assuming uid pk must execute multiple updates: update tabme_name set pid = 1902, title =112, category=27634 uid=230952 update tabme_name set pid = 1902, title =179, category=27641 uid=230953 ...

c# - Does assigning an non-empty array to another array clear the array? -

say have arrays, string[] arr1 = { "hi", "hello", "goodbye" }; string[] arr2 = { "stop", "making", "arrays", "please" }; string[] arr3 = { "simple", "array"}; according declaration above arr1 initialized size 3, arr2 4, , arr3 2. arr1 has been initialized array maximum size 3, happens if assign different array it? are original values cleared , replaced new array? what if second array smaller, values smaller array populated , old values kept? if it's bigger, indexoutofrange exception? the variables pointers arrays. assigning arr2 arr1 , arr1 , arr2 both point { "stop", "making", "arrays", "please" } . if assign "test" arr1[1] , arr2[1] == "test" . original array assigned arr1 orphaned , garbage collected @ point.

php - Symfony2: How to use constraints on custom compound form type? -

Image
here question i've been breaking head on while now. please know i'm not symfony2 expert (yet), might have made rookie mistake somewhere. field1: standard symfony2 text field type field2: custom field type compound field text field + checkbox field) my goal: getting constraints added autovalue field work on autovalue's text input child the reason why constraints don't work because notblank expecting string value , internal data of form field array array('input'=>'value', 'checkbox' => true) . array value gets transformed string custom datatransformer . suspect that happens after validating field against known constraints. as see below in commented code, have been able constraints working on text input, when hardcoded autovalue's form type, , want validate against main field's constraints. my (simplified) sample code controller , field: . controller code setting quick form testing purposes. <?php //

javascript - Adding unique class name to dynamically created elements/ JS / jQuery -

if have ten divs created dynamically, each 1 given class name 'createddiv' on creation. how can iterate through them after created , add unique class name each? somthing like, for each('.createddiv'){ var count = 1; this.addclass('uniquename' + count); count ++; } so end 10 divs follows, ('.createddiv .uniquename1') ('.createddiv .uniquename2') ('.createddiv .uniquename3') ('.createddiv .uniquename4') and on... $('.createddiv').each(function(i){ $(this).addclass('uniquename' + i); });

recursion - Recursive object setting java -

i have model call section. section has 2 fields: color , list of section objects. public class section{ public string color; public list<section> sub_sections; } suppose json feed list of section objects. within each section object color field set random color , list of section objects. within these nested section lists color fields set empty string. dont know how many nested sections there are. how set nested color strings within nested sections same color first level section? code below non recursive 3 levels deep give ides of problem. for(section section : sectionslist){ for(section sub : section.sub_sections){ sub.color=section.color; if(sub.sub_sections.size()> 0){ for(section sub2 : sub.sub_sections){ sub2.color=sub.color; if(sub2.sub_sections.size()> 0){ for(section sub3 : sub2.sub_sections){ sub3.color=sub2

jquery - Execute PHP code onclick of button/link? -

i have shopping cart uses php. when person adds cart, relevant code done @ top of cart.php, meaning have leave product page add cart, , end having press button if want more. how execute php/sql code when user clicks "add cart", without redirecting them new page? think jquery/json needed here, don't know first thing that. below: //product page <input type="button" value="3"/> //when button clicked, sql/php based on value on same page originally, had: //product page <form action="./cart.php" method="post"> //some code user select whats submitted <input type="submit"/> </form> ... //cart page //some logic relevant taking value product page , adding cart //then display cart contents the problem takes them new page when i'm positive logic can done on same page onclick of button. do post request jquery,the page doesn't load since ajax.. $('input[type="sub

c - const char array[] = {set} storing in big endian, I need little endian -

i'm writing c big endian 32-bits microcontroller , need store char arrays in rom: const uint8 font_6x8[570] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <space> 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, // '!' 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, // '"' ... } const uint8 font_6x6var[665] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <space> 0x02, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, // '!' 0x04, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, // '"' ... } and on multiple bitmap fonts use on graphic lcd. problem compiler stores bytes in big endian 4-bytes sets messes every character each other they're not made of n*4 bytes each. they're supposed const , set in rom can't go , reverse them in code. is there way tell compiler these bytes need inserted in little endian order. thought using 8-bits types enforce doesn't. if using gcc , try calling flag -mbig-endian or -mlittle-endian respectively.

c# - Insert list of rows -

i'm trying simple insert list of rows datagridview database. i have made checkedbox upon checked, item added datagridview . i'm attempting insert part. have come far: try { string strappointment = "select appointmentid appointment appointmentid=@searchappointmentid"; sqlcommand cmdappointment = new sqlcommand(strappointment, connection); cmdappointment.parameters.addwithvalue("@searchappointmentid", txtappointmentid.text); connection.open(); (int = 0; < dataprescription.rows.count; i++) { string firstcolumn = dataprescription[0, dataprescription.currentcell.rowindex].value.tostring(); string strmedications = "select medicationid medication medicationname= ('" + firstcolumn + "')"; sqlcommand cmdmedications = new sqlcommand(strmedications, connection); sqldatareader readmedications = cmdmedications.executereader(); if (readmedications.read())

java - How to change the key of one map corresponding to a value in another map? -

i working on project in having map of string , object coming below method. , suppose if data map contains - a = p b = q c = r d = s e = t f = u g = v h = w = x where a, b, c, d, e, f, g key , p, q, r, s, t, u, v there corresponding values in above map. below method - private void datacheck(map<string, object> data) { } now have static mapping in map of string , string - public static final map<string, string> static_mapping = collections.unmodifiablemap(new linkedhashmap<string, string>() {{ put("a","hello"); put("b","world"); put("c","titan"); put("d","david"); put("e","elephant"); put("f","fire"); put("g","gel"); }}); here value of key a hello , value of key b world , value of key c titan , same thing other key value pairs. now in below method have mentioned above, getting values in map contain data

interactive - Run program from c++ source which required multiple input -

i need run rnaeval (executable) c++ code , read output of rnaeval . found code can run command , read output. string exec(char* cmd) { file* pipe = popen(cmd, "r"); if (!pipe) return "error"; char buffer[128]; std::string result = ""; while(!feof(pipe)) { if(fgets(buffer, 128, pipe) != null) result += buffer; } pclose(pipe); return result; } but rnaeval doesn't take command line argument. instead need provide input after run program (similar bc in linux). example rnaeval [enter] input1 [enter] input2 [enter] return output rnaeval , exit how can c++? system: linux g++ gcc edit string exec(char* cmd) { file* pipe = popen(cmd, "w"); if (!pipe) return "error"; char buffer[128]; std::string result = ""; fprintf(pipe,"%s\n","acgt"); fprintf(pipe,"%s\n","(())"); fprintf(pipe,"%s\n&q

jquery - jsTree TYPE plugin events are ignored -

i unable jstree "types" plugin work in capacity @ all, , there no errors firing anywhere can detect. 1.) referred so question have node open/close mouseclick, function not ever executed. 2.) "types" plugin jstree plugin documentation says this: to set node's type can use set_type or supply type property node's data. i suspect it's setup problem because neither of "types" settings working, yet "contextmenu" plugin work, appears scripts in place , i'm doing wrong "types" has else encountered this, or see i'm going wrong? html <div id="jstree"></div> <script> $(function () { $('#jstree').jstree({ "types" : { "types" : { "series_type" : { "icon" : { "image" : "images/seriesnode.png"

hibernate - EntityManager.flush(), EntityManager.getTransaction.commit(), What is the standard usage ? -

i'm trying understand how synchronisation between persistence context , database works.the code below runs pretty : entitymanagerfactory factory = persistence.createentitymanagerfactory("projecta"); entitymanager em = factory.createentitymanager(); em.gettransaction().begin(); for(string name : names) { student toinsert = new student(); toinsert.setname(name); em.persist(toinsert); } em.gettransaction().commit(); but flush() method goes ? have use ? do have gettransaction.begin() everytime ? what standard form update information in database hibernate ? flush not required commit flush automatically you. need flush when performing long running transaction data needs saved db avoid memory heap (or) if need sync data in session db reason. if feel starting transactions tedious, ma use spring declarative transactions . doing so, spring take care of creating transaction boundaries around method , commits/rolls data depending on happens in

var inside var in oop php -

im biginner in object oriented programming , learning object oriented php , have got bit confused including variable inside variable inside of class, like: $div_content="some content"; $div = '<div>'.$div_content.'</div>'; but when trying this, error: class someclass{ private $div_content ="some content"; public $div='<div>'.$div_content.'</div>'; function __construct(){ echo $this->div; } } can 1 please me understand im doing wrong here? in advance. function __construct(){ $this->div = '<div>'.$this->div_content.'</div>'; echo $this->div; } you can define static values on declarations, use __construct() it

python - Pandas graphing a timeseries, with vertical lines at selected dates -

Image
consider timeseries, cumulative number of edits in wikipedia category. in [555]: cum_edits.head() out[555]: 2001-08-31 23:37:28 1 2001-09-01 05:09:28 2 2001-09-18 10:01:17 3 2001-10-27 06:52:45 4 2001-10-27 07:01:45 5 name: edits, dtype: int64 in [565]: cum_edits.tail() out[565]: 2014-01-29 16:05:15 53254 2014-01-29 16:07:09 53255 2014-01-29 16:11:43 53256 2014-01-29 18:09:44 53257 2014-01-29 18:12:09 53258 name: edits, dtype: int64 i have graph so: in [567]: cum_edits.plot() out[567]: <matplotlib.axes.axessubplot @ 0x1359c810> i plot vertical lines, after every total_edits/n ; e.g. n=10 edits. calculate these easily. in [568]: dates out[568]: [timestamp('2006-06-04 04:46:22', tz=none), timestamp('2007-01-28 23:53:02', tz=none), timestamp('2007-09-16 10:52:02', tz=none), timestamp('2008-04-28 21:20:40', tz=none), timestamp('2009-04-12 22:07:13', tz=none), timestamp('2010-04-09 18

php - How to get the current url in a OpenCart .tpl file? -

i'd current url in .tpl file in opencart. i've seen answer works in php file. i have way: _my_array.push(['_productname',"<?php echo $heading_title; ?>"]); **_my_array.push(['_producturl', ["how can url ?"]]);** thanks to full url <?php $url = "http://$_server[http_host]$_server[request_uri]"; ?> and btw answers work on tpl files because tpl files sort of php files only

javascript - ng-class only for current scope in ng-repeat angularjs -

i'm having trouble ng-class part of angularjs. the thing figured out adding class after success or error allll buttons ng-click on. but want add/change class of clicked element. possible in way? <section ng-repeat="user in users"> <button class="btn" ng-click="myfunction(user);" ng-class="{invalid:errors,done:success}"></button> </section> <script> function userscontroller($scope, $http) { $http.get('/users.json').success(function(users) { $scope.users = users; $scope.errors = false; $scope.success = false; }); $scope.myfunction = function(user) { $http.post('/myurl/'+user.id, student) .success(function(data, status, headers, config) { // $scope.success = true; user.success = true; }) .error(function(data, status, headers, config) { // $scope.errors = true; user.er

linux - UNIX command to search blank word -

in file (tab delimited text, csv or database file) have first name, last name , address. in rows not have last name first name , address there. how can list rows last name blank using unix command? firstname lastname street city dan, god, 1st street, chicago sam, , 2nd street, chicago adam, smith, 3rd street, chicago it csv, tab delimited text file(;,:). answer should 2nd row above. assuming input file csv, can use awk: awk -f, '$2 == ""' file to print rows 2nd columns (last name) blank.

c# - Difference Between DataReader and Dataset? -

i want convert code using dataset . i don't have idea how retrieve data dataset . conn.open(); string strquery = "select * tblclientinfo clientid=" + txtid.text; sqlcommand sqlcmd = new sqlcommand(strquery, conn); sqldatareader sqldreader = sqlcmd.executereader(); if (sqldreader.hasrows) { while (sqldreader.read()) { txtid.text = sqldreader["clientid"].tostring(); txtname.text = sqldreader["name"].tostring(); txtmobile.text = sqldreader["mobile"].tostring(); txtcnic.text = sqldreader["cnic"].tostring(); } } else { messagebox.show("record id" + " " + txtid.text + " " + "not found !"); } sqldreader.close(); conn.close(); do want ? sqldataadapter da = new sqldataadapter(); da.selectcommand.commandtext = "select * tblclientinfo clientid = @id"; da.selectcommand.parameters.addwithvalue("@id", txtid);

Alt codes in batch a file -

Image
according people (and have used before , worked.) can use alt codes in batch this: ░ = ° ▒ = ± ▓ = ² but stopped working? symbols come out lot of spam. help? edit: here how "get alt code in" {link} and image on alt symbols like: it add first symbol. open notepad , click on "encoding" , click on "convert ascii" symbols lost °±² wont display t symbol before it

c# - Merge nodes of the same kind to a single node -

i'm trying merge 2 nodes of same kind single node so having both nodes this <clubs> <spe>accepted</community> <scu>accepted</scu> </clubs> and this <clubs> <bus>declined</bus> </clubs> it become this <clubs> <spe>accepted</spe> <scu>accepted</scu> <bus>declined</bus> </clubs> how achieve such thing? this might you xmldocument mydocument = new xmldocument(); mydocument.load(xmlfile); var nodetoadd = mydocument.childnodes.oftype<xmlelement>().where(nodevariant => nodevariant.name == "clubs").selectmany(o => o.childnodes.oftype<xmlelement>()).tolist(); var nodetodelete = mydocument.childnodes.oftype<xmlelement>().where(nodevariant => nodevariant.name == "clubs"); foreach (var m in nodetodelete) { mydocument.rem

ios - In UIKit, how can I add a UILabel as a subview to a UITextField so that is positioned exactly where the text will be? -

i want add uilabel subview uitextfield . should positioned @ exact same coordinates normal text contents. (i aware of uitextfield.placeholder , not fit requirements.) i have created class inherits uitextfield , assigned text field in storyboard. have added following in initwithcoder method: placeholderlabel = [[uilabel alloc] init]; // set font, color, text [placeholderlabel sizetofit]; // rect useless me :( cgrect frame = [self textrectforbounds:placeholderlabel.bounds]; [self addsubview:placeholderlabel]; i use initwithframe method, instead of init , or set uilabel 's frame property need know gcrect . need calculate hand based on uitextfield 's height, paddings, font size, , possible left view etc?

C++ / Objective-C++ - How can I store a C++ variable in an NSDictionary? -

i have c++ variable of type std::vector<std::bitset<128> > defined , populated in c++ class (which called objective-c++ class.) i store object in nsdictionary - or equivalent of. can't add std::vector<std::bitset<128> > nsdictionary because it's not of type id . so question this: how can achieve same concept? how can store std::vector<std::bitset<128> > in dictionary of sorts? can wrap vector object in id type somehow? if it's not direct dictionary, there method use? need mutable, can add key/object's @ runtime. i'v seen std::map<std::string, std::string> , i'm not sure if it's i'm looking for. nor have found examples on being mutable. does have idea how achieve this? actually nsvalue seems solution. @taum's advice correct cases (when store objects somewhere , sure pointers working). in case you've created object , it's lifetime limited, need push object further, use ns

jquery - Flip! plugin content as a hyperlink -

i'm trying make content of flip! box click-able hyperlink. i'm new jquery, code have: <script type="text/javascript"> $(function () { $("#flippad a:not(.revert)").bind("mouseover", function () { var $this = $(this); $("#flipbox").flip({ direction: $this.attr("rel"), color: $this.attr("rev"), content: $this.attr('title'), }) return false; }); }); </script> <div id="flipbox" >select contact option below</div> <div id="flippad"> <a href="#" class="left" rel="rl" rev="#39ab3e" title="johntk86@gmail.com">email</a> <a href="#" class="top" rel="bt" rev="#66b7d2" title

c# - How do I search for a type in .NET, disregarding the assembly version? -

i want maintain savefile compatibility between multiple versions of program, causes problems serialization, assembly qualified type name changes when increment version number, type.gettype() can't find it. there way search type disregarding assembly version? whenever type not found assembyresolvedevent fired. this event can used check types loaded , return type has same name ignore version number. http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve%28v=vs.110%29.aspx edit : time ago seems not recall correctly. adriano was correct. assemlyresolve ist asking assembly. so additionally serializationbinder needed. sounds work, quite simple! i'll try summarize: private static assembly currentdomain_assemblyresolve(object sender, resolveeventargs args) { if (args == null || string.isnullorempty(args.name)) return null; //if object serialized previous version .dll, deserialze current version .dll (only relevant strong names) foreac