Thursday, 15 July 2010

AngularJS - updating service-based model from directive -



AngularJS - updating service-based model from directive -

i think i've flaw in design of angularjs app.

i have service contains 1 of model items , methods associated adding/deleting them. service injected core app , directive. issue removing items in model directive. doing because directive physically represents each of model items. alter happening, not pushing way core app exposes model. realize because i'm not telling update, issue don't understand how to. adding $apply in directive after calling service causes error apply in progress, feels wrong approach.

i've set model in service want single instance of info entire app.

can suggest improve way of achieving this? storing model in service idea?

service:

angular.module("app").service("widgetservice", function () { this.widgets = []; this.removewidget = function() { <!-- remove item this.widgets --> } this.getwidgets = function() { homecoming this.widgets; } this.setwidgets = function(widgets) { this.widgets = widgets; ) }

core app:

app.controller("coreappcontroller", function($scope, $http, widgetservice) { $scope.widgets = widgetservice.getwidgets(); }

html:

<widget data-ng-repeat="widget in widgets" />

directive:

mykss.mykssapp.directive("widget", function($compile) { homecoming { restrict: "e", replace: true, templateurl: "partials/widget.html", scope: { }, controller: function($scope, $element, $attrs, widgetservice) { $scope.removewidget = function() { widgetservice.removewidget(); }; } } }

there 1 thing i've notices: shouldn't give possibility alter value of widgets variable of service - otherwise couldn't track adding/removing (i mean this.setwidgets method of service should removed)

everything else should work (with other minor changes): http://plnkr.co/edit/fqmwfi5d7nikjhxtxsc6?p=preview

angularjs

php - sqlsrv_connect: Login failed for user -



php - sqlsrv_connect: Login failed for user -

i testing out new installation of 5.3:

<?php $servername = "ks252"; $connectioninfo = array( "database"=>"ocustom"); /* connect using windows authentication. */ $conn = sqlsrv_connect( $servername, $connectioninfo); if( $conn === false ) { echo "unable connect.</br>"; die( print_r( sqlsrv_errors(), true)); } ?>

and getting error:

unable connect. array ( [0] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. [message] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. ) [1] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. [message] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. ) )

what mean>? doing wrong?

php sql-server iis sql-server-2012

xbmc - Python if valuea is equal and if valueb is not equal -



xbmc - Python if valuea is equal and if valueb is not equal -

i made little script work xbmc , i'm not able work. here code:

import xbmcgui import xbmc while (not xbmc.abortrequested): win = (xbmcgui.getcurrentwindowid()) menu = 0 if win == 10000 , menu != 10000: print ("home menu") menu = 10000

all want when home menu there, write log (but once) write in log when on menu

thanks in advance

set menu = 0 outside of while loop; resetting 0 each time otherwise:

menu = 0 while (not xbmc.abortrequested): win = (xbmcgui.getcurrentwindowid()) if win == 10000 , menu != 10000: print ("home menu") menu = 10000

python xbmc

javascript - Backbone dynamically set collection view el after click on dom element -



javascript - Backbone dynamically set collection view el after click on dom element -

the project calendar model 1 day , collection contain days month. view same. when render collection have calendar on screen. need, able set todo list in selected day. need model,view , collection. thought tasks 1 day day collection - , there go problem : how set new collection view "el" element of clicked day , id. each day has got same class , unique id equal date - "2013.02.08" not sure possible or maybe approach wrong , should in way. edit - ok lets clarify :

i know there in no collection of collections how ? have calendar on screen - imagine 31 square divs. want todo list in each of them - :

model of task view of task {li element} view of tasks {ul element} collection of tasks {model:model}

in each of squares. how store collections ?

javascript backbone.js backbone-views

webgl - Three.js globe rotate on click -



webgl - Three.js globe rotate on click -

i have created rotating globe has hostspots fire modal when clicked on. globe spin , have hotspot clicked on @ centre of screen. code below rotates globe doesn't centre desired. kindly provide pointers

checkhotspotclick: function(){ var me = this; window.cancelanimationframe(me.animate) //get normalized mousecoords -1 -> 1 var mouse2dx = (mousex/me.windowdimensionx)*2-1 var mouse2dy = -(mousey/me.windowdimensiony)*2+1 //for utilize orthographic photographic camera var vecorigin = new three.vector3( mouse2dx, mouse2dy, - 1 ); var vectarget = new three.vector3( mouse2dx, mouse2dy, 1 ); me.projector.unprojectvector( vecorigin, me.camera ); me.projector.unprojectvector( vectarget, me.camera ); vectarget.subself( vecorigin ).normalize(); var ray = new three.ray(); ray.origin = vecorigin; ray.direction = vectarget; var intersects = ray.intersectobjects(me.hotspotsarr); if (intersects.length > 0) { console.log($(me.hotspotdivsarr[intersects[0].object.name]).html()) // ajax overide me.targetrotation_x += (me.options.camx-mouse2dx)*12; me.targetrotation_y += (me.options.camy+mouse2dy)*12; me.dozoom(-6); console.log(me.targetrotation_x); var country_id = $(me.hotspotdivsarr[intersects[0].object.name]).data('id'); url = 'home/getprojectdata'; $("#mymodal").load(url,{ s: country_id }); settimeout(function() {$("#mymodal").modal('show')},2000); $('#mycarousel').carousel($(this).data('slide-index')); /*me.targetrotation_x = 0;*/ } else { me.dozoom(+6); } },

three.js webgl

scripting - Search String using Shell Awk -



scripting - Search String using Shell Awk -

i have string:

the disk 'virtual memory' known 'virtual memory' has exceeded maximum utilization threshold of 95 percent.

i need search every time in string word the disk , if found need extract phrase in '*' known '*' , set in variable monitor

in other words want search , set value to

monitor="'virtual memory' known virtual memory'"

how can using awk?

here's snippet describe. should set in $(...) assign $monitor variable:

$ awk '/the disk '\''.*'\'' known '\''.*'\'' has exceeded/ {gsub(/the disk /,"");gsub(/ has exceeded.*$/,"");print}' input.txt

the 2 problems awk in case is

it doesn't have submatch extraction on regexes (which why solution uses gsub() in body rid of first , lastly part of line. to utilize quotes in awk regex in shell script need '\'' sequence scape (more info here)

shell scripting awk

html - Fixed width columns with fluid gutters -



html - Fixed width columns with fluid gutters -

i know can done columns, have back upwards ie.

i'm trying layout columns fixed width, gutters beingness fluid.

i couldn't work floats, settled on using justified inline-block items:

html

<div class="wrapper"> <div></div> <div></div> <div></div> <!-- more divs... --> </div>

css

class="lang-css prettyprint-override">.wrapper { text-align: justify; } .wrapper div { width: 100px; display: inline-block; }

this works wonderfully, lastly row of divs aligned left: http://jsfiddle.net/eshh3/

the solution found add together additional unnecessary divs: http://jsfiddle.net/eshh3/1/

i sense uncomfortable this, i'd know if there other options.

please don't tell me not re-invent wheel. have not found fluid grid scheme supports fluid gutters.

for want do, i'm afraid css solution not available @ moment, much less if want work in ie8.

since want have (a) items in html source list (b) variable number of columns depending on available space (c) column spacing depending on width of container think solution you'll need have employ @ to the lowest degree bit of javascript.

consider on of frameworks proposed in other answers. 1 i've worked , want masonry (or for-pay bigger brother isotope). (there's non-jquery version of masonry). you'll have come function when page resized, recalculates desired gutter , reconfigures framework. along lines of calculating x = how many items fit per line based on container width , item width , dividing remaining space x-1.

if want stick thought of adding div's markup, alternative hear resize events, , add together divs needed based on width , how many items fit per line.

original answer, failed fit criteria.

since you're relying on text-align: justified reason lastly line doesn't expand total width because there's no line break @ end of it. accomplish add together element wrapper:after {} rule, inline block width of 100% guaranties line break.

see fiddle

the css ends like:

.wrapper { text-align: justify; width: 380px; margin: 0 auto; } .wrapper div { width: 100px; display: inline-block; } .wrapper:after {content: ''; width: 100%; display: inline-block; background: pink; height: 2px; overflow: hidden}

note pinkish background there can see element is. might need play border/margin/padding of element or wrapper content comes after wrapper doesn't gain margin. in chrome unfortunately there's slight missalignment of lastly row items, perchance because of space between lastly div , false element.

html css html5 grid fluid-layout

api - How to set hadoop replication in java client by class org.apache.hadoop.conf.Configuration? -



api - How to set hadoop replication in java client by class org.apache.hadoop.conf.Configuration? -

i utilize java api client upload files ,but set dfs.replication 3,as result when utilize command (hadoop dfsadmin -report) check situation,all blocks under replication factor,because have 2 info nodes test.

i want know how set hadoop dfs.replication in java client class org.apache.hadoop.conf.configuration or in way? give thanks help!

according java api hadoop filesystem class can specify replication factor file when creating output stream write file cluster. e.g.

create(path f, short replication)

i cannot test locally have zookeeper node running here.

java api file-upload replication

regex - C#: Split string on date keeping date intact -



regex - C#: Split string on date keeping date intact -

i have next sample data:

21/10/2012 blahblah blah blahblah 265 blah 25 22/10/2012 blahblah blah blahblah 10 blah 14 blah 66 nk blahblah blah blahblah 25

i want output next data:

21/10/2012 blahblah blah blahblah 265 blah 25 22/10/2012 blahblah blah blahblah 10 blah 14 blah 66 nk blahblah blah blahblah 25

i have tried following:

var regex = new regex ("(\d{1,2})/(\d{1,2})/(\d{4})"); var matches = regex.matches(str);//str given above foreach(var item in matches) { //my logic operations }

this gives array of dates. how can split string on dates?

you can split string on empty string before date. need regex:

string[] arr = regex.split(str, "(?<!\d)(?=\d{1,2}/\d{1,2}/\d{4})");

splitting on above regex, give output want. split string on empty string preceded date of form - 21/10/2012, , not preceded digit. need look-behind stuff, doesn't tear day part apart. without that, split on empty string before 1 in 21, keeping 2 , 1/10/2012 separate element.

also, note empty string first element of array, since first empty string in string satisfies split criteria.

validating dates can complex regex. specially, if want restrict every possible invalid date, 30 feb. still, if want can seek out regex, match 30 & 31 feb , 31 november.

string[] arr = regex.split(str, "(?<!\\d)(?=(?:0[1-9]|[1-2][0-9]|[3][01])/(?:0[1-9]|1[0-2])/(?:19[0-9]{2}|2[0-9]{3}))");

c# regex

Facebook API, Getting name of friend by his ID -



Facebook API, Getting name of friend by his ID -

i wrote fql query names of friends tagged me -

this fql query gives me list of friends id's(it's works):

