Posts

Showing posts from April, 2014

iphone - MonoTouch CoolStorage OneToMany caching issue -

i'm experiencing issue coolstorage onetomany relationship being cached when reading list first time, list fails update when data changes later. when restarting app list correct, must caching issue , can't find solution in coolstorage documentation or anywhere. i've pasted unit test code below. i have game class has opponent of type person. there many games, , person can opponent many games. my person class has cslist called opponentgames, @ anytime person can 'get games person opponent'. in unit test first time reference 'person.opponentgames.count', correctly tells me there 1 game. after creating second game , adding person opponent, still reports 1 game opponentgames. if remove first count, test passes, first check result being cached , there it's not updated. i'll appreciate suggestions!! thanks. the sql (sqlite3) setup: csdatabase.executenonquery( "create table person " + "(serverid integer primary k

box api - message: "Invalid value 'xxx'. Entity body should be a correctly nested resource attribute name/value pair" -

when try recieve list of folders message: "invalid value 'authorization=bearer xxx'. entity body should correctly nested resource attribute name/value pair". 1. url https://api.box.com/2.0/folders 2. post request 3. content-type: json or x-www-form-urlencoded 4. authorization:bearer 5iv0..... invalid value 'authorization=bearer xxx'. entity body should correctly nested resource attribute name/value pair this indicates you're sending authorization header in body of request. haven't provided context around how you're making http requests, should 'how set http headers' whatever language/module you're using see how correctly.

seek better design to have multi-dispatching with java -

in language not supporting multiple dispatching, such java, code /* example using run time type comparison via java's "instanceof" operator */ interface collideable { void collidewith(collideable other); } class asteroid implements collideable { public void collidewith(collideable other) { if (other instanceof asteroid) { system.out.println("aaaaaa"); } else if (other instanceof spaceship) { system.out.println("bbbbbb"); } else if (other instanceof plane) { system.out.println("ccccccc"); } } } class spaceship implements collideable { public void collidewith(collideable other) { if (other instanceof asteroid) { system.out.println("ddddddd"); } else if (other instanceof spaceship) { system.out.println("eeeeeee"); } else if (other instanceof plane) { system.out.println("fffffff"); } } } class plane implements col

python - Disabling Javascript after page has been rendered in Selenium Webdriver -

i'm using python. i've seen how can disable javascript in firefox selenium? says create profile load driver profile. want disable javascript after page has been rendered means can't recreate driver. i've tried following: browser = selenium.webdriver.firefox() browser.get('http://wwwhatever.com') browser.firefox_profile.set_preference('javascript.enabled', false) browser.firefox_profile.update_preferences() but this: print browser.capabilities['javascriptenabled'] true furthermore, rest of test still acts javascript enabled. it possible quickjs extension - https://addons.mozilla.org/en-us/firefox/addon/quickjs/?src=search . extension add ctrl+q shortcut disable javascript. here code: profile = selenium.webdriver.firefoxprofile() profile.add_extension("addon-8753-latest.xpi") #quickjs extension browser = selenium.webdriver.firefox(profile) browser.get('http://wwwhatever.com') #turn of javascript, send ct

c# - Unity Ioc Configuration Error -

i have following problem: i using ioc unity c#. case implements ioc following: using microsoft.practices.unity; using microsoft.practices.unity.configuration; namespace tanspritr.ioc { public class ioccontainer { private static readonly ioccontainer contenedor = new ioccontainer(); private readonly iunitycontainer unitycontainer; private ioccontainer() { unitycontainer = new unitycontainer(); unitycontainer.loadconfiguration("micontenedor"); } public static ioccontainer contenedor { { return contenedor; } } /// <summary> /// create instance of object implements tservicio. /// </summary> /// <typeparam name = "tservicio">type of service want resolve</typeparam> /// <returns></returns>

Blank Screen on Preview Sencha Architect 2 -

i created project , on first preview it's showing blank screen, simple project, no codes, steps in sequence: i add 2 form panels, named them, created add 2 buttons on mainpanel, , them created navigationview , linked mainpanel on mainnav (navigationview). here project on deposit files download

html - Text not aligned horizontally in li -

