Posts

Showing posts from January, 2011

c# - Saving string with xml -

why if save variables , load them companyname , playername this: system.xml.xmlelement, instead of write? other variables works fine. struggling while, appreciate help, thanks. public void loadgameprefs() { string filepath = "c:/users/gameprefs.xml"; xmldocument xmldoc = new xmldocument(); if(file.exists (filepath)) { xmldoc.load(filepath); xmlnodelist transformlist = xmldoc.getelementsbytagname("gameprefs"); foreach (xmlnode transforminfo in transformlist) { xmlnodelist transformcontent = transforminfo.childnodes; foreach (xmlnode transformitems in transformcontent) { if(transformitems.name == "firststart") { firststart = bool.parse(transformitems.innertext); } if(transformitems.name == "drawfirstgui") { drawfi...

Can Neo4j property order be controlled? -

is there mechanism controlling order of properties? i cannot reproduce in http://www.neo4j.org/console using neo4j 1.9.2 community if following: create (m1 {`$type`: {moduletypename}, name: 'm1', modelnumber: 'mn1'}) then later node cypher query using rest cypher endpoint back... { "extensions": {}, "paged_traverse": "http://localhost:7575/db/data/node/3777/paged/traverse/{returntype}{?pagesize,leasetime}", "outgoing_relationships": "http://localhost:7575/db/data/node/3777/relationships/out", "traverse": "http://localhost:7575/db/data/node/3777/traverse/{returntype}", "all_typed_relationships": "http://localhost:7575/db/data/node/3777/relationships/all/{-list|&|types}", "property": "http://localhost:7575/db/data/node/3777/properties/{key}", "all_relationships": "http://localhost:7575/db/data/node/3777/...

java - Desktop application "internal urls" -

for web applications internal navigation, use urls, url router/dispatcher. is there equivalent pattern/analogy within desktop app being navigation intensive/with multiple views? let's i'm in myapp://view1/subview1?state=somestate , switch in myapp://view2/subview2/, deconstructing in main controller, decodes first part, switches view view2, calls view2 controller "/subview2", loads "subview2", etc. i find kiss (keep simple stupid) abstraction handling "navigation" state. would "pattern" practical or awful idea? what general plan implement in java? (use uris? urls? strings?) application controller pattern might place start.

2 start and 2 end dates difference. sql server -

i have 4 dates. example. 2 start dates , 2 end dates, like: start_date_he 2013-08-15 01:24:00.000 end_date_he 2013-08-15 02:09:00.000 and start_date_lunch 2013-08-14 20:40:00.000 end_date_luch 2013-08-14 21:40:00.000 i wanna know hou many minutes have between these dates. in sample might 0. because 20:40 until 21:40 not between 01:24 until 02:09 here version, seems mess, work values: select l.id lunchid , isnull(datediff(mi, case when l.startdate between h.startdate , h.enddate l.startdate else (case when l.startdate < h.startdate h.startdate else null end) end, case when l.enddate between h.startdate , h.enddate l.enddate else (case when l.enddate > h.enddate h.enddate else null end) end), 0) result lunch l left join h on h.id = 1 or if going use more in 1 query, may better create function create function getbetweenminutes( @hstart datetime, @hend datetime, @lstart datetime, @lend datetime) ret...

json - Backbonejs pass data from one to other view? -

there have 2 views ... need put data 1 view next dont know how can implement . there first function view : var categoriesview = backbone.view.extend({ initialize:function () { this.render(); }, render:function () { var = this; var categories = new categories(); categories.fetch({ success: function (categories) { var template = _.template($('#categories-template').html(), {categories: categories.models}); that.$el.html(template); } }) } }); there template : <script type="text/template" id="categories-template"> <% _.each(categories, function(category) { %> <li><%= category.get('name') %></li> <% }); %> </script> model , collection : var category = backbone.model.extend({ defaults: { name: 'category', id: [] }, }); var categories = backbone.collection.extend({ url: 'ap...

objective c - How to define a method to show up when subclassing a custom class -

i'm not sure title makes sense, i'm having problems asking (and google searching) solution below question in single coherent sentence. i've created custom class sole intention of subclassing it. have single method i'll need override when writing new subclass. i'm looking is, when create new file, , choose custom class subclass i'd new implementation file have empty version of method. similar how init method, or drawrect method (when appropriate) in implementation file when creating new class. does make sense? you can define template in editor that. there no mechanism in objective-c language can that. however, create protocol required method , implement (instead of subclassing existing class), if fits need. gives compile error if forget implement method.

from extjs array grid store, call csv file and store -

i have code upload extjs array grid. in store, don't know how call data csv file have uploaded (without saving). here's controller upload.js: ext.define('application.controller.upload', { extend : 'ext.app.controller', init: function() { this.control( { 'uploadview button': { uploaded: this.uploadedfile } }); }, uploadedfile : function(form) { console.log('uploadedfile called, file: ' + form); ext.create('ext.container.viewport', { items: [ { xtype: 'displayview', store: form //guessing here ****** } ] } ); } }); here's view display.js: ext.define('application.view.display' , { alias : 'widget.displayview', var store = ext.create('ext....

javascript - With three.js, can I attach information to an object, such as a URL? -

i have webgl question related three.js. attach information object. instance, when click on object, retrieve information that's tied object, url, , run function using information. the code i'm using finding object is: var vector = new three.vector3((event.clientx / window.innerwidth) * 2 - 1, -(event.clienty / window.innerheight) * 2 + 1, 0.5); projector.unprojectvector(vector, camera); var raycaster = new three.raycaster(camera.position, vector.sub(camera.position).normalize()); var intersects = raycaster.intersectobjects(objects); intersects[0].object.material.color.sethex(math.random() * 0xffffff); the last line being how i'm manipulating object. array objects array of of objects. issue don't know enough how raycaster or intersectobjects works, or enough how tie information object can recalled later. indeed can set custom user data object in three.js. key here object3d basis scene graph objects. docs have property called ob...

vb.net - form upload get other form variables in asp.net -

i have asp.net form upload box copied msdn. after form submitted, instead of displaying information on page, want page redirect 2 query parameters, filename , number hidden form field, in same form , upload box. how can number after form submits add redirect code. form field name 'id' <script runat="server"> protected sub button1_click(byval sender object, _ byval e system.eventargs) if fileupload1.hasfile try fileupload1.saveas("c:\inetpub\sites\rebbetzin\uploads\" & _ fileupload1.filename) label1.text = "file name: " & _ fileupload1.postedfile.filename & "<br>" & _ "file size: " & _ fileupload1.postedfile.contentlength & " kb<br>" & _ "content type: " & _ fileupload1.postedfile.contenttype response.redirect(...

javascript - How to resize twitter bootstrap popover? -

i using bootstrap in mvc project. have issue bootstrap popover widget. have created custom knockout binding popover widget, here code : check fiddle ko.bindinghandlers.popover = { init: function (element, valuesaccessor, allbindingsaccessor, viewmodel, bindingcontext) { var options = ko.utils.unwrapobservable(valuesaccessor() || {}); options.html = true; options.content = '<small class="text-info">' + 'variable text goes here.variable text goes here.variable text goes here.variable text goes here.variable text goes here. ' + '</small>'; $(element).popover(options); }, update: function (element, valuesaccessor, allbindingsaccessor, viewmodel, bindingcontext) { var extraoptions = allbindingsaccessor().popoveroptions; $(element).popover(extraoptions.observable() ? "show" : "hide"); $(element).siblings(...

visual studio 2012 - dll not being copied to output directory, even with Copy Local flag (<Private>true</Private>) -

we have project called www references project in same solution called framework. framework uses nuget has dependency on nuget package called isynaptic. the framework.csproj xml says: <private>true</private> and visual studio ui says copy local = true. however, when rebuild solution, www/bin not contain dll isynaptic.core. here full xml reference: <reference include="isynaptic.core"> <hintpath>..\packages\isynaptic.core.0.1.3\lib\isynaptic.core.dll</hintpath> <private>true</private> </reference> i've tried permutations in case of case sensitivity: true, true & true additionally, have tried adding dummy class file in framework explicitly uses class isynapticcore.dll using isynaptic; using isynaptic.core; namespace framework.bootstrap { public static class dummy { public static int getcode() { return isynaptic.hashcode.mixjenkins32(0); } }...

excel - JavaScript via Cscript Runtime Error - Odd Expected ';' -

i'm writing basic script sake of data entry excel jscript, , i've run bit of roadblock strange error (the returned error isn't strange, moreso how go fixing it). i'm looking last free row in worksheet checking cells.(i, 8).value see if there 2 consecutive rows empty, break loop retain index i, , perform data entry. while(!data.atendofstream)//looping find data the 5 digit code found above. { var ts = new string(data.readline()); var t=ts.split(","); if(search==t[0]) { var i; for(i=0; i<wks.usedrange.rows.count; i++) { if(wks.cells(i,11).value==null) { wscript.stdout.writeline("empty @ "+i); break; } } //data entry statements etc... } } when compiling through cmd, get: microsoft jscript runtime error: expected ';' returned line on if(wks.cells) line, char 4. i'm not sure if bad programming on part, or i'm overlooking.....

Converting one hash to another hash in ruby -

convert following hash hash. {["2013-08-15", "123", "user1"]=>1, ["2013-08-15", "456", "user1"]=>1, ["2013-08-09", "789", "user1"]=>5} convert above hash to {["2013-08-15", "user1"]=>2, ["2013-08-09", "user1"]=>1} as can see first , second key, value pairs in hash have same date, different account, , same user, in case need count total number of user posts 2 {["2013-08-15", "user1"]=>2} in last key, value pair, count should 1 because user posted 1 account ("789") though there 5 posts {["2013-08-09", "user1"]=>1} . h = {["2013-08-15", "123", "user1"]=>1, ["2013-08-15", "456", "user1"]=>1, ["2013-08-09", "789","user1"]=>5} hash[h.group_by{|k,v| k[0]}.map{|_,v| [v.f...

regex - Preg Replace of image source but not image link in PHP -

i have content in cms database, images have click zoom plugin. the html markup image looks this <div class="large-image-outer"> <a class="fancybox-button zoomer" data-rel="fancybox-button" title="" href="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg"> <div class="overlay-zoom"><img class="large-image img-polaroid" src="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg" alt="" title="" /> <div class="zoom-icon"></div> </div> </a> </div> i'm trying go through database , replace images on page thumbnails. each thumbnail named same image, -thumbnail.jpg on end. in example above <img class="large-image img-polaroid" src="http://images.website.com/prams/folder/e3-v2/review/e3-v2-introduction-1.jpg" alt="" title="...

dataflow - SSIS - How do I join two sources on a complex expression? -

i have 1 data source has column part_number. my second data source has product_family_id, product_id , part_mask. mask pattern string used in expression part_number mask. instance 'nxa%' or '001-[abcd][456]9-121%' usually legitimate part numbers product family based on available product part masks, in instance need go in other direction. based on part number, must find related products in product family , store in summary table. simulating in t-sql: declare @partlist table (partnumber varchar(100)) insert @partlist (partnumber) values ('nxampvg1') select distinct pl.partnumber, match.product_id @partlist pl join ( select m.masks, p.product_id mcs_productfamily_partmasks m join product p on m.productfamilyid = p.productfamily_id) match on pl.partnumber match.masks desired output: part_number product_id ----------- ---------- nxampvg1 15629 nxampvg1 15631 nxampvg1 15632 nxampvg1 15633 nxampvg1 15634 nxampvg1 15635 ...

xml - How to two different tags for images from different feeds as one single tag in yahoo pipes? -

i reading 3 or 4 news rss feeds different websites, , merging them in yahoo pipes. displaying 1 image each news item. facing 2 problems. 1> images provided in different tags in different feeds. different tags images are: <media:content medium="image" url="http://metrouk2.files.wordpress.com/2013/08/1000x67025.jpg?w=150&amp;h=150&amp;crop=1"> <media:title type="html">liverpool v stoke city - premier league</media:title> </media:content> from feed: <media:thumbnail height="340" link="" url="http://www.chelseafc.com/javaimages/4a/7c/0,,10268~12155978,00.jpg" width="640"/ and feed: <enclosure length="150" type="image/jpeg" url="http://u.goal.com/187200/187249_thumb.jpg"/> 2> in of feeds getting 3 or 4 media:content data , of them not images mp3 files.and image related news item not in fixed position. fourth media:content first...

javascript - Gmaps Api 3 set individual icons for markers in an array -

below code, i'd have 3rd setting (link, coordinates, icon) if possible , add loop. each university should have unique icon. see array below. var markers = [ ['<a href="http://www.ship.edu">shippensburg university</a>', 40.06090, -77.52148], ['<a href="http://www.millersville.edu">millersville university</a>', 39.99680, -76.35440], ['kutztown university', 40.50980, -75.78410], ]; function initialize() { var latlng = new google.maps.latlng(40.9, -77.5); var myoptions = { zoom: 7, center: latlng, maptypeid: google.maps.maptypeid.terrain, maptypecontrol: false }; var map = new google.maps.map(document.getelementbyid("gmap"),myoptions); var infowindow = new google.maps.infowindow(), marker, i; (i = 0; < markers.length; i++) { marker = new google.maps.marker({ position: new google.maps.latlng(markers[i][1], ma...

animation - Animate a Histogram in Python -

i'm trying animate histogram on time, , far code have following one: import matplotlib.pyplot plt import numpy np import time plt.ion() fig = plt.figure() ax = fig.add_subplot(111) alphab = ['a', 'b', 'c', 'd', 'e', 'f'] frequencies = [1, 44, 12, 11, 2, 10] pos = np.arange(len(alphab)) width = 1.0 # gives histogram aspect bar diagram ax.set_xticks(pos + (width / 2)) ax.set_xticklabels(alphab) bin_idx in np.linspace(0,1000000,100000000): t = time.time() #here change first bin, increases through animation. frequencies[0] = bin_idx line1 =plt.bar(pos, frequencies, width, color='r') plt.draw() elapsed = time.time() - t print elapsed the code works, outputs shows how after iterations becomes way slower @ beginning. there way speed things up, want update in real time, , process in runs pretty fast. also, important notice, not want post processing animation, want real time updates, h...

validation - Validating a text input to use only lower cases and numbers 0 to 9 when a link is clicked -

i making simple web app reads short urls specific domain , opens short url in existing internet browser. functionality working bit confused on how move forward in adding input validations make system more self service. validate text input field not using form. want text field support small case , numbers 0 9. i've found solutions here in forum not capable of integrating offered solutions because of them use forms , programming skill beginner's level. input field uses link anchor , looks this: <input type="text" id="keyword" placeholder="small letters only" /> <a class="btn" href="http://mysite.com" id="domain"></a> i need add following functions in jquery script: when link clicked, script check if character string provided in "keyword" lowercase , numbers only. if user inputs character other lowercase letters , numbers, alert message pops "invalid character detected. try a...

windows 8 - How to build my own DataGrid for Win8 App Store? -

i have list of items want display in table-like control, win8 app store. lets object item contains barcode, price , amount (all double types). want present table different columns each prop of object. present table in layoutawarepage. ideas? you can start here : how data grid ui collection of items? mytoolkit - datagrid usage of mytoolkit datagrid <controls:datagrid x:name="dg"> <controls:datagrid.columns> <controls:datagridtextcolumn width="200" binding="{binding firstname}" /> <controls:datagridtextcolumn width="200" binding="{binding lastname}" /> </controls:datagrid.columns> </controls:datagrid> protected override void onnavigatedto(navigationeventargs e) { observablecollection<viewmodel> people = new observablecollection<viewmodel> { new viewmodel("fname", "lname"), new viewmodel("fname...

Alert text of span tag inside div with jQuery Droppable -

js fiddle can found here . have 2 sets of divs, ones can draggable , droppable . i'm trying add text inside of span element on array element caused drop event fired cannot cause second drop fired (not pertinent @ moment because doesn't work either). why isn't alert($(this).find("span").text()); finding alerting text of span tag inside element dragged? html <div id="quizcontainer"> <div id="questionscontainer"> <div class="drugquizzes"> <span>docusil</span> </div><div class="drugquizzes"> <span>oracea</span> </div><div class="drugquizzes"> <span>zyloprim</span> </div> </div> <div id="answerscontainer"> </div> <div class="druganswers" style="background-color:palevioletred;...

How to access and make use of html data in django? -

i having hard time figuring out right logic problem, have 3 models, class item(smartmodel): name= models.charfield(max_length=64,help_text="name item e.g hamburger") price=models.decimalfield(max_digits=9,decimal_places=2) optionalitems = models.manytomanyfield('optionalitems.optionalitemcategory',null=true,blank=true) class optionalitems(smartmodel): """optional items belong item e.g topping belongs pizza""" name = models.charfield(max_length=20, help_text="item name.") price = models.decimalfield(max_digits=9, decimal_places=2, null=true,blank=true) class optionalitemcategory(smartmodel): """category optional items belong""" title = models.charfield(max_length=20,help_text="category name") optional_items = models.manytomanyfield(optionalitems) in template, {%for optionalcategory in optionalcategories %} <h5 id="blah"...

How to pull a git repository from remote server? -

i've seen few similar questions asked, didn't me figure out, , couldn't find tutorials (i wasn't sure looking for, honest). also, haven't used git apart pulling/pushing onto github, why (at least believe so) confused! github made me spoiled setting repo up! what did on server: sudo apt-get install git installed (i think) needed proceed. i created test repository (just few txt , html files) inside git_test git init git add . git commit i used vim .git/description change description starships . what did computer i have git pre-installed git clone destielstarship@ [remote_server] /starships 1 which produced error: fatal: unable destielstarship@ [remote_server] (port 9418) (a non-recoverable error occurred during database look-up. ) i replaced ip address [remote_server] clarity, hope didn't make more confusing. update: whoops! fixed awkward typo! tl;dr unless you're running git-daemon on remote server, want use ssh...

django - Creating multiple instances of the same model from one form -

so have model member : class member(models.model): first_name = models.charfield(max_length = 15) last_name = models.charfield(max_length = 15) house = models.foreignkey('house', null = true) created_on = models.datetimefield('created on') user = models.onetoonefield(user, null = true) and form create model: class memberform(forms.form): first_name = forms.charfield() last_name = forms.charfield() email_address = forms.emailfield() my app works create house , specify number of members in house. that's far have working, continue new page displays appropriate number of forms (one each member), , creates member instance each supplied data. i'm confused how access data each form, since they're technically in same html form. more how identify email field goes first name field , on. appreciated, thanks. this formsets for. note creating member memberform easier if used model forms (and model formsets).

javascript - How do I execute a "CONTINUE" statement inside a ".EACH" function of jQuery? -

please refer comment inside code below: $('#btndelete').on('click', function() { var treeview = $("#treeview").data("kendotreeview"); var userid = $('#user_id').val(); $('#treeview').find('input:checkbox:checked').each(function() { debugger; var li = $(this).closest(".k-item")[0]; var notificationid = treeview.datasource.getbyuid(li.getattribute('data-uid')).id; if (notificationid == undefined) { //if notification id "undefined" here, want ".each" 'loop' continue next item. } $.ajax( { url: '../api/notifications/deletenotification?userid=' + userid + '&notificationid=' + notificationid, type: 'delete' }).done(function() { var treeview = $("#treeview").data("kendot...

jquery - JavaScript get JSON from rest API without re-rendering the page -

problem i'm trying query rest api in javascript , use jquery parse , insert results webpage. when query made believe submits search form , re-renders page removing of elements queried , inserted. is there away json object rest api , not re-render webpage? here's i'm using make requests: function get_data(){ var url = "www.rest_api/search_term&apikey=my_key" var xmlhttp = null; xmlhttp = new xmlhttprequest(); xmlhttp.open( "get", url, false ); xmlhttp.send( null ); return xmlhttp.responsetext; } the search term comes simple input form, , submitted when submit button clicked. goal keep webpage single page , avoid results page. what i've tried i can't return json object get json data external url , display in div plain text http://api.jquery.com/jquery.getjson/ request url example: http://woof.magnify.net/api/content/find?vq=karma&per_page=5&page=1&sort=popularity&key=84lthnzq1364...

sql - trigger creation gives error -

i have sql server management studio 2012 , im trying create trigger on existing database, test created table "prueba" , im trying set trigger (by right clicking database, calle veritrax , hitting "new query"). query: create trigger items_insert on [dbo.prueba] insert set xact_abort on insert openquery(webdb, 'select * prueba') select id, name inserted go however, i'm getting error: *msg 8197, level 16, state 4, procedure items_insert, line 1 object 'dbo.prueba' not exist or invalid operation.* what wrong query? appreciated edit: oh god, sorry pasted old error message, error made reference prueba.dbo not tlbaccessareas! old question, i'm surprised nobody spotted it. dotted notation not correct, i.e.: [dbo.prueba] should [dbo].[prueba] : create trigger items_insert on [dbo].[prueba] insert set xact_abort on insert openquery(webdb, 'select * prueba') select id, name inserted go

android - How to change/customize getItem method in custom array adapter? -

i want make custom getitem method in custom adapter class. however, when replace default getitem custom one, error tells me tht have implement default getitem method because extend baseadapter. when have both of them in there, still returning null when use in activity. public imageview getitem(int rownum, int columnnum) { return gridcontent[rownum][columnnum]; } public object getitem(int i) { return null; } you have class extends arrayadapter a specific type belive in case imageview :-? try : public t getitem(int rownum, int columnnum) { return gridcontent[rownum][columnnum]; }

python - Not able to give inputs to subprocess(process which runs adb shell command) after 100 iterations -

i want run stress test adb(android debug bridge) shell. ( adb shell in respect command line tool provided android phones). i create sub-process python , in subprocess execute 'adb shell' command. there commands has given subprocess providing via stdin proper of sub process. everything seems fine when running stress test. after around 100 iterations command give stdin not reach subprocess. if run commands in separate terminal running fine. problem stdin. can tell me doing wrong. below code sample class adb(): def __init__(self): self.proc = subprocess.popen('adb shell', stdin=subprocess.pipe, stdout=subprocess.pipe, stderr=subprocess.stdout, shell=true,bufsize=0) def provideamcommand(self, testparam): try: cmd1 = "am startservice -n com.test.myapp/.adbsupport -e \"" + "command" + "\" \"" + "test" + "\"" cmd2 = " -e \"" + "param" + ...

SQL Update a DateRange table from a SUM query of another table -

table daterangetab (fromdate, todate, totalvalue) has data such as: 2010-01-01, 2011-01-01, 0 2010-01-01, 2012-01-01, 0 etc (i.e lots of date ranges 0 in totalvalue column) i have table valuetab (dateofvalue, value) has data such as: 2010-01-02, £25 2011-01-01, £45 2011-05-04, £65 etc (i.e. lots of different rows dates , value each date) i need update daterangetab totalvalue column sum of value valuetab table dateofvalue falls in range fromdate - todate. i tried following : update daterangetab set totalvalue = a.value (select sum(value) value valuetab vt join daterangetab dt on vt.dateofvalue between dt.startdate , dt.todate) but puts same total in each row of daterangetab. hope can or direct me post related answer. thanks try this: update daterangetab set totalvalue = (select sum(value) valuetab dateofvalue between a.fromdate , a.todate group dateofvalue) i cannot test approximat...

Android Bluetooth SCO with Nissan car radio -

before details, little context: car: nissan note (uk 2011 model) device: nexus 4 os: android 4.3 stock i'm trying create app speech recognition , synthesis in car while phone connected on bluetooth. car audio system not provide it's own voice recognition, instead delegates phone triggering intent android.intent.action.voice_command the default app on device handling google search app, has specific activity hands-free dialling. app has terrible speech recognition demonstrate how system supposed work - when activated car displays "voice recognition active" on phone screen while app running, , hides when app exits. the problem have while can make label appear calling audiomanager.startbluetoothsco() , play audio through car speakers , record through car microphone, audiomanager.stopbluetoothsco() not disable mode in car, , remains displaying 'voice recognition active'. problem since car not launch app until bluetooth connection has been closed , r...

How to programmatically create a Drupal Commerce product with price -

i creating drupal commerce product in code using following: $cp = commerce_product_new('product'); $cp->is_new = true; $cp->revision_id = null; $cp->uid = 1; $cp->status = 1; $cp->created = $cp->changed = time(); $cp->sku = $product[sku]; $cp->title = $product[name]; $cp->language = language_none; $cp->commerce_price->amount = $product[sale_price] ? $product[sale_price] : $product[retail_price]; $cp->commerce_price->currency_code = 'usd'; commerce_product_save($cp); if comment out 2 lines pertaining price, product gets added, has no price. if not comment out 2 lines, 500 error if change pricing part be: $cp->commerce_price = array( 'amount' => $product[sale_price] ? $product[sale_price] : $product[retail_price], 'currency_code' => 'usd', ); i not 500, message warning: invalid argument supplied foreach() in _commerce_price_field_serialize_data() (line 148 of commerce/modules/pri...

How do I avoid AngularJS in inline javascript calls? -

i new angularjs , mv* patterns in javascript. i've been playing around angularjs on project , curious how avoid situation doing things <a ng-click="dosomething()"></a> ? don't javascript in html. want able control javascript javascript files rather html files. there better way handle type of stuff along lines of how can specify class or id supposed have behavior associated in angularjs? you can encapsulate own behavior using directives , setup bindings events on elements call function if want wrap behavior (i believe read ben nadel angularjs blogger does... http://www.bennadel.com/blog/2446-using-controllers-in-directives-in-angularjs.htm ). as stated in comment though don't find issue, if on larger team potentially see desire leave binding javascript developer , not have html developer worry details , use directives seeing how write both parts don't have issue. directives way teach html new tricks. during dom compilation dire...

Wordpress custom post type capabilities, admin can't edit post type -

i'm having wired problem wordpress. below code events post type, works without capabilities when capabilities added default roles (admin, editor, etc...) cant use post type. admin role able see custom taxonomies. i have custom user role "edit_events => true" user role able submit events review. want, built in roles can't see post type! i've tried every capabilities tutorial find, seem pretty same , can't how of them differ code. function register_custom_event_type() { $labels = array( 'name' => _x('events', 'event'), 'singular_name' => _x('event', 'event'), 'add_new' => _x('add new', 'event'), 'add_new_item' => _x('add new event', 'event'), 'edit_item' => _x('edit event', 'event'), 'new_item' => _x('new event', 'event'), 'view_item' => _x('view e...

Taking a screenshot with C# WebBrowser doesn't work properly on windows server 2012 -

i've written function uses webbrowser screenshot of web page in c# mvc application(this reference of code used http://www.codeproject.com/articles/95439/get-asp-net-c-2-0-website-thumbnail-screenshot ). in more details, on web page i'm going capture there youtube iframe , need preview of video captured on screenshot. when run function on computer(os windows 8) works properly, when run function on published project(on windows server 2012) iframe on screenshot not captured(is blank). i think probabily issue related in ie10 on windows server, since use webbrowser. i tried set configuration of ie on server in computer, , tried install flash player on server doesn't work. does have suggestions? thanks. edit: * solution found: * found solution. according topic: http://social.technet.microsoft.com/forums/windowsserver/en-us/c26bd4c9-d8dc-4d3b-9fdb-a9750508951c/adobe-flash-v113370178-not-properly-working-in-server-2012-rp i've installed "desktop experien...

what has changed about groovy class properties after the GINA book? -

i reading groovy in action (gina) book. in chapter 9, there listing: class myclass { def first = 1 def getsecond() { first * 2 } public third = 3 } obj = new myclass() keys = ['first', 'second', 'third', 'class', 'metaclass'] assert obj.properties.keyset() == new hashset( keys ) // fail however, following assert right one: keys = ['first', 'second', 'class'] assert obj.properties.keyset() == new hashset( keys ) so, has changed groovy class properties after gina book? thank you. from forum book , looks bit error, or changed , no 1 sure what. you're better getting access meap second edition of book covers groovy 2

c - Bitwise AND behaves differently than expected? -

#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int = 50; // 110010 int b = 30; // 011110 if (a & b) { printf("hi"); } return 0; } the code above prints hi. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int = 50; // 110010 int b = 13; // 001101 if (a & b) { printf("hi"); } return 0; } the code above doesn't print anything. logically, think bitwise , mean digits in binary have match in order return true. instead, in reality, each digit in binary have different condition return false. i don't understand point of bitwise and. i understand false equivalent 0 in c. this purpose of bitwise and. it's used bit testing masks. net effect keep common 1s , 0 out else. say, instance want test if 3rd bit 1, can write if ( & 4 /*0100*/ ) // as karthik said there other methods compare operan...

math - how to round an odd integer towards the nearest power of two -

add 1 or subtract 1 odd integer such result closer nearest power of two. if ( ??? ) x += 1; else x -= 1;// x > 2 , odd for example, 25 through 47 round towards 32, adding 1 25 through 31 , subtracting 1 33 through 47. 23 rounds down towards 16 22 , 49 rounds towards 64 50. is there way without finding specific power of 2 being rounded towards. know how use logarithm or count bits specific power of two. my specific use case in splitting odd sized inputs karatsuba multiplication. if second significant bit set add, otherwise subtract. if ( (x&(x>>1)) > (x>>2) ) x += 1; else x -= 1;

How do I filter nested cases to be filter out python -

i have ascii plain text file input file main case , nested case below: want compare instances start '$' between details , @extendedattr = nvp_add functions in input file below each case under switch($specific-trap), when run script under section python script, nested cases print out, dont want nested cases print out here , script consider cases under switch($specific-case). how should help! : input file: ************ case ".1.3.6.1.4.1.27091.2.9": ### - notifications jnpr-timing-mib (1105260000z) log(debug, "<<<<< entering... juniper-jnpr-timing-mib.include.snmptrap.rules >>>>>") @agent = "jnpr-timing-mib" @class = "40200" $option_typefieldusage = "3.6" switch($specific-trap) { case "1": ### trapmsgntpstratumchange ########## # $1 = trapattrsource # $2 = trapattrseverity ########## ...

Timing for loop changes when using other functions in the computer Jquery -

i have pulsing animation in jsfiddle http://jsfiddle.net/upbdw/8/ when use on own, works fine. problem i'm having when start browsing web, open itunes or whatever else while window still open, timings of pulses start fluctuate. the function pulses this: function fadeitin() { window.setinterval(function(){ // fade ins $('#child4,#child4c').fadein(175); settimeout(function () { $('#child3,#child3c').fadein(175); }, 175); settimeout(function () { $('#child2,#child2c').fadein(175); }, 350); settimeout(function () { $('#child1,#child1c').fadein(175); }, 525); settimeout(function () { $('#child,#childc').fadein(175); }, 700); // fade outs settimeout(function () { $('#child,#childc').fadeout(175); }, 875); settimeout(function () { $('#chi...

How to declare an array of objects C# -

i'm making 2d tile map game. have cell class (tiles) makes cell objects have 4 attributes: topwall, bottomwall, leftwall, rightwall. wall may or may not there, attributes boolean true or false, , if true, line drawn down cell wall (not allowing player pass through cell). want declare (2 dimensional? in, row, , column) array of cell objects called map1 (as make game map). want set each member of array having specific wall attributes. here have: cell.cs using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace map { public class cell : picturebox { bool leftwall; bool topwall; bool rightwall; bool bottomwall; public cell(bool topwall, bool rightwall, bool bottomwall, bool leftwall) { this.topwall = topwall; this.rightwall = rightw...

Rails: multiple-class methods -

i'm presenting users list of assets they've created. can different classes, , each has edit button. what'd best way write method takes user correct edit form depending on class is? something i'm thinking: def edit_asset(class, id) if class == 'photo' redirect_to edit_photo_url(id) elsif class == 'audio' redirect_to edit_audio_url(id) elsif ... ... end end is there better way this? should method go? thanks! edit i forgot mention classes either classes or subclasses. you can link_to 'edit', [:edit, @object] , assuming @object listed resource in routes file.

javascript - Using Q library in browser -

i need use q library ( http://documentup.com/kriskowal/q/ ) in browser. use requirejs load library, don't have idea how this. know how load own module, can't q . has function: (function (definition) { //some code here*** // requirejs } else if (typeof define === "function" && define.amd) { define(definition); how can load q , use in module? you can load q library using script statement in html <script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.1.0/q.js"></script> then can access via q variable so: function square(x) { return x * x; } function plus1(x) { return x + 1; } q.fcall(function () {return 4;}) .then(plus1) .then(square) .then(function(z) { alert("square of (value+1) = " + z); }); see running @ http://jsfiddle.net/uesyd/1/

$.ajax()function with json data from javascript array to a php processing file -

i trying use json first time $.ajax() got values of checkboxes , other needed data php file processing , posting mysqldb through array data section of $.ajax() function empty array[] on php file. when try using javascript debugging tool browser got reprot **uncaught syntaxerror: unexpected end of input jquery-1.9.0.min.js:1 st.extend.parsejson jquery-1.9.0.min.js:1 (anonymous function) index.php?url=account/registration/:297 st.event.dispatch jquery-1.9.0.min.js:2 y.handle** the array produced looks @ console log [checkbox1: "com 101", semester: "1st semester", mid: "7", checkbox2: "com 112", checkbox3: "sta 111"…] checkbox1: "com 101" checkbox2: "com 112" checkbox3: "sta 111" checkbox4: "sta 112" checkbox5: "mth 111" length: 0 mid: "7" semester: "1st semester" on php processing file did print_r on json data got array[] result this javascript code bl...