select owner photo object_id in (select object_id photo_tag subject=me())

now want names querying :

select name user uid in (select owner photo object_id in (select object_id photo_tag subject=me()))

but don't total list of names, , it's stops , gives error - "uncaught typeerror: cannot read property 'name' of undefined"

your query may failing because of owner ids returned inner query don't belong users. seek profile table instead:

select name profile id in (select owner photo object_id in (select object_id photo_tag subject=me()))

facebook facebook-fql

vba - How to add a DocumentProperty to CustomDocumentProperties in Excel? -



vba - How to add a DocumentProperty to CustomDocumentProperties in Excel? -

i'm trying add together documentproperty customdocumentproperties collection. code follows:

sub testcustdocprop() dim docprops documentproperties dim docprop documentproperty set docprops = thisworkbook.customdocumentproperties set docprop = docprops.add(name:="test", linktocontent:=false, value:="xyz") end sub

running gives me next error:

run-time error '5': invalid procedure phone call or argument

i tried running .add void function, so:

docprops.add name:="test", linktocontent:=false, value:="xyz"

this gave me same error. how add together custom document property?

try routine:

public sub subupdatecustomdocumentproperty(strpropertyname string, _ varvalue variant, doctype office.msodocproperties) on error resume next wb.customdocumentproperties(strpropertyname).value _ = varvalue if err.number > 0 wb.customdocumentproperties.add _ name:=strpropertyname, _ linktocontent:=false, _ type:=doctype, _ value:=varvalue end if end sub

vba excel-vba

cakephp 2.3 defining data model -



cakephp 2.3 defining data model -

in info model main entities openings (job), companies , students

the company creates opening have belongsto relationship fine

a pupil can apply many openings store have link table openings_students

id|opening_id|user_id

in opening model class have habtm association