Image
hi using below code , text not getting aligned horizontally within li. html code: <body> <div id="image_header"> <img src="header.jpg" width="500" height="54" /> </div> <div id="header"> <div id="left_panel"> <h2 id="heading" align="cente">welcome <br /> center</h2> <div id="image_src" align="center"> <img src="doc_image.jpg" align="middle" /> </div> </div> <div id="right_panel"> <p><strong> xxx</strong> </p> </div> </div> <div id="footer"> <div id="left_footer"> <div id="img_left"> <img src="separator_bar.jpg"/> </div> <div>help topics &nbsp;&nbsp;&nbsp;</div> <br /> <div id="left_list"> <ul > <li&g

javascript - jQuery function prevents add / remove class on click -

i'm trying have div new class (which makes expand) when being clicked, , old class (which makes close) when clicking on cancel link inside div. <div class="new-discussion small"> <a class="cancel">cancel</a> </div> <script> $('.new-discussion.small').click(function() { $(this).addclass("expand").removeclass("small"); }); $('a.cancel').click(function() { $('.new-discussion.expand').addclass("small").removeclass("expand"); }); </script> now, adding expand class works flawlessly, closing panel after clicking on cancel link works when remove code: $('.new-discussion.small').click(function() { $(this).addclass("expand").removeclass("small"); }); so guess must preventing second function work, can't figure out why. any ideas? thanks! try this $('a.cancel').click(func

c# - How would you test it? How many tests? -

i have class (it's more pseudocode) public class roles { private processdata processdata; roles(processdata pd) { processdata = pd; } public string[] getloginsthatcancallaction(string actionname) { return getpeoplethatcancallactionfromdb(actionname) .union(processdata.processowner) .union(getfromdb(role.administrators); // there may many more union(xyz) calls here .toarray(); } // can refactor methods mockable private getpeoplethatcancallactionfromdb(...) private getfromdb(...) } now question is. write 1 test each union call in getloginsthaatcanrunaction method? or is enough write 1 test , assert method returns logins returned methods called inside getloginsthatcancallaction. i can see reasons both ways. maybe convince me on or other solution. edit: think wasn't clear question: wanted ask if write test var pd = new processdata() pd.processowner = "owne

android - Get days until date based on timezone on phone -

i´ve been trying figure out while can not wrap head around it. i´m working on android app , want display left specific date, , want number of days based on time zone have set on phone. i have joda time in app , information have example: 2013-05-05 9.00pm time in pst (gmt-8) timezone, have no clue how , have searched both on google , can not clear answer. edit i managed solve problem code found here on so string datestring = airdate + " " + airtime.touppercase(); simpledateformat sourceformat = new simpledateformat("yyyy-mm-dd k:mma"); sourceformat.settimezone(timezone.gettimezone("gmt-8")); date parsed; parsed = sourceformat.parse(datestring); timezone tz = timezone.getdefault(); simpledateformat destformat = new simpledateformat("yyyy-mm-dd"); destformat.settimezone(tz); result = destformat.format(par

javascript - Mustache renders actual HTML tags in the dom? -

i have simple mustache function grabs template, process , use $().append insert need to. the problem renders html tags instead of text. instead of : paragraph1... paragraph2... it (actually shows html tags): <p>paragraph1</p> <p>paragraph2</p> my mustache function: $.get(baseurl+"js_temp/template.html", function(templates) { tab.append(mustache.render(templates, templatedata)); }); template.html: <div> {{content}} </div> pretty standard stuff... , worked fine until 2 days ago... , can't figure out have done cause this. can point me in right direction of why might happening? thank you! perhaps try using 3 {{{content}}} ? all variables html-escaped default. if want render unescaped html, use triple mustache: {{{name}}} . can use & unescape variable. i got on git repo mustache.

jQuery mobile: ajax form submission + disable enter key to submit form -

i trying learn bit of jquery mobile preparing little form , want disable enter key submit form. here's tried: $('#form').submit(function(e) { e.preventdefault(); // don't submit multiple times this.submit(); // use native submit method of form element $('#field').val(''); // blank input }); // validate , submit form $("#page").live("pageinit", function () { $("#form").validate({ submithandler: function(form) { // other stuff valid form $.post('insert.php', $("#form").serialize(), function(data) { $('#results').html(data); but every time press enter form submitted anyway... what doing wrong? i've resolved way (i have no checkboxes in page): $(document).bi

ascii - Batch file to add echo to each newline in text file -

i'm trying append echo each new line in text file... since text file has on 250000 lines don't see feasible go through , add them individually. have experience in field share knowledge of how this... i'm trying create artwork ascii characters , didn't realize until after done wanted echo out each line... please if can... example of part of artwork text file: ...................................................................................................................................................... ........................................................................................................................................................................................................ ........................................................................................................................................................................................................ ..............................................................

reconnect default database man studio SQL express (4064 error) -

i have sql server 2008 express , management studio installed on laptop i error: cannot open user default database. login failed i've been googling hours trying resolve i'm out of depth i can't log on master or other database. i sure have disconnected default database. how / reconnect it?

ios - Display HTML file using UIWebView that has subdirectories and external js/img files -

Image
in objective c, want display website have built using uiwebview. brief overview: have folder has index.html. inside folder, there "img" folder , "js" folder. js folder has many .js files. img folder has many images. can run page independently (outside of xcode) no problem. now able create basic html file, store in same directory of .h , .m files, , display correctly. goal display website subdirectories explained above. here i've got far: xcode: - (void)viewdidload { [super viewdidload]; nsstring *path = [[nsbundle mainbundle] path:@"index" oftype:@"html"]; nslog(path); nsstring *content = [nsstring stringwithcontentsoffile:path encoding:nsasciistringencoding error:nil]; nsurl *baseurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]]; [self.webview loadhtmlstring:content baseurl:baseurl]; } here file structure looks like: when run it, build succeeds. nothing displayed. in addition, can c

wcf - Does using a custom ServiceHost disable simplified configuration? -

i have one-time initialization tasks on service startup, , in order have defined custom servicehostfactory , servicehost override initializeruntime. service1.svc markup: <%@ servicehost language="c#" debug="true" factory="service.our_service_host_factory" service="service.service1" codebehind="service1.svc.cs" %> service host definitions: public class our_service_host_factory : servicehostfactory { protected override servicehost createservicehost(type servicetype, uri[] baseaddresses) { return new our_service_host(servicetype, baseaddresses); } } class our_service_host : servicehost { public our_service_host(type servicetype, uri[] baseaddresses) : base(servicetype, baseaddresses) { } protected override void initializeruntime() { // 1 time setup code } } snippet web.config: <system.servicemodel> <behaviors> <servicebehaviors> <b

jquery - disable button until input and file fields have got value -

i have got form here: <form action="#" method="post"> text: <input type="type" name="text" id="text" /><br /> file: <input type="file" name="fileinput" id="fileinput" /><br /> <select name="cars"> <option value="volvo">1</option> <option value="saab">2</option> <option value="mercedes">3</option> <option value="audi">4</option> </select><br /> <input type="submit" value="submit" disabled /> </form> <div id="result"></div> and want disable submit button until fields(including dropdown) have been filled out or chosen. my code is: $(document).ready( function() { $('form > input').keyup && $('input:file').change(function() { var empty = false

iphone - iOS Overlay view which always sits on top? -

i haven't been able find on , feel isn't possible in simple manner. can have view, such loading bar example sits on every other view controller until choose dismiss @ same time underlying view can still interacted with? sort of acting system view. persistent when presenting new view controllers , all. thanks. add subview of window . this: uiview *myview = ... [self.window addsubview:myview];

php - Ajax request on wordpress returns 404 error -

on function.php file on custom theme folder have this: function getprices(){ $price = get_post_meta($_request["post_id"], "price_one", true); $results['price'] = $price; $results = json_encode($results); die($results); } add_action('wp_ajax_getprices', 'getprices'); add_action('wp_ajax_nopriv_getprices', 'getprices'); and on js file had this: $('ul.people_adult li').click(function(){ var post_id = $("#post_id").val(); jquery.ajax({ type:"post", datatype : "json" url: "http://localhost/wordpress/wp-admin/admin-ajax.php", data: { action: 'getprices', post_id: post_id }, complete:function(data){ console.log(data.price);

javascript - How to load div with dynamic content in jQuery -

i load content dynamically using jquery mobile. the alert displays not display content. however, if load file disk in browser works okay, if load server not load div. i validated page content on server using w3c validator. appreciated. here's javascript: $(document).on('pagebeforeshow', '#privacy', function(){ $('div#privacy_load').load('http://example.com'); alert('privacy'); /* displays ok */ }); here's html <div class="container" data-role="page" id="privacy"> <div data-role="header"> <h1>privacy</h1> </div> <div data-role="content"> <div id="privacy_load"></div> <!-- content not display --> </div> </div> update: this not work: <div id="terms_load"></div> <script>alert('alert'); /* alert shows ok */ $("

java - What does it mean to call a class as a function? -

i'm porting code java (i know nothing language) c. fact java c-like language, have no problem in converting statements. have no idea parts of code mean. calls java class function , pass parameter: assume classes be: public class foo { public foo(typex x) { //etc } } public class baa { public baa(typex x) { //etc } } from class it's called as: new foo(baa()) what mean? this wrong ! new foo(baa()) you cannot in java, instead need new foo(new baa().bar()) . this means first create reference (object) of baa , call bar() method of reference. remember new keyword in java create new reference out of class. calls constructor method of class , allocates memory reference. further in above case passes whatever returned bar() method argument foo class , in turn create reference of foo class too. this start : [1]: http://docs.oracle.com/javase/tutorial/java/javaoo/index.html

opengl - Placing multiple images on a 3D surface -

if place texture on surface of 3d object, example cube, use vertices of cube describe placement of texture. but if want place multiple separate images on same flat surface? or suppose 1 image, don't want appear @ edges of surface, vertices are, rather somewhere small , in middle of surface. want actual images chosen , placed dynamically @ runtime, otherwise condense them offline single texture. i have approach want seek advice whether there better method, or if acceptable : my guess create multiple separate 2d quads (with depth of 0), each texture associated them , placed on them (they of course texture atlas different texture coordinates). then, transform these quads such appear on surface of 3d object, such cube. of course i'd have maintain matrix hierarchy these quads transformed appropriately whenever cube transformed, such appear attached cube. while isn't hard, new texturing , know if normal practice this. but if want place multiple separate

html5 - How to create an interactive circular links using CSS -

Image
i wish similar this, http://timheuer.com/blog/archives.aspx need create interactive circular links using css. there number of ways can achieve effect. page in question looks uses image background in css style. simplest example is; 1 image background #link1 { background-image: url('/images/button1-trans.png') } #link2 { background-image: url('/images/button2-trans.png') } #link1:hover { background-image: url('/images/button1.png') } #link2:hover { background-image: url('/images/button2.png') } 1b image spriting using multiple images requires multiple browser requests 'image spriting' technique commonly used these-days optimise download single request cached resulting in single 304 response. in tim's case, looks (although original transparent); then use same image each link along clipping , offsetting locate appropriate part of image; #links { background-image:url('/images/allbuttons.png

asp.net mvc - InsufficentExecutionStackException in MVC Razor file -

so trying work asp net mvc 4.5 , working inside login razor view. page different rest have @ top @model hsserver.models.loginmodel @{ viewbag.title = "log in"; layout = null; } with layout = null; not use master page. i try run application , throws insufficentexecutionstackexception on line layout = null; , says insufficient stack continue executing program safely. can happen having many functions on call stack or function on stack using stack space. can tell me going on! edit it appears not related layout = null removing did not , moved error 1 line. still digging. got it. duplicated this without knowing it. in body calling @html.action("login") , not @url.action("login") meant to. page recursively calling instead of giving url... whoops.

python 3.x - allow input to be 2.d.p, if not prompt error msg -

i want make sure when user inputs exchange rate , amount, can input 2.d.p, if input not 2.d.p there must error message. how can without messing code? check if number rounded 2 dp same number: x = float(input(prompt)) if round(x, 2) != x: # x has more 2 dp also, money applications, consider using decimal module - works same way: from decimal import decimal x = decimal(input(prompt)) if round(x, 2) != x: # x has more 2 dp except avoids floating point representation issues, once start doing arithmetic numbers.

c++ - Trouble rendering quake 3 maps -

recently i've been working on quake 3 bsp loader while. cannot faces render correctly. http://postimg.org/image/o2lf8vlp9/ here vertices map. here's happens when render faces on map. http://postimg.org/image/6hmoht7ep/ this code rendered. void bsp::render() { ( int j = 0; j <= bsp::lumps[13].length/sizeof(bspface); j++)//read until end of lump { if ((bsp::faces[j].type == 1)||(bsp::faces[j].type == 3)) // 1=polygon, 2=patch, 3=mesh, 4=billboard { glfrontface(gl_cw); glbegin(gl_triangle_strip); ( int k = 0; k <= bsp::faces[j].numofverts - 1; k++)//read until end of lump { glvertex3f(bsp::vertices[bsp::faces[j].vertexindex+k].position.x, bsp::vertices[bsp::faces[j].vertexindex+k].position.y, bsp::vertices[bsp::faces[j].vertexindex+k].position.z); } glend(); } } } here's full source #include <stdio.h>

javascript - How to change the text of a radio button when other button is selected -

i creating web store , want know how use javascript change text associated radio button depending on button selected. web store has configuration options, want know how make when 1 option selected, price difference other options displayed next options. likewise, want price difference options display when user checks radio button not default. how can this? information helpful.

.net - Facade design pattern with states -

after implementing facade hide complex sub systems, end having single class client. problem single class still has on 100 apis. seems against cohesive principle. facade class manages states objects used among sub systems can hided. system consist of sub-systems(e.g. project, policy, user, permissions etc) think might able design facade in more modular way. design patterns may work facade in case? as say, having more 100 apis in 1 class not idea. can split different facade classes. common functionality can moved base classes. not design pattern core of oo. state can still maintained. not sure if using session store save state. if can still continue so. you can use cache store state or use database. if using ejbs sfsb provides functionality.

struts2 - How to Integrate Struts Conventions with Tiles such that the benefit of conventions is maintained -

how integrate struts conventions tiles while maintaining conventions benefits? the issue conventions links url-to-action-to-result automatically , nicely jsp, velocity , freemarker results. not expect deal tiles result. when using tiles typically want our ui actions (as opposed json/xml service actions) use tiles in doing lose convention result component , need use annotations. annotations allow deviate expected, in large application when expecting use tiles annoyance. further conventions allows create actions specifying view. want retain such benefit when using tiles well. rectify need establish convention carries though tiles result such don't need use annotations tie action tiles result , can continue create jsps without actions classes gain benefits of conventions (no xml) , benefits of tiles (all boiler plate factored tiles). how achieve this? this self answer others wish address issue here steps needed: create custom tiles result dynamically builds &q

Using C# as a scripting language for a C# application -

i have developed application uses c# script files configurations , settings. script file contains various user generated objects , functions on objects. presently, user has generate .cs file using third party editor , supply path program make use of it. disadvantage method user not have flexibility of auto-complete , intellisense-esque support while editing script files. i want embed script editing part application. can using rich-text editor. coding auto-complete part huge pain. there way in can provide user in-program editor auto-complete.... code compiling script dynamically in program. public string compile(string inputfilepath) { compilerresults res = null; csharpcodeprovider provider = new csharpcodeprovider(); string errors = ""; if (provider != null) { try { assembly asb = assembly.load("bhel.pumpsdas.datatypes, version=1.0.0.0, culture=neutral, publickeytoken=81d3de1e

sigsegv - C++ - Empty method causing SIGSEV signal -

i'm making simple deck/card/hand object oriented system university assignment, , i've become stuck on problem. i've set simple test class calls various methods in objects. int main() { deck deck = deck(); deck.displaydeck(); deck.shuffle(); deck.displaydeck(); hand hand = hand(1); card* card; card = deck.dealnextcard(); hand.addcard(card); hand.ftring(); deck.displaydeck(); } the problem comes @ hand.ftring() . when call this, causes segmentation fault. weird thing is, contains no code. in hand.cpp : string hand::ftring() { } if remove it, runs completion. if add console output method, prints , crashes. i'm @ loss do, debugger states program received signal sigsegv, segmentation fault. in ?? () () you declare returning string in ftring function, don't return anything. bad.

python 3.x - tkinter listbox insert error "invalid command name ".50054760.50055432" -

i have database of objects , can view items in database in listbox , there's button remove item , create item. creating item opens dialog window item class , item's data stored in database. have reproduced problem simple duplicate of set-up (see code below). every time add new item, addition successful (it's there next time open database dialog), listbox doesn't insert item, , when close database dialog following error: exception in tkinter callback traceback (most recent call last): file "c:\python33\lib\tkinter__init__.py", line 1442, in call return self.func(*args) file "", line 21, in addrecord file "c:\python33\lib\tkinter__init__.py", line 2604, in insert self.tk.call((self._w, 'insert', index) + elements) _tkinter.tclerror: invalid command name ".50054760.50055432" the same problem doesn't come if try create object , populate values without invoking inputs gui (which necessary

javascript - Knockout Can I get around this computed loop? -

i have following structure bunch of objects in viewmodel i have underlying array filled objects have ko.observable items in. ex: selections = [{legs:{'0':ko.observable(12)}}, {legs:{'0':ko.observable(0)}}] what trying achieve when user clicks on checkbox, should toggle selected value of runner. when happens update cache value reflect runners selected state cache used binary storage 12 == 1100 == checkboxes 3 , 4 checked now of can work no problem, don't need make cache observable. but, have need programatically change cache values, , checkboxes reflect these changes automatically. what below sorta works, creates loop, knockout gracefully handles, results unreliable , slows things down. how can create binding setup? function runner(name, odds, race, leg, post) { var runner = { name: name, odds: odds, post: post, race: race, leg: leg, cache: selections[race].legs[leg], selected: k

java - How would I remove an index from ArrayList after a return statement? -

i working on class lab , ran trouble. have been asked write method following instructions: "dog getrandomdog() - randomly selects dog, returns it, , removes kennel. returns null if there no dogs." this method wrote (which doesn't work): public dog getrandomdog(){ if(dogs.size() >= 0){ random random = new random(); int index = random.nextint(dogs.size()); return dogs.get(index); dogs.remove(index); } else { return null; } } i understand cant have executable statement after return, how heck around this? in advance. i come old school of thought one entry, 1 exit public dog getrandomdog(){ dog dog = null; if(dogs.size() >= 0){ random random = new random(); int index = random.nextint(dogs.size()); dog = dogs.remove(index); } return dog; } this means allow 1 point of entry method (a little mute in java) , 1 exit (or 1 return ). makes method easier understand

c# - Rate control star for rating purpose in windows phone 8 -

i working on rate control project, user can rate pictures. need rate control star rating purpose. when searched found [link] http://wp7wonders.wordpress.com/2010/10/15/use-the-rating-control-in-windows-phone-7/ , [link] http://j4ni.com/blog/?p=79 .first link not helpful able create star not able fetch rating numbers 3/5 or 2/5 e.t.c. second link able create star not able see stars on emulator screen when clicked area kept stars able view stars clicked. there other way it. understand windows phone new windows phone framework. in first link each ratingitem control has property called displayvalue either 0 or 1. when set 1 means selected. if check each of ratingitem's can number. actual rating control controlstoolkit:rating has value property number you're looking for. for example. adding <controlstoolkit:rating height="40" grid.row="1" value="0.6" itemcount="0" x:name="ctrating"> in code behind can chec

java - string split performance down after one code -

i test sting.split below. import java.io.file; public class testsplit3 { private static final string procfs = "/proc/"; public static void main(string[] args) { //split(); testfile(integer.parseint(args[0]) > 0); split(); } private static void testfile(boolean flag) { long start = system.currenttimemillis(); if (flag) { (int = 0; < 1000; i++) { new file(procfs + i); } } system.out.println("newfile:" + (system.currenttimemillis() - start)); } public static void split() { long start = system.currenttimemillis(); (int j = 0; j < 1000; j++) { (int = 0; < 1000; i++) { string str = "asas asa s asas asas asa sa sas as a" + "asa sasa sa sa sas as asas as as as" + "as sas asdasdas dasd asda sd ada d"; str.tostring().split(" "); } } system.out.println("split:" + (system.currentti