public $hasandbelongstomany = array( 'applicants' => array( 'classname' => 'student', 'jointable' => 'openings_students', 'foreignkey' => 'opening_id', 'associationforeignkey' => 'user_id', 'unique' => 'true', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderquery' => '', 'deletequery' => '', 'insertquery' => '' ) );

is need or need habtm relationship on student?

only getting started framework help appreciated.

the best document go threw cakephp 2.0

http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm

i have question here using students table , foreign key user_id, having 2 tables users, students or single table students foreign key user_id ? can clarify that.

cakephp-2.3

iis - Unity3D Web Client loading Page error in Windows Server? -



iis - Unity3D Web Client loading Page error in Windows Server? -

i have developed unity3d 3d walk through , published on web. when uploaded linux server, works fine; however, when uploaded windows server, have problems.

linux server: http://www.mandanemedia.com/staging/unity3d/nus3dwalkthrough/

windows server: http://skqs.nus.edu.sg/medicallibrary3d/

i think what's happening unity3d page not accessible. seek out yourself, go this link, , don't error. however, if go this page, iss error.

i've searched on google seek , find solution:

on iis server, must specify unity3d file allowed sent over.

how it: in web.config file on home directory of iis need configure file allow unity3d file loaded:

<configuration> <system.webserver> <staticcontent> <remove fileextension=".unity3d" /> <mimemap fileextension=".unity3d" mimetype="application/vnd.unity" /> </staticcontent> </system.webserver> </configuration>

further links:

http://forum.unity3d.com/threads/14819-lots-of-customers-experience-invalid-unity-file/page3 deploy unity3d in windows azure http://developer.dynamicweb-cms.com/forum/development/adding-mime-types.aspx

and i've got network admin of nus this, below screenshots of server settings:

but issue still exists. appreciate if had ideas on how solve it. thanks!

the issue server windows 2003 , iis6, result method not work in iis6.

through configure iis6 need utilize iis manager user interface in windows server 2003:

go start\administrative tools , run iis manager. right click on server name , select properties. in properties dialog box, click mime types. in mime types dialog box, click new. i

the mime types dialog box, come in next mime type:

extension: .unity3d

mime type: application/vnd.unity

it's done, luck

iis unity3d loading

iphone - Facebook share kit ios -



iphone - Facebook share kit ios -

i have implemented facebook share kit app , works intended , if user installed facebook official iphone app messes app because logins through facebook iphone app instead of share kit default login. there way create share kit ignore facebook official iphone app?

no there no such method. have utilize latest facebook api provided apple. may solve problem of not detecting login app

iphone ios xcode facebook sharekit

entity framework - Optional one-to-one relation -



entity framework - Optional one-to-one relation -

when have 2 models this:

public class predictiongroup { [key] public guid predictiongroupid { get; set; } public guid? resultpredictionid { get; set; } [foreignkey("resultpredictionid")] public prediction resultprediction { get; set; } public list<prediction> predictions { get; set; } } public class prediction { [key, databasegenerated(databasegeneratedoption.identity)] public guid predictionid { get; set; } [required] public guid predictiongroupid { get; set; } [foreignkey("predictiongroupid")] public predictiongroup predictiongroup { get; set; } }

this generated:

createtable( "website.predictiongroups", c => new { predictiongroupid = c.guid(nullable: false, identity: true), resultpredictionid = c.guid(), }) .primarykey(t => t.predictiongroupid) .foreignkey("website.predictions", t => t.resultpredictionid) .index(t => t.resultpredictionid); createtable( "website.predictions", c => new { predictionid = c.guid(nullable: false, identity: true), predictiongroupid = c.guid(nullable: false), predictiongroup_predictiongroupid = c.guid(), }) .primarykey(t => t.predictionid) .foreignkey("website.predictiongroups", t => t.predictiongroupid) .foreignkey("website.predictiongroups", t => t.predictiongroup_predictiongroupid) .index(t => t.predictiongroupid) .index(t => t.predictiongroup_predictiongroupid);

when seek come in in database error: unable determine principal end of 'site.data.prediction_predictiongroup' relationship. multiple added entities may have same primary key.

can shine lite on this?

i added fluent api code:

modelbuilder.entity<predictiongroup>() .hasoptional(m => m.resultprediction) .withoptionaldependent() .map(x => x.mapkey("predictionresultgroupid"));

the mapkey optional, hoping been done annotations.

entity-framework ef-code-first code-first-migrations

Image url in JSON (RABL, Dragonfly, Ruby on Rails) -



Image url in JSON (RABL, Dragonfly, Ruby on Rails) -

i'm using rabl gem, user model has many posts

users/show.rabl

object @user attributes :id, :name kid :posts extends "posts/post" end

posts/_post.rabl

attributes :id, image: post.image.url

i want show post's image, have error: undefined local variable or method "post".

but in posts/_post.html.erb can utilize <%= post.image.url =%>

images loaded dragonfly gem.

how can image url in json format?

if child-attribute can append root node using glue.

like this:

@post attributes :id, :image_url glue @image attributes :url => :image_url end

or perhaps this:

@post attributes :id node :image_url |post| post.image.url end

ruby-on-rails-3.2 rabl dragonfly-gem

math - clicking on a sphere -



math - clicking on a sphere -

i have unit sphere (radius 1) drawn centred in orthogonal projection.

the sphere may rotate freely.

how can determine point on sphere user clicks on?

given:

the height , width of monitor the radius of projected circle, in pixels the coordinates of point user clicked on

and assuming top-left corner (0,0), x value increases travel right, , y value increases travel down.

translate user's click point coordinate space of globe.

userpoint.x -= monitor.width/2 userpoint.y -= monitor.height/2 userpoint.x /= circleradius userpoint.y /= circleradius

find z coordinate of point of intersection.

//solve z //x^2 + y^2 + z^2 = 1 //we know x , y, userpoint //z^2 = 1 - x^2 - y^2 x = userpoint.x y = userpoint.y if (x^2 + y^2 > 1){ //user clicked outside of sphere. flip out homecoming -1; } //the negative sqrt closer screen positive one, prefer that. z = -sqrt(1 - x^2 - y^2);

now know (x,y,z) point of intersection, can find lattitude , longitude.

assuming center of globe facing user 0e 0n,

longitude = 90 + todegrees(atan2(z, x)); lattitude = todegrees(atan2(y, sqrt(x^2 + z^2)))

if sphere rotated 0e meridian not straight facing viewer, subtract angle of rotation longitude.

math graphics geometry

php - Keeps redirecting to my error page -



php - Keeps redirecting to my error page -

so, reason whenever go website. session 'loggedin' set true automatically, , reason automatically re-directs me error page. here's site code: login.php:

<?php session_start(); if($_session['loggedin'] == true){ header("location: /index.php"); } $user = stripslashes($_post['user']); $pass = stripslashes($_post['pass']); if((!user == "") && (!$pass == "") && file_exists("/home/manseld/public_html/accounts/$user.txt")){ $file = explode(":", file_get_contents("/home/manseld/public_html/accounts/$user.txt")); if(($file[0] == $user) && ($file[1] == md5($pass))){ $_session['loggedin'] = true; }else{ header("location: /error.php?e=badlogin"); } }else{ header("location: /error.php?e=doesnotexist"); } ?> <?php include('/home/manseld/public_html/scripts/config.php'); ?> <title><?php echo "$title"; ?></title> <head> <link href="/stylesheets/stylesheet1.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="/images/favicon.ico"/> </head> <style type="text/css"> body { background: url("<?php echo "$background"; ?>") 50% 50% repeat; } </style> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <center> <div class="menu"> <div style="border:3px groove white"> <table> <form action="" method="post"> <tr> <td align="right"><font color=white>username:</font></td> <td align="left"><input type="text" name="user"/></td> </tr> <tr> <td align="right"><font color=white>password:</font></td> <td align="left"><input type="password" name="pass"/></td> </tr> </table> <input type="submit" value="login" name="submit" name="submit"/> </form> </div> </div> </center>

now here's index page:

<?php session_start(); if($_session['loggedin'] == false){ header("location: /login.php"); } ?> <?php include('/home/manseld/public_html/scripts/config.php'); ?> <title><?php echo "$title"; ?></title> <a name="#top"></a> <head> <link href="/stylesheets/stylesheet1.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="/images/google%20drive%20favicon.ico"/> </head> <style type="text/css"> body { background: url("<?php echo "$background"; ?>") 50% 50% repeat; } </style> <?php echo "$menu"; ?> <div class="main"> <div class="games" bgcolor=black> <font size=4 color=white> <div style="text-align:left"> <li><a href="/scripts/startgme.php?&name=airbttle2&width=720&height=480" style="color: #cccccc">air battle 2</a><br></li> <li><a href="/scripts/startgme.php?&name=aow&width=780&height=540" style="color: #cccccc">age of war</a><br></li> <li><a href="/scripts/startgme.php?&name=aow2&width=720&height=480" style="color: #cccccc">age of war 2</a><br></li> <li><a href="/scripts/startgme.php?&name=aryofags&width=720&height=500" style="color: #cccccc">army of ages (age of war 3)</a><br></li> <li><a href="/scripts/startgme.php?&name=arcne&width=640&height=480" style="color: #cccccc">arcane</a><br></li> <li><a href="/scripts/startgme.php?&name=arcnorm&width=700&height=525" style="color: #cccccc">arcanorum</a><br></li> <li><a href="/scripts/startgme.php?&name=awsumplnes&width=600&height=600" style="color: #cccccc">awesome planes</a><br></li> <li><a href="/scripts/startgme.php?&name=awsumtnks2&width=600&height=600" style="color: #cccccc">awesome tanks 2</a><br></li> <li><a href="/scripts/startgme.php?&name=bbltnks2&width=500&height=400" style="color: #cccccc">bubble tanks 2</a><br></li> <li><a href="/scripts/startgme.php?&name=bdeggs&width=640&height=530" style="color: #cccccc">bad eggs online</a><br></li> <li><a href="/scripts/startgme.php?&name=blxorz&width=550&height=300" style="color: #cccccc">bloxorz</a><br></li> <li><a href="/scripts/startgme.php?&name=brtbson&width=720&height=480" style="color: #cccccc">burrito bison</a><br></li> <li><a href="/scripts/startgme.php?&name=btd4&width=640&height=660" style="color: #cccccc">bloons tower defence 4</a><br></li> <li><a href="/scripts/startgme.php?&name=bttlepanic&width=800&height=620" style="color: #cccccc">battle panic</a><br></li> <li><a href="/scripts/startgme.php?&name=bttlgar&width=800&height=500" style="color: #cccccc">battle gear</a><br></li> <li><a href="/scripts/startgme.php?&name=bxhd&width=640&height=480" style="color: #cccccc">boxhead</a><br></li> <li><a href="/scripts/startgme.php?&name=bxhd2ply&width=640&height=480" style="color: #cccccc">boxhead 2play</a><br></li> <li><a href="/files/loaders/canyndefnce2.php" style="color: #cccccc">canyon defence 2</a><br></li> <li><a href="/scripts/startgme.php?&name=chsfctn&width=800&height=600" style="color: #cccccc">chaos faction</a><br></li> <li><a href="/scripts/startgme.php?&name=chsfctn2&width=800&height=600" style="color: #cccccc">chaos faction 2</a><br></li> <li><a href="/scripts/startgme.php?&name=corpratininc&width=800&height=500" style="color: #cccccc">corporation inc</a><br></li> <li><a href="/scripts/startgme.php?&name=cyclmniacs&width=640&height=480" style="color: #cccccc">cyclomaniacs</a><br></li> <li><a href="/scripts/startgme.php?&name=cyclmniacs2&width=750&height=500" style="color: #cccccc">cyclomaniacs 2</a><br></li> <li><a href="/scripts/startgme.php?&name=deadlyneihbrs2&width=720&height=480" style="color: #cccccc">deadly neighbors 2</a><br></li> <li><a href="/scripts/startgme.php?&name=drodasslt&width=640&height=480" style="color: #cccccc">droid assault</a><br></li> <li><a href="/scripts/startgme.php?&name=ducklfe4&width=750&height=480" style="color: #cccccc">duck life 4</a><br></li> <li><a href="/scripts/startgme.php?&name=efinwrms2&width=640&height=480" style="color: #cccccc">effing worms 2</a><br></li> <li><a href="/scripts/startgme.php?&name=elctrcmn2&width=640&height=400" style="color: #cccccc">electric man 2</a><br></li> <li><a href="/scripts/startgme.php?&name=endlsswr3&width=727&height=600" style="color: #cccccc">endless war 3</a><br></li> <li><a href="/scripts/startgme.php?&name=endlszombrmpge&width=550&height=400" style="color: #cccccc">endless zombie rampage</a><br></li> <li><a href="/scripts/startgme.php?&name=endlszombrmpge2&width=550&height=400" style="color: #cccccc">endless zombie rampage 2</a><br></li> <li><a href="/scripts/startgme.php?&name=enigmta-stellr-wr&width=700&height=550" style="color: #cccccc">enigmata stellar war</a><br></li> <li><a href="/scripts/startgme.php?&name=eridni&width=580&height=500" style="color: #cccccc">eridani</a><br></li> <li><a href="/scripts/startgme.php?&name=erntodi&width=700&height=500" style="color: #cccccc">earn die</a><br></li> <li><a href="/scripts/startgme.php?&name=erntodi2012&width=750&height=500" style="color: #cccccc">earn die 2012</a><br></li> <li><a href="/scripts/startgme.php?&name=flght&width=720&height=480" style="color: #cccccc">flight</a><br></li> <li><a href="/scripts/startgme.php?&name=fncypnts&width=720&height=480" style="color: #cccccc">fancy pants adventure world 1</a><br></li> <li><a href="/scripts/startgme.php?&name=fncypnts2&width=720&height=480" style="color: #cccccc">fancy pants adventure world 2</a><br></li> <li><a href="/scripts/startgme.php?&name=fncypnts3&width=720&height=480" style="color: #cccccc">fancy pants adventure world 3</a><br></li> <li><a href="/scripts/startgme.php?&name=frwyfry2&width=450&height=565" style="color: #cccccc">freeway fury 2</a><br></li> <li><a href="/scripts/startgme.php?&name=gdsplyngfild&width=550&height=400" style="color: #cccccc">gods playing field</a><br></li> <li><a href="/scripts/startgme.php?&name=ghstgidnce&width=550&height=400" style="color: #cccccc">ghost guidance</a><br></li> <li><a href="/scripts/startgme.php?&name=gmcorp&width=640&height=480" style="color: #cccccc">gam-e corp</a><br></li> <li><a href="/scripts/startgme.php?&name=gnblodwestrnshotout&width=720&height=425" style="color: #cccccc">gunblood western shootout</a><br></li> <li><a href="/scripts/startgme.php?&name=gnbot&width=700&height=550" style="color: #cccccc">gunbot</a><br></li> <li><a href="/scripts/startgme.php?&name=goalsothafric&width=640&height=480" style="color: #cccccc">goal south africa</a><br></li> <li><a href="/scripts/startgme.php?&name=hliattck3&width=450&height=320" style="color: #cccccc">heli attack 3</a><br></li> <li><a href="/scripts/startgme.php?&name=inftntr2&width=720&height=480" style="color: #cccccc">infectonator 2</a><br></li> <li><a href="/scripts/startgme.php?&name=intospc2&width=600&height=600" style="color: #cccccc">into space 2</a><br></li> <li><a href="/scripts/startgme.php?&name=intractvbddy&width=550&height=400" style="color: #cccccc">interactive buddy</a><br></li> <li><a href="/scripts/startgme.php?&name=intractvbddy2&width=550&height=400" style="color: #cccccc">interactive buddy 2</a><br></li> <li><a href="/scripts/startgme.php?&name=lrn2fly&width=640&height=480" style="color: #cccccc">learn fly</a><br></li> <li><a href="/scripts/startgme.php?&name=lrn2fly2&width=640&height=480" style="color: #cccccc">learn fly 2</a><br></li> <li><a href="/scripts/startgme.php?&name=mazegme&width=727&height=556" style="color: #cccccc">the maze</a><br></li> <li><a href="/scripts/startgme.php?&name=mgamnr&width=800&height=600" style="color: #cccccc">mega miner</a><br></li> <li><a href="/scripts/startgme.php?&name=nclrgn&width=640&height=480" style="color: #cccccc">nuclear gun</a><br></li> <li><a href="/scripts/startgme.php?&name=ntebokwrs3unleashd&width=600&height=600" style="color: #cccccc">notebook wars 3 unleashed</a><br></li> <li><a href="/scripts/startgme.php?&name=nxgme&width=725&height=340" style="color: #cccccc">nex gam-e</a><br></li> <li><a href="/scripts/startgme.php?&name=obltratevrythng&width=640&height=480" style="color: #cccccc">obliterate everything</a><br></li> <li><a href="/scripts/startgme.php?&name=obltratevrythng2&width=640&height=480" style="color: #cccccc">obliterate 2</a><br></li> <li><a href="/scripts/startgme.php?&name=phgwrs&width=728&height=611" style="color: #cccccc">phage wars</a><br></li> <li><a href="/scripts/startgme.php?&name=plntjucer&width=640&height=480" style="color: #cccccc">planet juicer</a><br></li> <li><a href="/scripts/startgme.php?&name=pndmc2&width=700&height=500" style="color: #cccccc">pandemic 2</a><br></li> <li><a href="/scripts/startgme.php?&name=potonpnc2&width=800&height=600" style="color: #cccccc">potion panic 2</a><br></li> <li><a href="/scripts/startgme.php?&name=pperidr&width=640&height=480" style="color: #cccccc">pipe riders</a><br></li> <li><a href="/scripts/startgme.php?&name=pttyrcrs3&width=800&height=600" style="color: #cccccc">potty racers 3</a><br></li> <li><a href="/scripts/startgme.php?&name=rbokll&width=800&height=600" style="color: #cccccc">robokill</a><br></li> <li><a href="/scripts/startgme.php?&name=robtsvszombs&width=760&height=570" style="color: #cccccc">robots vs zombies</a><br></li> <li><a href="/scripts/startgme.php?&name=shdz2&width=700&height=500" style="color: #cccccc">shadez 2</a><br></li> <li><a href="/scripts/startgme.php?&name=spllstrm&width=800&height=600" style="color: #cccccc">spellstorm</a><br></li> <li><a href="/scripts/startgme.php?&name=ss3&width=850&height=550" style="color: #cccccc">sas3</a><br></li> <li><a href="/scripts/startgme.php?&name=stkemprs&width=850&height=700" style="color: #cccccc">stick empires</a><br></li> <li><a href="/scripts/startgme.php?&name=stkwr2&width=850&height=700" style="color: #cccccc">stick war 2</a><br></li> <li><a href="/scripts/startgme.php?&name=stmpnktwrdefnce&width=800&height=500" style="color: #cccccc">steampunk tower defence</a><br></li> <li><a href="/scripts/startgme.php?&name=strkforchroes&width=800&height=600" style="color: #cccccc">strike forcefulness heroes</a><br></li> <li><a href="/scripts/startgme.php?&name=strmwindthelstcampagn&width=700&height=375" style="color: #cccccc">stormwinds lost campaigns</a><br></li> <li><a href="/scripts/startgme.php?&name=territrywr3&width=700&height=500" style="color: #cccccc">territory war 3</a><br></li> <li><a href="/scripts/startgme.php?&name=thegngme2&width=550&height=400" style="color: #cccccc">the gun gam-e 2</a><br></li> <li><a href="/scripts/startgme.php?&name=thelststnd2&width=700&height=400" style="color: #cccccc">the lastly stand 2</a><br></li> <li><a href="/scripts/startgme.php?&name=trckwrs&width=800&height=480" style="color: #cccccc">truck wars</a><br></li> <li><a href="/scripts/startgme.php?&name=upgrdcmplte2&width=400&height=500" style="color: #cccccc">upgrade finish 2</a><br></li> <li><a href="/scripts/startgme.php?&name=vrsumbr&width=800&height=400" style="color: #cccccc">versus umbra</a><br></li> <li><a href="/scripts/startgme.php?&name=wndrptt&width=750&height=650" style="color: #cccccc">wonderputt</a><br></li> <li><a href="/scripts/startgme.php?&name=wrldshrdstgme&width=728&height=529" style="color: #cccccc">worlds hardest gam-e</a><br></li> <li><a href="/scripts/startgme.php?&name=wrldshrdstgme2&width=728&height=520" style="color: #cccccc">worlds hardest gam-e 2</a><br></li> <li><a href="/scripts/startgme.php?&name=zombetrlrprk&width=800&height=600" style="color: #cccccc">zombie trailer park (hillbillys vs zombies)</a><br></li> </div> </div> <hr> <center><div class="title" style="border:2px groove white;"> <a href="#top">back top</a> | <a href="/request.php">want game added?</a> </center></div> </font>

and custom error page:

<?php $msg = stripslashes($_get['e']); if($msg == "badlogin"){ $error = 'you have entered invalid login... <a href="index.php">please seek again!</a>'; }elseif($msg = "doesnotexist"){ $error = "invalid login; user doesn't exist"; }else{ $error = 'an unknown error occured!'; } ?> <center> <img src="/images/me_gusta.png" alt="me gusta"></img><br> <font color="red" size=3><?php echo $error; ?></font> </center>

i have no thought why it's re-directing error page

in case of $_session['loggedin'] == true need stop code execution , return.

if($_session['loggedin'] == true){ header("location: /index.php"); return; }

php

c++ - error C2664: cannot convert parameter 1 from 'X' to 'X' -



c++ - error C2664: cannot convert parameter 1 from 'X' to 'X' -

i have c++/win32/mfc project in visual studio 2008, , i'm getting unusual error message when compile it.

i've created little project demonstrate problem, , main code is

#ifndef _myobject_h #define _myobject_h class myobject { public: myobject() { } }; #endif // _myobject_h // --- end myobject.h // --- begin objectdata.h #ifndef _objectdata_h #define _objectdata_h template <typename datapolicy> class objectdata { public: datapolicy *data; objectdata() : data(null) { } objectdata(const objectdata<datapolicy> &copy) : data(copy.data) { } objectdata<datapolicy> & operator=(const objectdata<datapolicy> &copy) { this->data = copy.data; homecoming *this; } }; #endif // _objectdata_h // --- end objectdata.h // --- begin tool.h #ifndef _tool_h #define _tool_h #include "objectdata.h" template <typename objectpolicy> class tool { private: objectdata<typename objectpolicy> _object; public: tool(objectdata<typename objectpolicy> obj); }; #endif // _tool_h // --- end tool.h // --- begin tool.cpp #include "stdafx.h" #include "tool.h" template <typename objectpolicy> tool<objectpolicy>::tool(objectdata<typename objectpolicy> obj) : _object(obj) { } // --- end tool.cpp // --- begin engine.h #ifndef _engine_h #define _engine_h #include "tool.h" #include "myobject.h" class engine { private: myobject *_obj; public: engine(); ~engine(); void dosomething(); }; #endif // _engine_h // --- end engine.h // --- begin engine.cpp #include "stdafx.h" #include "engine.h" engine::engine() { this->_obj = new myobject(); } engine::~engine() { delete this->_obj; } void engine::dosomething() { objectdata<myobject> objdata; objdata.data = this->_obj; // next line error occurs tool< objectdata<myobject> > *tool = new tool< objectdata<myobject> >(objdata); } // --- end engine.cpp

errors:

engine.cpp c:\projects\myproject\myproject\engine.cpp(18) : error c2664: 'tool::tool(objectdata)' : cannot convert parameter 1 'objectdata' 'objectdata' with [ objectpolicy=objectdata, datapolicy=objectdata ] and [ datapolicy=myobject ] and [ datapolicy=objectdata ] no user-defined-conversion operator available can perform conversion, or operator cannot called 1>build log saved @ "file://c:\projects\myproject\myproject\debug\buildlog.htm" myproject - 1 error(s), 0 warning(s)

thanks help.

there few problems code. first of all, using typename keyword in wrong way. typename can used when qualified type names used (and required when type names dependent), not case:

template <typename objectpolicy> class tool { private: objectdata<typename objectpolicy> _object; // "typename" not needed! public: tool(objectdata<typename objectpolicy> obj); // "typename" not needed! };

the problem complain about, however, in instantiation of tool class template:

tool< objectdata<myobject> > *tool = new tool< objectdata<myobject> >(objdata);

your tool<> template contains fellow member variable of type objectdata<objectpolicy>, objectpolicy class template parameter. however, in line above instantiate tool objectdata<myobject> parameter. means fellow member variable have type objectdata<objectdata<myobject>>, , type of constructor's parameter.

because of this, trying invoke constructor accepts objectdata<objectdata<myobject>> argument of mismatching type objectdata<myobject>. hence, error get.

you should alter instantiation into:

tool< myobject > *tool = new tool< myobject >(objdata);

another problem have definition of tool's fellow member functions in separate .cpp files. should not that: linker won't able see when processing separate translation unit.

to solve problem, set definitions of class template's fellow member functions same header class template defined (tool.h in case).

c++ visual-studio-2008

economics - Error in Python Code. How do I fix it? -



economics - Error in Python Code. How do I fix it? -

first time writing python code. need help in graphing function. overlapping growth model function. keeps giving error code though sure equation correct. help appreciated!

from numpy import * pylab import * scipy import optimize scipy.optimize import fsolve def olgss(x) : numg = ((1-alpha)*a*x**alpha)/(1+n) deng = (1+(1/(beta**(sigma)))*(1+alpha*a*x**(alpha-1))**(1-sigma)) olgk = x - numg/deng homecoming olgk # set parameter values alpha = .3 # share of capital income in gross domestic product = 1.0 # productivity parameter beta = 0.8 # discount factor n = 0.01 # rate of growth of population sigma = 0.9 # intertemporal elasticity of substitution utility function # set inital status state= 0.2 xt = [] # x_t valudebuge # iterate few time steps niterates = 10 # plot lines, showing how iteration reflected off of identity n in xrange(niterates): xt.append(state) state = olgss(state) plot(xrange(niterates), xt, 'b') xlabel('time') ylabel('k$t$') title('time path of k$t$') #savefig('olgtimepath', dpi=100) show()

the error is:

traceback (most recent phone call last): file "c:\users\achia\documents\untitled1.py", line 37, in <module> state = olgss(state) file "c:\users\achia\documents\untitled1.py", line 14, in olgss numg = ((1-alpha)*a*x**alpha)/(1+n) valueerror: negative number cannot raised fractional powerfulness

if add together print statements olgss(x), so:

def olgss(x) : print "alpha is", alpha print "x is", x numg = ((1-alpha)*a*x**alpha)/(1+n) deng = (1+(1/(beta**(sigma)))*(1+alpha*a*x**(alpha-1))**(1-sigma)) olgk = x - numg/deng homecoming olgk

i next output:

alpha 0.3 x 0.2 alpha 0.3 x 0.0126300785572 alpha 0.3 x -0.0251898297413 traceback (most recent phone call last): file "globals.py", line 36, in ? state = olgss(state) file "globals.py", line 13, in olgss numg = ((1-alpha)*a*x**alpha)/(1+n) valueerror: negative number cannot raised fractional powerfulness

so, looks 3rd phone call olgss() returning negative value, feeds next phone call , causes error.

python economics

Configure kendo ui treeview for my json data -



Configure kendo ui treeview for my json data -

i have next data:

[ {"id":1,"parendid":0,"name":"foods","hasitems":"true}, {"id":2,"parentid":1,"name":"fruits","hasitems":"true"}, {"id":3,"parentid":1,"name":"vegetables","hasitems":"true"}, {"id":4,"parentid":2,"name":"apple","hasitems":"false"}, {"id":5,"parentid":2,"name":"orange","hasitems":"true"}, {"id":6,"parentid":3,"name":"tomato","hasitems":"true"}, {"id":7,"parentid":3,"name":"carrot","hasitems":"true"}, {"id":8,"parentid":3,"name":"cabbage","hasitems":"true"}, {"id":9,"parentid":3,"name":"potato","hasitems":"true"}, {"id":10,"parentid":3,"name":"lettuce","hasitems":"false"} ]

can tell how can configure kendo ui treeview above data? also, possible have treeview within kendo ui dropdownlist?

update:

this have far...

categories = new kendo.data.hierarchicaldatasource({ transport: { read: { url: urlthatfetchesdata } }, schema: { model: { id: 'id', parentid: 'parentid', name: 'name' } } }); $('#tvcategories').kendotreeview({ datasource: categories, datatextfield: 'name', datavaluefield: 'id' });

all items displayed main category, 1 right below other. how the treeview utilize parentid?

are trying embed within treeview item other data? if so, kendotreeview should this:

@( html.kendo().treeview() .name("treeview") .datatextfield("name") //display text .datasource(datasource => datasource .read(read => read .action("actionthatfetchesdata", "controllername") ) ) .templateid("treeview-template") //name of template )

and utilize kendo template display json

<script id="treeview-template" type="text/kendo-ui-template"> <span>#: item.id#</span> <span>#: item.parentid#</span> <span>#: item.name#</span> <span>#: item.hasitems#</span> </script>

kendo-ui kendo-treeview

php - How can I use ajax in Zend Framework 2? -



php - How can I use ajax in Zend Framework 2? -

i trying little ajax application whereby want homecoming hello world string controller action. returning hello world along this, returning template file.. tried disable templating using next code in action of controlelr

$this->_helper->layout()->disablelayout(); $this->_helper->viewrenderer->setnorender( true );

but returns me error

scream: error suppression ignored ( ! ) notice: undefined property: survey\controller\surveycontroller::$_helper in c:\wamp\www\zend\module\survey\src\survey\controller\surveycontroller.php on line 55 scream: error suppression ignored ( ! ) fatal error: phone call fellow member function layout() on non-object in c:\wamp\www\zend\module\survey\src\survey\controller\surveycontroller.php on line 55 phone call stack

how prepare ?

edit

i modifed controller such looks

public function registeraction() { $result = new jsonmodel(array( 'some_parameter' => 'some value', 'success'=>true, )); return( $result ); }

added strategies in module..module.config in module appl directory

'strategies' => array( 'viewjsonstrategy', ),

still, in ajax response template beingness returned

here's solid example:

http://akrabat.com/zend-framework-2/returning-json-from-a-zf2-controller-action/

you should using jsonmoodels send json response.

php zend-framework2

installation - Error installing testacular with latest version of nodejs 0.8.19 -



installation - Error installing testacular with latest version of nodejs 0.8.19 -

i next error when run below command..

⚡ sudo npm -g install testacular

module.js:340 throw err; ^ error: cannot find module 'npmlog' @ function.module._resolvefilename (module.js:338:15) @ function.module._load (module.js:280:25) @ module.require (module.js:362:17) @ require (module.js:378:17) @ /usr/local/bin/npm:19:11 @ object.<anonymous> (/usr/local/bin/npm:87:3) @ module._compile (module.js:449:26) @ object.module._extensions..js (module.js:467:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12)

try re-installing node.js - http://nodejs.org/download/

this happened me after old version of n failed install node v0.10.5, upgraded n , had install node. apparently didn't install npm quite correctly.

installation karma-runner

python - Simple parallel scientific programming -



python - Simple parallel scientific programming -

i quite write simple optimization routines this:

def createinstance(n): while(true): #create instance called instance yield instance loopno = 100000 n= 100 min = 0 in xrange(loopno): inst in createinstance(n): value = foo(inst) if (value < min): min = value print min

i able utilize of cores on machine this.

a simple method split range parts , farm them out cores , collect results @ end.

a improve method have cores request batch of instances when idle.

what's nice way solve problem maximum efficiency in python? maybe standard plenty community question?

this question seems simpler version of solving embarassingly parallel problems using python multiprocessing .

with regards standard python install, multiprocessing module seems you'd want, illustration case in http://docs.python.org/2/library/multiprocessing.html looks adapted case. if memory isn't issue, splitting range on n processors efficient option, have no communication between processes.

there seem many ways of parallelising python, either using mpi or smp. there's list of potential candidates on python wiki http://wiki.python.org/moin/parallelprocessing

parallel python http://www.parallelpython.com supports smp, want in instance (single machine, multiple processors, rather cluster of machines).

python multiprocessing

AngularJS : When writing a directive, how do I decide if a need no new scope, a new child scope, or a new isolate scope? -



AngularJS : When writing a directive, how do I decide if a need no new scope, a new child scope, or a new isolate scope? -

i'm looking guidelines 1 can utilize help determine type of scope utilize when writing new directive. ideally, i'd similar flowchart walks me though bunch of questions , out pops right reply – no new new scope, new kid scope, or new isolate scope – asking much. here's current paltry set of guidelines:

don't utilize isolate scope if element utilize directive uses ng-model see ngmodel , component isolated scope , why formatters not work isolated scope? if directive doesn't modify scope/model properties, don't create new scope isolate scopes seem work if directive encapsulating set of dom elements (the docs "a complex dom structure") , directive used element, or no other directives on same element

i'm aware using directive isolate scope on element forces other directives on same element utilize same (one) isolate scope, doesn't severely limit when isolate scope can used?

i hoping angular-ui team (or others have written many directives) can share experiences.

please don't add together reply says "use isolate scope reusable components".

what great question! i'd love hear others have say, here guidelines use.

the high-altitude premise: scope used "glue" utilize communicate between parent controller, directive, , directive template.

parent scope: scope: false, no new scope @ all

i don't utilize often, @markrajcok said, if directive doesn't access scope variables (and doesn't set any!) fine far concerned. helpful kid directives only used in context of parent directive (though there exceptions this) , don't have template. template doesn't belong sharing scope, because inherently exposing scope access , manipulation (but i'm sure there exceptions rule).

as example, created directive draws (static) vector graphic using svg library i'm in process of writing. $observes 2 attributes (width , height) , uses in calculations, neither sets nor reads scope variables , has no template. utilize case not creating scope; don't need one, why bother?

but in svg directive, however, required set of info utilize , additionally had store tiny bit of state. in case, using parent scope irresponsible (again, speaking). instead...

child scope: scope: true

directives kid scope context-aware , intended interact current scope.

obviously, key advantage of on isolate scope user free utilize interpolation on attributes want; e.g. using class="item-type-{{item.type}}" on directive isolate scope not work default, works fine on 1 kid scope because whatever interpolated can still default found in parent scope. also, directive can safely evaluate attributes , expressions in context of own scope without worrying pollution in or harm parent.

for example, tooltip gets added; isolate scope wouldn't work (by default, see below) because expected utilize other directives or interpolated attributes here. tooltip enhancement. tooltip needs set things on scope utilize sub-directive and/or template , manage own state, quite bad indeed utilize parent scope. either polluting or damaging it, , neither bueno.

i find myself using kid scopes more isolate or parent scopes.

isolate scope: scope: {}

this reusable components. :-)

but seriously, think of "reusable components" "self-contained components". intent used specific purpose, combining them other directives or adding other interpolated attributes dom node inherently doesn't create sense.

to more specific, needed standalone functionality provided through specified attributes evaluated in context of parent scope; either one-way strings ('@'), one-way expressions ('&'), or two-way variable bindings ('=').

on self-contained components, doesn't create sense need apply other directives or attributes on because exists itself. style governed own template (if necessary) , can have appropriate content transcluded (if necessary). it's standalone, set in isolate scope say: "don't mess this. i'm giving defined api through these few attributes."

a best practice exclude much template-based stuff directive link , controller functions possible. provides "api-like" configuration point: user of directive can replace template! functionality stayed same, , internal api never touched, can mess styling , dom implementation much need to. ui/bootstrap great illustration of how because peter & pawel awesome.

isolate scopes great utilize transclusion. take tabs; not whole functionality, whatever inside of can evaluated freely within parent scope while leaving tabs (and panes) whatever want. tabs have own state, belongs on scope (to interact template), state has nil context in used - it's exclusively internal makes tab directive tab directive. further, doesn't create much sense utilize other directives tabs. they're tabs - , got functionality!

surround more functionality or transclude more functionality, directive already.

all said, should note there ways around of limitations (i.e. features) of isolate scope, @proloser hinted @ in answer. example, in kid scope section, mentioned interpolation on non-directive attributes breaking when using isolate scope (by default). user could, example, utilize class="item-type-{{$parent.item.type}}" , 1 time 1 time again work. if there compelling reason utilize isolate scope on kid scope you're worried of these limitations, know can work around virtually of them if need to.

summary

directives no new scope read-only; they're trusted (i.e. internal app) , don't touch jack. directives kid scope add functionality, not the only functionality. lastly, isolate scopes directives entire goal; standalone, it's okay (and "correct") allow them go rogue.

i wanted initial thoughts out, think of more things, i'll update this. holy crap - long answer...

ps: totally tangential, since we're talking scopes, prefer "prototypical" whereas others prefer "prototypal", seems more accurate rolls off tongue not @ well. :-)

angularjs angularjs-directive angularjs-scope

java - ORMLite iterating over ForeignCollection throws the exception -



java - ORMLite iterating over ForeignCollection throws the exception -

i seek iterate on foreigncollection<orderitems>. works if eager set true lazy alternative still doesn't work.

firstly, make

orderdatasource orderds = new orderdatasource(getappcontext()); ws.order order = orderds.converttows(morder,ws.order.class); orderds.close();

where close() close db connection , converttows() create iterating.

part of converttows():

iterator<orderitem> itr = order.getorderitems().iterator(); while (itr.hasnext()) { orderitem orderitem = itr.next(); ... }

method close called after homecoming converttows(). work other objects in converttows() problem.

i seek utilize closeableiterator , close in finally block, without success. expect of this, don't close connection.

exception:

02-17 02:21:43.094: e/androidruntime(4820): fatal exception: main 02-17 02:21:43.094: e/androidruntime(4820): java.lang.illegalstateexception: database /data/data/my_app/databases/my_db (conn# 0) closed 02-17 02:21:43.094: e/androidruntime(4820): @ android.database.sqlite.sqlitedatabase.verifydbisopen(sqlitedatabase.java:2082) 02-17 02:21:43.094: e/androidruntime(4820): @ android.database.sqlite.sqlitedatabase.rawquerywithfactory(sqlitedatabase.java:1556) 02-17 02:21:43.094: e/androidruntime(4820): @ android.database.sqlite.sqlitedatabase.rawquery(sqlitedatabase.java:1538) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.android.androidcompiledstatement.getcursor(androidcompiledstatement.java:162) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.android.androidcompiledstatement.runquery(androidcompiledstatement.java:57) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.stmt.selectiterator.<init>(selectiterator.java:55) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.stmt.statementexecutor.builditerator(statementexecutor.java:232) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.basedaoimpl.createiterator(basedaoimpl.java:933) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.basedaoimpl.iterator(basedaoimpl.java:531) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.basedaoimpl.iterator(basedaoimpl.java:526) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.lazyforeigncollection.seperateiteratorthrow(lazyforeigncollection.java:74) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.lazyforeigncollection.iteratorthrow(lazyforeigncollection.java:60) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.lazyforeigncollection.closeableiterator(lazyforeigncollection.java:50) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.lazyforeigncollection.iterator(lazyforeigncollection.java:45) 02-17 02:21:43.094: e/androidruntime(4820): @ com.j256.ormlite.dao.lazyforeigncollection.iterator(lazyforeigncollection.java:26) 02-17 02:21:43.094: e/androidruntime(4820): @ orders.orderdatasource.converttows(orderdatasource.java:409) 02-17 02:21:43.094: e/androidruntime(4820): @ fragments.orderdetailfragment.sendorder(orderdetailfragment.java:419) 02-17 02:21:43.094: e/androidruntime(4820): @ fragments.orderdetailfragment.dopositiveclick(orderdetailfragment.java:347) 02-17 02:21:43.094: e/androidruntime(4820): @ ui.dialogfragments.alertdialogfragment$1.onclick(alertdialogfragment.java:54) 02-17 02:21:43.094: e/androidruntime(4820): @ com.android.internal.app.alertcontroller$buttonhandler.handlemessage(alertcontroller.java:166) 02-17 02:21:43.094: e/androidruntime(4820): @ android.os.handler.dispatchmessage(handler.java:99) 02-17 02:21:43.094: e/androidruntime(4820): @ android.os.looper.loop(looper.java:137) 02-17 02:21:43.094: e/androidruntime(4820): @ android.app.activitythread.main(activitythread.java:4424) 02-17 02:21:43.094: e/androidruntime(4820): @ java.lang.reflect.method.invokenative(native method) 02-17 02:21:43.094: e/androidruntime(4820): @ java.lang.reflect.method.invoke(method.java:511) 02-17 02:21:43.094: e/androidruntime(4820): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 02-17 02:21:43.094: e/androidruntime(4820): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 02-17 02:21:43.094: e/androidruntime(4820): @ dalvik.system.nativestart.main(native method)

you need have database open in order iterate on values since doing lazy queries, meaning fetching info database first time access object foreign collection.

so if extending ormliteactivity database remain open until destroy screen.

the main thing here maintain helper open while using data.

java android collections ormlite foreign-collection

r - Plotting multiple lines from multiple data frames -



r - Plotting multiple lines from multiple data frames -

i'm beginner r. have 2 info files, a.dat , b.dat like:

1 101203 2 3231233 3 213213 ...

so did

a <- read.table("a.dat", col.names = c("time","power")) b <- read.table("b.dat", col.names = c("time","power"))

and want line plot , b in same scheme (sorry, can't upload image yet). suggestions on how go about?

i prefer using ggplot2 (package can downloaded cran). first requires little info processing:

a$group = "a" b$group = "b" dat = rbind(a,b)

and plotting figure:

ggplot(aes(x = time, y = power, color = group), info = dat) + geom_line()

for base of operations graphics, should work:

plot(power~time, a) lines(power~time, b)

r plot ggplot2 data.frame

Count the deleted files Shell script -



Count the deleted files Shell script -

can tell me how can count files extension ".txt" delete folder? shell script in unix

thank reply :)

i tried delete them way :

deleted=0

while read line do

if test -d "$line" in "$line"/* if test -f "$i" deleted=`ls -l $line |grep "*.o" | wc -l` echo "from: " $line " deleted : " $deleted find . -type f -name "*.o" -exec rm -f {} \; else echo "not file " $i fi done else echo "not directory!" fi

done

try doing :

lang=c rm -v *.txt | grep -c "^removed "

shell

LESS CSS compilation error on subtracting color values -



LESS CSS compilation error on subtracting color values -

i'm running lessc my.less my.css.

code:

@background: #343434; input[type='text'] { border: 1px solid (@background-#222); }

fails providing error

nameerror: variable @background- undefined in ...

however,

input[type='text'] { border: 1px solid (@background+#222); }

will work.

i have read bom, not case. have checked less compiler installed latest nodejs. tried #222222. out of ideas.

the - may part of identifier. why tells can't find variable @background-. on other hand + never part of identifier , less knows variable @background. have insert space working:

input[type='text'] { border: 1px solid (@background -#222); }

colors compilation less subtract

html5 - H.264 Streamed Video Works in Chrome 23 but not Chrome 24, different request headers... same cherrypy backend -



html5 - H.264 Streamed Video Works in Chrome 23 but not Chrome 24, different request headers... same cherrypy backend -

on site i'm working on, utilize html5 video h.264. if it's not available utilize flash fallback. flash fallback working fine in both chrome 23 , 24, html5 video works in chrome 23.

i opened video file in it's own tab (which chrome has simple bootstrap snippet of html play it) in each version of chrome , saved request , response information. makes 3 requests find teh first 1 interesting. here header info request , response both.

chrome 23:

request: url:http://localhost:8040/media/preview/ab0eca40ffee4f/c268a6240b08ff/mp4_360 request method:get status code:200 ok request headersview source accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-charset:iso-8859-1,utf-8;q=0.7,*;q=0.3 accept-encoding:gzip,deflate,sdch accept-language:en-us,en;q=0.8 cache-control:no-cache connection:keep-alive cookie:beaker.session.id=c59137ff184428045f317d6b2385aa384 4c30f host:localhost:8040 pragma:no-cache user-agent:mozilla/5.0 (x11; linux x86_64) applewebkit/537.11 (khtml, gecko) chrome/23.0.1271.97 safari/537.11 ------------------------------- response headersview source accept-ranges:bytes content-disposition:inline; filename="2af3dc86e4fae33370c268a6240b08ff" content-length:5817287 content-type:video/mp4 date:wed, 06 feb 2013 15:51:25 gmt last-modified:fri, 07 dec 2012 19:47:51 gmt server:cherrypy/3.2.0

chrome 24:

request url:http://localhost:8040/media/preview/ef5a0220219b8e0/a4fe5f21c26f/mp4_360 request method:get status code:200 ok request headersview source accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-charset:iso-8859-1,utf-8;q=0.7,*;q=0.3 accept-encoding:gzip,deflate,sdch accept-language:en-us,en;q=0.8 cache-control:max-age=0 connection:keep-alive cookie:beaker.session.id=5c080dc2b3343dc725ea368dae30cb1bc324 host:localhost:8040 user-agent:mozilla/5.0 (x11; linux x86_64) applewebkit/537.17 (khtml, gecko) chrome/24.0.1312.68 safari/537.17 ----------------------------------- response headersview source accept-ranges:bytes content-disposition:inline; filename="e10cce5997514651851aa4fe5f21c26f" content-length:3632612 content-type:video/mp4 date:wed, 06 feb 2013 18:45:04 gmt last-modified:tue, 05 feb 2013 20:15:20 gmt server:cherrypy/3.2.0

has else expierenced this? i'm willing farther tests requested well.

you may prepare problem doing following: there alternative in chrome://flags called "disable hardware-accelerated video decode" enable it.

https://productforums.google.com/forum/?fromgroups=#!searchin/chrome/mp4/chrome/ilqhittzcay/hkpga3gk6bij

and bug filed 3 weeks ago: http://src.chromium.org/viewvc/chrome?view=rev&revision=178906. according status “fixed”. however, later on in comments saying prepare might pushed version m25 , fixed version 26.0.1395.1.

as test, have downloaded version 26 of chrome (the developer version), (re)disabled “disable hardware-accelerated video decode”, , works fine. if want same, visit chrome’s release page , take “dev channel windows”.

html5 google-chrome html5-video

c++ - How do I remove the first occurrence of a value from a vector? -



c++ - How do I remove the first occurrence of a value from a vector? -

i'm trying single element vector , force of vector remove won't have empty section in memory. erase-remove idiom can removes all instances of particular value. want first 1 removed.

i'm not experienced standard library algorithms , can't find appropriate methods (if any) this. here example:

int main() { std::vector<int> v{1, 2, 3, 3, 4}; remove_first(v, 3); std::cout << v; // 1, 2, 3, 4 }

so how go removing first occurance of 3 vector?

find first, erase it:

auto = std::find(v.begin(),v.end(),3); // check there 3 in our vector if (it != v.end()) { v.erase(it); }

c++ c++11

java - How to use Facebook appAccessToken with Spring Social -



java - How to use Facebook appAccessToken with Spring Social -

i'm bit confused how utilize facebook's app access token spring social.

i have app access token making request to:

http://graph.facebook.com/oauth/access_token?client_id=your_app_id&client_secret=your_app_secret&grant_type=client_credentials

i can't utilize (for reasons don't want discuss here) standard spring social connection creation flow , want utilize token (if possible).

my question directed toward graphapi.

so in general can utilize app access token acquired via standard create requests graph api through spring social ?

thanks,

there few things app access token can used for. of operations in graph api fetching user info , hence must obtain user access token. app access token have not work.

if you're planning utilize app access token fetch user's profile, see friends list, or post timeline (or pertains user), you're out of luck. imagine chaos ensue if had read , post on behalf of user obtain app access token! must user's permission kind of thing.

there 3 ways user access token: authorization code grant (which spring social's connectcontroller , appropriate traditional web applications), implicit grant (which more appropriate client-side javascript), , resource owner credentials grant (which appropriate mobile or desktop applications doing browser redirect awkward, difficult, or impossible).

the app access token have intended consume api endpoints application-centric , not pertain given user. there few such operations in facebook's api, 1 comes mind can utilize app token create test users (see https://developers.facebook.com/docs/test_users/).

just of facebook's api user-centric, likewise spring social's facebook api binding. if, however, there's app-centric operation you'd see added spring social, i'd appreciate if you'd allow me know @ https://jira.springsource.org/browse/socialfb.

java facebook spring facebook-graph-api spring-social

Time complexity of program that run infinitely -



Time complexity of program that run infinitely -

does time complexity of next segment of programme o(2^n)? i’m confused

n=1; j=1 n output(j); n=2*n; end {for}

no, o(n).

you raising n 2^n power.

this because number of iterations of loop "n", regardless of final reply or computation within it.

time-complexity

symfony2 - PHP GD libray, path to image in Symfony -



symfony2 - PHP GD libray, path to image in Symfony -

i have controller in surgery/patientbundle/constroller/registrationpatientbundlecontroller , in surgery/patientbundle/resources/public/images/test.jpg have image. how path image ? tried code in controller

public testaction(){ header ( 'content-type: image/jpeg' ); $image = imagecreatefromjpeg("../resources/public/images/test.jpg"); imagejpeg($image);

but can't find file.

try :

$image => imagecreatefromjpeg(__dir__.'/../resources/public/images/test.jpg');

php symfony2 gd

c# - Writeline not writing certain tabs to output file -



c# - Writeline not writing certain tabs to output file -

i trying write tab delimited text file info similar below:

colhead1 colhead2 ... colhead10 row1dat1 row1dat2 ... row1dat10 row2dat1 row2dat2 ... row2dat10

however, when debugging code, notice there few tabs don't appear. here code trying:

string columnheaders = string.format("colhead1\tcolhead2\tcolhead3\tcolhead4\tcolhead5\tcolhead6\tcolhead7\tcolhead8\tcolhead9\tcolhead10"); filew.writeline(columnheaders); string row1 = string.format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}", val1, val2, val3, val4, val5, val6, val7, val8, val9, val10); filew.writeline(row1); string row2 = string.format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}", val11, val12, val13, val14, val15, val16, val17, val18, val19, val20); filew.writeline(row2);

specifically, when @ value in row1 or row2, formatted below (on either row):

dat1 dat2(notabhere)dat3 dat4 dat5 dat6 dat7 dat8 dat9(notabhere)dat10

why aren't 2 tabs beingness inserted , can ensure they're inserted properly?

maybe tabs became little because preceding value wide?

0 1 2 15 162 102819201924 . . . . . . . .

c# string-formatting delimiter

Detect installed certificate in my android device -



Detect installed certificate in my android device -

i installing certificate in application when application starts. have gone through few of links below , install certificate.

http://nelenkov.blogspot.in/2011/12/ics-trust-store-implementation.html

http://pastebin.com/bn6qsyhx

how programmatically install ca certificate (for eap wifi configuration) in android?

how install ca certificate programmatically on android without user interaction

i came know cannot install certificate silently without user interaction.currently don't know how stop prompt each time user open app.

whenever application starts every time inquire user install certificate. there way can observe whether certificate(in case certificate) installed or not, programmatically.

code snippet have installing certificate in app

private void installcertificate() { seek { bufferedinputstream bis = new bufferedinputstream(getassets().open(my_cert)); byte[] keychain = new byte[bis.available()]; bis.read(keychain); intent installintent = keychain.createinstallintent(); x509certificate x509 = x509certificate.getinstance(keychain); installintent.putextra(keychain.extra_certificate, x509.getencoded()); installintent.putextra(keychain.extra_name, my_cert); startactivityforresult(installintent, install_keychain_code); } grab (ioexception e) { e.printstacktrace(); } grab (certificateexception e) { e.printstacktrace(); } } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == install_keychain_code) { switch (resultcode) { case activity.result_ok: dothetask(); break; case activity.result_canceled: finish(); break; default: super.onactivityresult(requestcode, resultcode, data); } } }

also fyi, installcertificate() called oncreate().

please help me out same. help appreciated.

query: when prompt comes certificate name, entered text comes selected , on orientation alter cut/copy alternative comes. body knows how stop text selection when prompt comes?!!!

i used below piece of code check whether certificate installed or not

try { keystore ks = keystore.getinstance("androidcastore"); if (ks != null) { ks.load(null, null); enumeration aliases = ks.aliases(); while (aliases.hasmoreelements()) { string alias = (string) aliases.nextelement(); java.security.cert.x509certificate cert = (java.security.cert.x509certificate) ks.getcertificate(alias); if (cert.getissuerdn().getname().contains("mycert")) { iscertexist = true; break; } } } } grab (ioexception e) { e.printstacktrace(); } grab (keystoreexception e) { e.printstacktrace(); } grab (nosuchalgorithmexception e) { e.printstacktrace(); } grab (java.security.cert.certificateexception e) { e.printstacktrace(); }

android certificate

unit testing - Understanding stubs, fakes and mocks. -



unit testing - Understanding stubs, fakes and mocks. -

i have started read professional test driven development c#: developing real world applications tdd

i have hard time understanding stubs, fakes , mocks. understand far, false objects used purpose of unit testing projects, , mock stub conditional logic it.

another thing think have picked mocks somehow related dependency injection, concept managed understand yesterday.

what not why utilize them. cannot seem find concrete examples online explains them properly.

can please explain me concepts?

as i've read in past, here's believe each term stands for

stub

here stubbing result of method known value, allow code run without issues. example, lets had following:

public int calculatedisksize(string networksharename) { // method things on network drive. }

you don't care homecoming value of method is, it's not relevant. plus cause exception when executed if network drive not available. stub result in order avoid potential execution issues method.

so end doing like:

sut.whencalled(() => sut.calculatedisksize()).returns(10);

fake

with false returning false data, or creating false instance of object. classic illustration repository classes. take method:

public int calculatetotalsalary(ilist<employee> employees) { }

normally above method passed collection of employees read database. in unit tests don't want access database. create false employees list:

ilist<employee> fakeemployees = new list<employee>();

you can add together items fakeemployees , assert expected results, in case total salary.

mocks

when using mock objects intend verify behaviour, or data, on mock objects. example:

you want verify specific method executed during test run, here's generic illustration using moq mocking framework:

public void test() { // arrange. var mock = new mock<isomething>(); mock.expect(m => m.methodtocheckifcalled()).verifiable(); var sut = new thingtotest(); // act. sut.dosomething(mock.object); // assert mock.verify(m => m.methodtocheckifcalled()); }

hopefully above helps clarify things bit.

edit: roy osherove know advocate of test driven development, , has info on topic. may find useful :

http://artofunittesting.com/

unit-testing mocking tdd stubs

postgresql - How can I prevent Postgres from inlining a subquery? -



postgresql - How can I prevent Postgres from inlining a subquery? -

here's slow query on postgres 9.1.6, though maximum count 2, both rows identified primary keys: (4.5 seconds)

explain analyze select count(*) tbl id in ('6d48fc431d21', 'd9e659e756ad') , info ? 'building_floorspace' , info ?| array['elec_mean_monthly_use', 'gas_mean_monthly_use']; query plan ---------------------------------------------------------------------------------------------------------------------------------------------------- aggregate (cost=4.09..4.09 rows=1 width=0) (actual time=4457.886..4457.887 rows=1 loops=1) -> index scan using idx_tbl_on_data_gist on tbl (cost=0.00..4.09 rows=1 width=0) (actual time=4457.880..4457.880 rows=0 loops=1) index cond: ((data ? 'building_floorspace'::text) , (data ?| '{elec_mean_monthly_use,gas_mean_monthly_use}'::text[])) filter: ((id)::text = ('{6d48fc431d21,d9e659e756ad}'::text[])) total runtime: 4457.948 ms (5 rows)

hmm, maybe if subquery primary key part first...: (nope, still 4.5+ seconds)

explain analyze select count(*) ( select * tbl id in ('6d48fc431d21', 'd9e659e756ad') ) t info ? 'building_floorspace' , info ?| array['elec_mean_monthly_use', 'gas_mean_monthly_use']; query plan ---------------------------------------------------------------------------------------------------------------------------------------------------- aggregate (cost=4.09..4.09 rows=1 width=0) (actual time=4854.170..4854.171 rows=1 loops=1) -> index scan using idx_tbl_on_data_gist on tbl (cost=0.00..4.09 rows=1 width=0) (actual time=4854.165..4854.165 rows=0 loops=1) index cond: ((data ? 'building_floorspace'::text) , (data ?| '{elec_mean_monthly_use,gas_mean_monthly_use}'::text[])) filter: ((id)::text = ('{6d48fc431d21,d9e659e756ad}'::text[])) total runtime: 4854.220 ms (5 rows)

how can prevent postgres inlining subquery?

background: have postgres 9.1 table using hstore , gist index on it.

i think offset 0 improve approach since it's more hack showing weird going on, , it's unlikely we'll ever alter optimiser behaviour around offset 0 ... wheras ctes become inlineable @ point. next explanation completeness's sake; utilize seamus's answer.

for uncorrelated subqueries can exploit postgresql's refusal inline with query terms rephrase query as:

with t ( select * tbl id in ('6d48fc431d21', 'd9e659e756ad') ) select count(*) t info ? 'building_floorspace' , info ?| array['elec_mean_monthly_use', 'gas_mean_monthly_use'];

this has much same effect offset 0 hack, , offset 0 hack exploits quirks in pg's optimizer people utilize around pg's lack of query hints ... using them query hints.

postgresql indexing subquery inlining

javascript - Change link color onclick without preventDefault() -



javascript - Change link color onclick without preventDefault() -

i need alter color of link if clicked.

if utilize event.preventdefault(); color applied permanently link doesn't work, uri isn't passed , can't utilize $_get['route'] since using mod_rewrite redirect uri's $_get var. ^(.*)$ index.php?route=$1

if don't utilize event.preventdefault link works , section changes, addclass applied while i'am clicking, dissapears...

how can both behaviours ? able pass uri (href), , permanently alter color onclick ?

html:

<a href="./section">section</a>

css:

.active { color: #f00; }

jquery:

$('a').on('click', function(event) { //event.preventdefault $(this).addclass("active"); });

you can seek in doc ready there no need specify .click() event:

try fiddle:http://jsfiddle.net/cmwt8/ $(function(){ var url = window.location.href; // url should way 'http://aaa.com/page/section' var link = url.substr(url.lastindexof('/') + 1); // here 'section' $('[href*="' + link + '"]').addclass("active"); // if found add together class });

javascript jquery html css events

extjs4 - How can I ignore the date picker when I press down in date field -



extjs4 - How can I ignore the date picker when I press down in date field -

i have date field in extjs 4, , want add together custom event downwards arrow key, date field shows picker , lost focus on pressing downwards arrow on keyboard. how can disable event utilize event?

thx answers!

specialkey: function (t, e, opts) { console.log(e.getkey()); var key = e.getkey(); this.keyevents(t, key); }

...

keyevents: function (t, key) { switch(key){ case 38: // break; case 40: // downwards // picker off?????? break; case 37: // left break; case 39: // right break; } }

easiest create subclass of date field , override downwards handling method:

ext.define('mydate', { extend: 'ext.form.field.date', alias: 'widget.mydate', ondownarrow: ext.emptyfn });

extjs4

java - Return statement not working -



java - Return statement not working -

can help me fixing problem. have function checks if file nowadays in particular path. function checks if filenames match , paths match.(a file particular name nowadays in multiple locations). please find below code.

memberpath static variable contains relative path. file_path static variable gets updated when match has been found.

my problem function finds match breaks out of for-loop comes homecoming statement goes loop. can help me prepare code 1 time match found returns bac calling position.

public static string traverse(string path, string filename) { string filepath = null; file root = new file(path); file[] list = root.listfiles(); (file f : list) { if (f.isdirectory()) { traverse(f.getabsolutepath(), filename); } else if (f.getname().equalsignorecase(filename) && f.getabsolutepath().endswith(memberpath)) { filepath = f.getabsolutepath(); file_path = filepath; break ; } } homecoming filepath; }

add :

return traverse(f.getabsolutepath(), filename);

to homecoming value call.

as pointed out - can homecoming value instead of break.

java

html - How to submit form with Javascript -



html - How to submit form with Javascript -

<input type="submit" name="submit" value="submit" onclick="check_form();"></div>

if fields corrects function check_form() homecoming true, want submit form, hwen fields correct, how it. on moments when close javascript alerts form auto submit.

you missing return

<input type="submit" name="submit" value="submit" onclick="return check_form();"></div>

and function

function check_form(){ var isvalid = true; if(.....) { isvalid = false; } homecoming isvalid; }

better yet utilize onsubmit of form since come in key in textbox can submit it.

javascript html forms

path finding - Minimum cost cycle on complete graph -



path finding - Minimum cost cycle on complete graph -

i have complete graph undirected, weighted edges , need find lowest cost cycle through subset of graph nodes. unlike in travelling salesman, any node can visited more once , not all nodes need visited, , cost mean path should have smallest sum of traversed border weights.

for example, here graph in adjacency matrix form:

b c d 0 3 4 5 b 3 0 2 4 c 4 2 0 1 d 5 4 1 0

where weight of each border used each element. cycles starting , ending @ a , including [b,d] like

[a,b,d,a] -> 3+4+5 = 12 [a,b,d,b,a] -> 3+4+4+3 = 14 [a,b,c,d,c,a] -> 3+2+1+1+4 = 11

is there optimal algorithm this, or heuristic one?

cycles starting , ending @ a , including [b,d] means cycle must visit nodes a,b,d. [a,b,d,a] = [b,d,a,b] (cycles right). problem called k-tsp. see here. hard implement , may not looking for.

so give simpler way. first build shortest cycle passes through these nodes. replace each border smallest path between 2 nodes. think reasonable, leave out optimality. here steps :

v=nodes e=edges , m=must-visit nodes. create cycle c running tsp on m (without using other nodes), adding border create cycle. now using nodes v. each border uv in the c, do: find shortest path w between u , v using dijsktra's algorithm (should no negative cycle in graph). replace uv w.

path-finding graph-traversal

c# - Client-side SendEmail-Method doesn't work -



c# - Client-side SendEmail-Method doesn't work -

i want send emails using sharepoint 2013 client object model sendemail-method, "a recipient must specified." error. tried different email addresses , several sharepoint servers, error occurred in cases.

example source (c#):

string weburl = "http://sharepoint.example.com/"; emailproperties properties = new emailproperties(); properties.to = new string[] { "email@example.com" }; properties.subject = "test subject"; properties.body = "test body"; clientcontext context = new clientcontext(weburl); utility.sendemail(context, properties); context.executequery(); // serverexception thrown here context.dispose();

error message:

a recipient must specified.

error type:

system.invalidoperationexception

server stack trace:

@ system.net.mail.smtpclient.send(mailmessage message) @ microsoft.sharepoint.utilities.sputility.sendemail_client(emailproperties properties) @ microsoft.sharepoint.serverstub.utilities.sputilityserverstub.invokestaticmethod(string methodname, xmlnodelist xmlargs, proxycontext proxycontext, boolean& isvoid) @ microsoft.sharepoint.client.serverstub.invokestaticmethodwithmonitoredscope(string methodname, xmlnodelist args, proxycontext proxycontext, boolean& isvoid) @ microsoft.sharepoint.client.clientmethodsprocessor.invokestaticmethod(string typeid, string methodname, xmlnodelist xmlargs, boolean& isvoid) @ microsoft.sharepoint.client.clientmethodsprocessor.processstaticmethod(xmlelement xe) @ microsoft.sharepoint.client.clientmethodsprocessor.processone(xmlelement xe) @ microsoft.sharepoint.client.clientmethodsprocessor.processstatements(xmlnode xe) @ microsoft.sharepoint.client.clientmethodsprocessor.process()

what's wrong here?

i think email recipient must resolved current sharepoint site user. cannot utilize random email address email recipient.

c# email sharepoint-2013 client-object-model

php - more than one text separator style per template in joomla 3.0 -



php - more than one text separator style per template in joomla 3.0 -

let me first explain trying do. in joomla 3.0 have created menu_item_text_separator override template http://docs.joomla.org/help30:menus_menu_item_text_separator. seems though joomla recognize 1 default text separator per template ok if want one. ideally have selection of selecting custom 1 in template folder default 1 joomla recognizes. inform have done create happen.

in template have folder named html had folder called mod_menu within it. in mod_menu folder have .php files called:

default_separator.php custom_separator.php

i go menu manager , edit menu item want display text separator for. i go 'template style' http://docs.joomla.org/help30:menus_menu_item_text_separator , custom style. can take default one.

so wonder if way joomla works can have 1 default per template. possible have more one?

any advice welcome.

regards

w9914420

sorry got long comment.

okay let's start beginning. templates have set of parameters defined in templatedetails.xml file. template style simple record containing info template , array of parameter options have selected. can create many template styles want given template each 1 has own name. in menu can select of styles , assign menu item. ....

what talking has nil template styles. talking using layout override mod_menu. because using file same name core layout file should 1:1 replacement.

from understand of want do, should instead create new named replacemen both default_separator , default.php. that's because alternative layout field going replacement default.php yourname.php , in replacement when load template called separator automatically going yourname_separator rather default_separator because assumes appending _separator base of operations name. if has advantages such able create more complex layout , allow load different sub layouts conditionally example.

php joomla joomla-extensions joomla3.0 joomla-module

python - Dictionary Keys based on list elements and list values -



python - Dictionary Keys based on list elements and list values -

i scanning through document making list of each line read in.

i'm saving list called

testlist = []

when i'm done populating list want set value dictionary key based on element of list. thought should this:

testlist = ['informationa', 'informationb', 'lastinfo'] patent_offices = ['european office', 'japan office'] dict_offices[patent_offices[0]] = testlist

or

dict_offices = {'european office' : ['informationa', 'informationb', 'lastinfo'], 'japan office' : ['other list infoa', 'more infob']}

i want later type dict_offices['european office'] , list printed.

but because i'm collecting dynamically read through document erase , reuse testlist. i've seen after cleared cleared in dictionary's link.

how create dictionary saved can reuse testlist every loop through?

here code:

patent_offices = [] dict_offices = {} office_index = 0 testlist = [] # --- other conditional code not shown if (not patent_match , start_recording): if ( not re.search(r'[=]+', bstring)): #ignore ====== string printstring = fontsstring.encode('ascii', 'ignore') testlist.append(printstring) elif (not start_recording , patent_match): dict_offices[patent_offices[office_index]] = testlist start_recording = true office_index += 1 testlist[:] = []

this dictionary correctly updated , looks want until phone call

testlist[:] = []

line. dictionary goes blank testlist. understand dictionary linked don't know how not have happen.

lists mutable; multiple references same list see changes create it. testlist[:] = [] means: replace every index in list empty list. because reference same list in different places (including in dictionary values), see alter reflected everywhere.

instead, point testlist new empty list instead:

testlist = []

the empty piece assignment syntax used should used if want clear contents of list, not when want create new empty list.

>>> foo = [] >>> bar = foo >>> foo.append(1) >>> bar [1] >>> foo bar true >>> foo[:] = [] >>> bar [] >>> foo = ['new', 'list'] >>> bar [] >>> foo bar false

python list dictionary python-2.7