Saturday, 15 January 2011

lua - Enabling 'websocket' module on Prosody (Windows) -



lua - Enabling 'websocket' module on Prosody (Windows) -

in order enable 'websocket' module (https://code.google.com/p/prosody-modules/wiki/mod_websocket) on prosody, lua used prosody must have bit library installed, such luabitop. thing is: prosody windows uses bundled lua, under 'prosody_home/bin', doesn't have bit library.

i tried placing 'bit.dll' file under 'prosody_home/bin', libraries used bundled lua are, but, upon running prosody, when tries load 'websocket' module, gives error saying lua doesn't have bit library installed.

i found strange; though tested running bundled lua console , inputing:

require"bit"

it didn't give me error , able utilize without problems. on side note: can't utilize xmpp server, have utilize prosody.

any ideas on how create work?

thanks.

uppon doing @siffiejoe suggested, discovered looking under 'prosody_home/lib' , 'prosody_home/src'; i've set 'bit.dll' under 'prosody_home/lib' , worked.

windows lua websocket xmpp

c# 4.0 - Asynchronous Task controllers in C#4 -



c# 4.0 - Asynchronous Task controllers in C#4 -

i want write asynchronous controller displaying in output ienumerable<ienumerable<video>> i don't know can manage write correctly function task<ienumerable<ienumerable<video>>> getvideosasync(xxxxx) task.continuewhenall function (in order not have blocking code ). improve utilize lambda piece of code ...?

can help me ?

nb: *i can utilize c#4 , visual studio 2010

public class homecontroller : asynccontroller { string[] sources = { "http://xxxx/membervideos/1", "http://xxxx/membervideos/2" }; public task<actionresult> async() { var sw = stopwatch.startnew(); var info = getvideosasync(); sw.stop(); viewbag.elapsed = sw.elapsedmilliseconds; homecoming view("~/views/home/index.cshtml", data); } task<ienumerable<ienumerable<video>>> getvideosasync() { var allvideostasks = new list<task<ienumerable<video>>>(); foreach (var url in sources) { allvideostasks.add(downloaddataasync(url)); } var context = taskscheduler.fromcurrentsynchronizationcontext(); task.factory.continuewhenall<ienumerable<video>,ienumerable<ienumerable<video>>( /// code finish here ); task<ienumerable<video>> downloaddataasync(string url) { var httpclient = new httpclient(); var httpresponsemessage = httpclient.getasync(url); var result = httpresponsemessage.continuewith (t => { t.result.ensuresuccessstatuscode(); homecoming t.result.content.readasasync<ienumerable<video>>(); } ).unwrap(); homecoming result; } /**** view ******/ @{ viewbag.title = "home page"; } @model ienumerable<ienumerable<mvcapplication1.models.video>> <table> @foreach (var membervideos in model) { <tr> @foreach(var video in membervideos){ <td> <div>@video.title</div> <div><img src="http://xxxxxx/membervideos/@video.imageurl" style="width: 185px;"/> </div> </td> } </tr> } </table> <h1>@viewbag.elapsed</h1>

c#-4.0 asynchronous

ruby on rails - Why does RSpec report a syntax error in this spec? -



ruby on rails - Why does RSpec report a syntax error in this spec? -

when trying run rspec maintain getting error message below when running bundle exec rspec spec/models/user_spec.rb command. have searched similar issues , have seen suggestions entering in exact paths , making sure in root directory. neither have worked. additionally, have tried running bundle install. apologize if rudimentary question. i'm total noob. in advance help.

/users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': /users/sethjones/rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected '}', expecting => (syntaxerror) /users/sethjones/rails_projects/sample_app/spec/models/user_spec.rb:20: syntax error, unexpected end-of-input, expecting keyword_end /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files' /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each' /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files' /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run' /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run' /users/sethjones/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

my gemfile follows:

source 'https://rubygems.org' ruby '2.0.0' gem 'rails', '4.0.5' gem 'bootstrap-sass', '2.3.2.0' gem 'sprockets', '2.11.0' gem 'bcrypt-ruby', '3.1.2' gem 'faker', '1.1.2' gem 'will_paginate', '3.0.4' gem 'bootstrap-will_paginate', '0.0.9' grouping :development, :test gem 'sqlite3', '1.3.8' gem 'rspec-rails', '2.13.1' # next optional lines part of advanced setup. # gem ’guard-rspec’, ’2.5.0’ # gem ’spork-rails’, ’4.0.0’ # gem ’guard-spork’, ’1.5.0’ # gem ’childprocess’, ’0.3.6’ end grouping :test gem 'selenium-webdriver', '2.35.1' gem 'capybara', '2.1.0' gem 'factory_girl_rails', '4.2.0' gem 'cucumber-rails', '1.4.0', :require => false gem 'database_cleaner', github: 'bmabey/database_cleaner' gem 'growl', '1.0.3' # uncomment these lines on linux. # gem ’libnotify’, ’0.8.0'gem # uncomment these lines on windows. # gem ’rb-notifu’, ’0.0.4’ # gem ’wdm’, ’0.1.0’ end gem 'sass-rails', '4.0.1' gem 'uglifier', '2.1.1' gem 'coffee-rails', '4.0.1' gem 'jquery-rails', '3.0.4' gem 'turbolinks', '1.1.1' gem 'jbuilder', '1.0.2' grouping :doc gem 'sdoc', '0.3.20', require: false end grouping :production gem 'pg', '0.15.1' gem 'rails_12factor', '0.0.2' end

and user_spec.rb file looks this:

require 'spec_helper' describe user before { @user = user.new(name: "example user", email: "user@example.com") } end subject { @user } { should respond_to(:name) } { should respond_to(:email) } { should be_valid } describe "when name not present" before { @user.name = " "} { should_not be_valid } end end

thanks again!

the block you're passing before surrounded both do/end , curly braces. since curlies don't follow method invocation, ruby interprets them hash, , expects => before closing curly. remove curlies.

ruby-on-rails ruby rspec rspec-rails

How to import a managed c++ library to C# app (target .net version 3.5) -



How to import a managed c++ library to C# app (target .net version 3.5) -

i created managed c++ library (wrapper) in visual studio uses non-managed c++ library. wrapped used c# application uses .net framework 3.5.

in c++ add together additional dependecies linker , re-create .lib files , .h files of external library folder source files exists. setup 32bit platform , release configuration , build solution. dll created reference in c# application's configuration.

everything ok when utilize illustration .net 4.5 in c# , c++, c# must using 3.5 version. read need build c++ library in older visual studio (i tried 2005 , 2008). setted v90 build tools , 3.5 .net version , built dll.

when build c# project no errors shown, after running got such error:

i checked dependecies of library , result (i wrote version next every item, of them 4.0.0.0, 2.0.0.0). i'm struggling few hours , have no thought how create working..

the exception class, filenotfoundexception, little misleading. error code (0x8007007e) says more. that's com error code represents win32 error code.

how can tell that? well, structure of com error codes described on msdn. 8 indicates error, , 7 facility, facility_win32. so, com error code of form 0x8007xxxx win32 error code. win32 error code wrapped found in to the lowest degree important word. here 0x007e error_mod_not_found. associated text is:

the specified module not found.

that error occurs when scheme attempts load unmanaged dll , cannot locate it. managed assembly appear depend upon unmanaged dlls, , @ to the lowest degree 1 of them cannot found. commonly that:

the main unmanaged dll managed assembly wraps cannot found, or, the msvc runtime unmanaged dll requires cannot found.

you'll need dig little deeper in documentation managed assembly work out problem is. points in right direction. , hope i've given pointers how decode error codes in future.

c# c++ visual-studio

php - Get Id from post that I just created - Facebook Graph API -



php - Get Id from post that I just created - Facebook Graph API -

i creating posts via graph api need id utilize later.

this code using in php, can help me showing how id after creating post?

i tried $response->id or $graphobject->id didn't work. also, need utilize $graphobject in lastly line of code? saw somewhere else don't know does.

i did print_r in $graphobject , received aswer: facebook\graphobject object ( [backingdata:protected] => array ( [id] => 741760479220480 ) )

thanks

<?php session_start(); require_once( 'facebook/facebookhttpable.php' ); require_once( 'facebook/facebookcurl.php' ); require_once( 'facebook/facebookcurlhttpclient.php' ); require_once( 'facebook/facebooksession.php' ); require_once( 'facebook/facebookredirectloginhelper.php' ); require_once( 'facebook/facebookrequest.php' ); require_once( 'facebook/facebookresponse.php' ); require_once( 'facebook/facebooksdkexception.php' ); require_once( 'facebook/facebookrequestexception.php' ); require_once( 'facebook/facebookclientexception.php' ); require_once( 'facebook/facebookotherexception.php' ); require_once( 'facebook/facebookauthorizationexception.php' ); require_once( 'facebook/facebookpermissionexception.php' ); require_once( 'facebook/facebookserverexception.php' ); require_once( 'facebook/graphobject.php' ); require_once( 'facebook/graphsessioninfo.php' ); require_once( 'facebook/graphuser.php' ); utilize facebook\facebookhttpable; utilize facebook\facebookcurl; utilize facebook\facebookcurlhttpclient; utilize facebook\facebooksession; utilize facebook\facebookredirectloginhelper; utilize facebook\facebookrequest; utilize facebook\facebookresponse; utilize facebook\facebooksdkexception; utilize facebook\facebookrequestexception; utilize facebook\facebookclientexception; utilize facebook\facebookotherexception; utilize facebook\facebookauthorizationexception; utilize facebook\facebookpermissionexception; utilize facebook\facebookserverexception; utilize facebook\graphobject; utilize facebook\graphsessioninfo; utilize facebook\graphuser; facebooksession::setdefaultapplication('app','password'); $session = new facebooksession('token'); $message = 'test'; $link = "http://www.example.com.br"; $description = 'description'; $name = 'name'; $caption = 'caption'; $request = new facebookrequest( $session, 'post', '/page_id/feed', array ( 'message' => $message, 'link' => $link, 'description' => $description, 'published' => 'false', 'name' => $name, 'caption' => $caption, ) ); $response = $request->execute(); $graphobject = $response->getgraphobject(); ?>

according https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/#publish should

$post_id = $graphobject->id;

php facebook facebook-graph-api

vb.net - How do I convert from entity/property names (conceptual) to table/column names (store)? (Trial code [in VB 2010 and EF 4] uses reflection.) -



vb.net - How do I convert from entity/property names (conceptual) to table/column names (store)? (Trial code [in VB 2010 and EF 4] uses reflection.) -

i plan add together supplementary (unique) indexes entities' tables. since can't have more 1 ef key entity, other indexes need created using constraint sql, in turns means converting between entity , property names (conceptual model) , table , column names (database store). i've taken next code person (and converted vb):

imports system.data.objects imports system.data.entity imports system.data.sqlclient imports system.data.entityclient imports system.data.metadata.edm imports system.data.objects.dataclasses imports system.linq.expressions imports system.runtime.serialization imports system.reflection public class convertconceptualtostore private shared function gettablename(of t entityobject)() string dim type type = gettype(t) dim @ edmentitytypeattribute = getattribute(of edmentitytypeattribute)(type) homecoming at.name end function private shared function getcolumnname(of t entityobject) _ (byval propertyselector expression(of func(of t, object))) string if propertyselector nil throw new exception("""" & propertyselector.tostring & """ null.") end if dim propertyinfo propertyinfo = getpropertyinfo(propertyselector.body) dim attribute datamemberattribute = _ getattribute(of datamemberattribute)(propertyinfo) if string.isnullorempty(attribute.name) homecoming propertyinfo.name else homecoming attribute.name end if end function private shared function getattribute(of t class)(byval memberinfo memberinfo) t if memberinfo nil throw new exception("""" & memberinfo.tostring & """ null.") end if dim customattributes() object = _ memberinfo.getcustomattributes(gettype(t), false) dim attribute t = _ directcast(customattributes.where(function(a) typeof t).first(), t) homecoming attribute end function private shared function getpropertyinfo(byval propertyselector expression) propertyinfo if propertyselector nil throw new exception("""" & propertyselector.tostring & """ null.") end if dim memberexpression memberexpression = _ trycast(propertyselector, memberexpression) if memberexpression nil dim unaryexpression unaryexpression = _ trycast(propertyselector, unaryexpression) if unaryexpression isnot nil _ andalso unaryexpression.nodetype = expressiontype.convert memberexpression = trycast(unaryexpression.operand, memberexpression) end if end if if memberexpression isnot nil _ andalso memberexpression.member.membertype = membertypes.property homecoming directcast(memberexpression.member, propertyinfo) else throw new argumentexception("no property reference found.", "propertyselector") end if end function ' invocation illustration public shared sub test() dim table string = gettablename(of entity)() dim column string = getcolumnname(of entity)(function(entity) entity.property) end sub end class

i need know things:

i don't need objectcontext code, i? what if property need convert field part of complex property? need augment or modify code such situation? (i.e., suppose have entity called location, complex property of address, , need field address.street. use, columnname = getcolumnname(of location) (function(location) location.address.street), or have more?) suppose code doesn't know beforehand names of entity , property. there way adapt code take string value each (at to the lowest degree property name; i.e., "entity.property"), find appropriate class/property reference therefrom?

please reply these questions asap!

here's general-purpose algorithm converting between conceptual , store information, written in visual basic 2010.

i have written new routine convert entity/property pair table/column pair. class, mslmappingaction, takes in constructor model name , either xelement xml tree, msl mapping file, or xml string. 1 uses conceptualtostore method take string specifying entity , property "expressions" (stored in mslconceptualinfo structure) , find table , column names (stored in mslstoreinfo structure).

notes:

one write "storetoconceptual" method convert in other direction, xml queries bit more complex. same goes handling navigation-propery/function/stored-procedure mappings. beware inherited properties of derived entities! if property not specific derived entity, should utilize base of operations entity's name.)

here's code.

host code: (for xml sample given [see bottom], returns table name "locations" , column name "address_street" store info when given entity "location" , property look "address.street" [and conceptual model name "sctmodel"]):

dim msl mslmappingaction = new mslmappingaction(".\sctmodel.msl", "sctmodel") dim conceptualinfo mslconceptualinfo = new mslconceptualinfo {.entityname = "location", .propertyname = "address.street"} dim storeinfo mslstoreinfo = msl.conceptualtostore(conceptualinfo) messagebox.show(storeinfo.tablename & ": " & storeinfo.columnname)

class code:

option infer on imports system.xml.linq ''' <summary> ''' class allows 1 convert between ef conceptual model's entity/property pair ''' , database store's table/column pair. ''' </summary> ''' <remarks>it takes business relationship entity splitting , complex-property designations; ''' not take business relationship inherited properties ''' (in such case, should access entity's base of operations class)</remarks> public class mslmappingaction ' private fields , routines private mmamslmapping xelement private mmamodelname, mmanamespace string private function fullelementname(byval elementname string) string ' pre-pend namespace elementname homecoming "{" & mmanamespace & "}" & elementname end function private sub validateparams(byval mappingxml xelement, byval modelname string) ' verify model name specified if string.isnullorempty(modelname) throw new entityexception("entity model name not given!") end if ' verify we're using c-s space if mappingxml.@space <> "c-s" throw new metadataexception("xml not c-s mapping data!") end if ' namespace , set private variables mmanamespace = mappingxml.@xmlns mmamslmapping = mappingxml : mmamodelname = modelname end sub private function issequenceempty(items ienumerable(of xelement)) boolean ' determine if query result empty homecoming _ items nil orelse items.count = 0 end function ' properties ''' <summary> ''' name of conceptual entity model ''' </summary> ''' <returns>conceptual-model string</returns> ''' <remarks>model name can set in constructor</remarks> public readonly property entitymodelname() string homecoming mmamodelname end end property ''' <summary> ''' name of mapping namespace ''' </summary> ''' <returns>namespace string of c-s mapping layer</returns> ''' <remarks>this value determined when xml mapping ''' first parsed in constructor</remarks> public readonly property mappingnamespace() string homecoming mmanamespace end end property ' constructors ''' <summary> ''' c-s mapping info entity model (with xml tree) ''' </summary> ''' <param name="mappingxml">xml mapping tree</param> ''' <param name="modelname">conceptual-model name</param> ''' <remarks></remarks> public sub new(byval mappingxml xelement, byval modelname string) validateparams(mappingxml, modelname) end sub ''' <summary> ''' c-s mapping info entity model (with xml file) ''' </summary> ''' <param name="mslfile">msl mapping file</param> ''' <param name="modelname">conceptual-model name</param> ''' <remarks></remarks> public sub new(byval mslfile string, byval modelname string) dim mappingxml xelement = xelement.load(mslfile) validateparams(mappingxml, modelname) end sub ' methods ''' <summary> ''' c-s mapping infomration entity model (with xml string) ''' </summary> ''' <param name="xmlstring">xml mapping string</param> ''' <param name="modelname">conceptual-model name</param> ''' <returns></returns> public shared function parse(byval xmlstring string, byval modelname string) homecoming new mslmappingaction(xelement.parse(xmlstring), modelname) end function ''' <summary> ''' convert conceptual entity/property info store table/column info ''' </summary> ''' <param name="conceptualinfo">conceptual-model info ''' (.entityname = entity look string, .propertyname = property look string)</param> ''' <returns>store info (.tablename = table-name string, .columnname = column-name string)</returns> ''' <remarks></remarks> public function conceptualtostore(byval conceptualinfo mslconceptualinfo) mslstoreinfo dim storeinfo new mslstoreinfo conceptualinfo ' prepare query xml if not .entityname.contains(".") ' create sure entity name qualified .entityname = mmamodelname & "." & .entityname end if ' separate property names if there's complex-type nesting dim properties() string = .propertyname.split(".") ' relevant entity mapping dim mappinginfo ienumerable(of xelement) = _ (from mi in mmamslmapping.descendants(fullelementname("entitytypemapping")) _ mi.@typename = "istypeof(" & .entityname & ")" _ orelse mi.@typename = .entityname _ select mi) ' create sure entity in model if issequenceempty(mappinginfo) throw new entityexception("entity """ & .entityname & """ not found!") end if ' mapping fragments dim mappingfragments ienumerable(of xelement) = _ (from mf in mappinginfo.descendants(fullelementname("mappingfragment")) _ select mf) ' create sure there's @ to the lowest degree 1 fragment if issequenceempty(mappingfragments) throw new entityexception("entity """ & .entityname & """ not mapped!") end if ' search each mapping fragment desired property each mappingfragment in mappingfragments ' physical table fragment storeinfo.tablename = mappingfragment.@storeentityset ' search property look chain dim propertymapping ienumerable(of xelement) = {mappingfragment} ' parse complex property info (if any) index = 0 ubound(properties) - 1 ' go downwards 1 level dim complexpropertyname = properties(index) propertymapping = _ (from pm in propertymapping.elements(fullelementname("complexproperty")) _ pm.@name = complexpropertyname) ' verify property specified level exists if issequenceempty(propertymapping) exit 'go next fragment if not end if next index ' property not found? seek next fragment if issequenceempty(propertymapping) go on end if ' parse scalar property info dim scalarpropertyname = properties(ubound(properties)) dim columnname string = _ (from pm in propertymapping.elements(fullelementname("scalarproperty")) _ pm.@name = scalarpropertyname _ select cn = pm.@columnname).firstordefault ' verify scalar property exists if not string.isnullorempty(columnname) ' yes? homecoming (exit) column info storeinfo.columnname = columnname : homecoming storeinfo end if next mappingfragment ' property wasn't found throw new entityexception("property """ & .propertyname _ & """ of entity """ & .entityname & """ not found!") end end function end class ''' <summary> ''' conceptual-model entity , property info ''' </summary> public construction mslconceptualinfo ''' <summary> ''' name of entity in conceptual model ''' </summary> ''' <value>entity look string</value> ''' <remarks>entityname may or may not qualified (i.e., "modelname.entityname"); ''' when mapping method called mslmappingaction class, conceptual model's ''' name , period pre-pended if it's omitted</remarks> public property entityname string ''' <summary> ''' name of property in entity ''' </summary> ''' <value>property look string</value> ''' <remarks>propertyname may either stand-alone scalar property or scalar property ''' within 1 or more levels of complex-type properties; in latter case, must ''' qualified (i.e., "complexpropertyname.innercomplexpropertyname.scalarpropertyname")</remarks> public property propertyname string end construction ''' <summary> ''' database-store table , column info ''' </summary> public construction mslstoreinfo ''' <summary> ''' name of table in database ''' </summary> public property tablename string ''' <summary> ''' name of column in database table ''' </summary> public property columnname string end construction

the grab node names have have namespace prepended them. tripped me until checked elements 1 @ time!

here's sample xml -- load ".\sctmodel.msl" file in code above:

<?xml version="1.0" encoding="utf-8"?> <mapping space="c-s" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs"> <entitycontainermapping storageentitycontainer="sctmodelstorecontainer" cdmentitycontainer="socialcontactstracker"> <entitysetmapping name="socialcontacts"> <entitytypemapping typename="istypeof(sctmodel.socialcontact)"> <mappingfragment storeentityset="socialcontacts"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="dateadded" columnname="dateadded" /> <scalarproperty name="information" columnname="information" /> <complexproperty name="defaultassociations" typename="sctmodel.defaultassociations"> <scalarproperty name="defaultlocationid" columnname="defaultassociations_defaultlocationid" /> <scalarproperty name="defaultemailid" columnname="defaultassociations_defaultemailid" /> <scalarproperty name="defaultphonenumberid" columnname="defaultassociations_defaultphonenumberid" /> <scalarproperty name="defaultwebsiteid" columnname="defaultassociations_defaultwebsiteid" /> </complexproperty> <scalarproperty name="picture" columnname="picture" /> </mappingfragment> </entitytypemapping> <entitytypemapping typename="istypeof(sctmodel.person)"> <mappingfragment storeentityset="socialcontacts_person"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="dateofbirth" columnname="dateofbirth" /> <scalarproperty name="firstname" columnname="firstname" /> <scalarproperty name="lastname" columnname="lastname" /> </mappingfragment> </entitytypemapping> <entitytypemapping typename="istypeof(sctmodel.organization)"> <mappingfragment storeentityset="socialcontacts_organization"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="name" columnname="name" /> <scalarproperty name="dateofcreation" columnname="dateofcreation" /> </mappingfragment> </entitytypemapping> </entitysetmapping> <entitysetmapping name="locations"> <entitytypemapping typename="istypeof(sctmodel.location)"> <mappingfragment storeentityset="locations"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="city" columnname="city" /> <scalarproperty name="state" columnname="state" /> <scalarproperty name="zip" columnname="zip" /> <scalarproperty name="country" columnname="country" /> <complexproperty name="address" typename="sctmodel.address"> <scalarproperty name="street" columnname="address_street" /> <scalarproperty name="apartment" columnname="address_apartment" /> <scalarproperty name="housenumber" columnname="address_housenumber" /> </complexproperty> </mappingfragment> </entitytypemapping> </entitysetmapping> <entitysetmapping name="phonenumbers"> <entitytypemapping typename="istypeof(sctmodel.phonenumber)"> <mappingfragment storeentityset="phonenumbers"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="number" columnname="number" /> <scalarproperty name="phonetype" columnname="phonetype" /> </mappingfragment> </entitytypemapping> </entitysetmapping> <entitysetmapping name="emails"> <entitytypemapping typename="istypeof(sctmodel.email)"> <mappingfragment storeentityset="emails"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="domainname" columnname="domainname" /> <scalarproperty name="username" columnname="username" /> </mappingfragment> </entitytypemapping> </entitysetmapping> <entitysetmapping name="websites"> <entitytypemapping typename="istypeof(sctmodel.website)"> <mappingfragment storeentityset="websites"> <scalarproperty name="id" columnname="id" /> <scalarproperty name="url" columnname="url" /> </mappingfragment> </entitytypemapping> </entitysetmapping> <associationsetmapping name="socialcontactwebsite" typename="sctmodel.socialcontactwebsite" storeentityset="socialcontactwebsite"> <endproperty name="socialcontact"> <scalarproperty name="id" columnname="socialcontacts_id" /> </endproperty> <endproperty name="website"> <scalarproperty name="id" columnname="websites_id" /> </endproperty> </associationsetmapping> <associationsetmapping name="socialcontactphonenumber" typename="sctmodel.socialcontactphonenumber" storeentityset="socialcontactphonenumber"> <endproperty name="socialcontact"> <scalarproperty name="id" columnname="socialcontacts_id" /> </endproperty> <endproperty name="phonenumber"> <scalarproperty name="id" columnname="phonenumbers_id" /> </endproperty> </associationsetmapping> <associationsetmapping name="socialcontactemail" typename="sctmodel.socialcontactemail" storeentityset="socialcontactemail"> <endproperty name="socialcontact"> <scalarproperty name="id" columnname="socialcontacts_id" /> </endproperty> <endproperty name="email"> <scalarproperty name="id" columnname="emails_id" /> </endproperty> </associationsetmapping> <associationsetmapping name="socialcontactlocation" typename="sctmodel.socialcontactlocation" storeentityset="socialcontactlocation"> <endproperty name="socialcontact"> <scalarproperty name="id" columnname="socialcontacts_id" /> </endproperty> <endproperty name="location"> <scalarproperty name="id" columnname="locations_id" /> </endproperty> </associationsetmapping> </entitycontainermapping> </mapping>

vb.net visual-studio-2010 linq reflection entity-framework-4

Android activity, share a user photo on facebook -



Android activity, share a user photo on facebook -

i share user photo facebook (source existing photo or new photo camera). share contains:

name app link app title and/or description photo

is possibile without facebook login android app? tried facebookdialog values set doesn't work.

facebookdialog sharedialog = new facebookdialog.sharedialogbuilder(this) .setapplicationname("superselfie") .setname("hi all:") .setpicture(fileuri.getpath()) .setdescription("selfie...") .setlink( "https://play.google.com/store/apps/details?id=project.stats") .build(); uihelper.trackpendingdialogcall(sharedialog.present());

what necessary?

facebookdialog without login facebook login? open graph? others?

please help me.. thanks

android facebook facebook-graph-api

sql - How can I add a running total of one column to an Access query? -



sql - How can I add a running total of one column to an Access query? -

i have query contains in 1 field percentage of total sales corresponding specific product in past 12 months. example:

product 1 - 38% product 2 - 25% product 3 - 16% (...)

the records sorted in descending order percentage column, , sum of has 100%. want create new column adds previous percentages running total, this:

product 1 - 38% - 38% product 2 - 25% - 63% product 3 - 16% - 79% (... until reaches lastly product , 100% sub-total)

how this?

if have id field, or date field, can utilize variation of correlated subquery.

select t.*, t.productpct+[prev_value] runningsum, (select sum([productpct]) test t2 t2.id < t.id ) prev_value test t;

there people way improve @ sql i, if helps or gives reply great.

sql ms-access access-vba ms-access-2007

getting stared with HDF5 on Visual Studio 2013 with Visual C++ 2013 -



getting stared with HDF5 on Visual Studio 2013 with Visual C++ 2013 -

i having hard time getting hdf5 illustration working visual studio 2013 (c++). illustration at: http://www.hdfgroup.org/ftp/hdf5/examples/misc-examples/stratt.cpp , i've posted code below completeness.

my first question is: latest hdf5 (version 1.8.13) work visual c++ 2013? docs mention 2012 can see, i've had no problems using 2013 2012 mentioned.

i tried illustration programme both 32 bit , 64 bit app. ultimately, i'm interested in 64 bit. in project settings 32 bit, under vc++ settings, added include directories: c:\program files (x86)\hdf_group\hdf5\1.8.13\include library directories, added: c:\program files (x86)\hdf_group\hdf5\1.8.13\lib

to linker->input, added: hdf5.lib;hdf5_cpp.lib when ran, (not unexpectedly) got message, "the programme can't start because hdf5.dll missing computer..." debug directory, added, hdf5.dll , hdf5_cpp.dll directory: c:\program files (x86)\hdf_group\hdf5\1.8.13\bin

i runtime error:

the application unable start correctly (0xc000007b). click ok close application. ideas?

incidentally, when tried x64 bit version (using 64 bit setttings, directories , files), got different errors. programme runs end, no attribute written console, no file produced, , dreaded error @ end (after hitting f10 on lastly line):

unhandled exception @ 0x000007fef05e512d (msvcp120d.dll) in hdf5attributeexample2.exe: 0xc0000005: access violation reading location 0xffffffffffffffff.

in both cases (32 , 64 bit) gut tells me have sort of configuration problem (wrong lib, wrong setup, etc.) i'd appreciate help or suggestions folks can offer.

if there visual c++ hdf5 example, means please tell me!

thanks,

dave

#include <string> #include <iostream> #include "h5cpp.h" using std::cout; using std::endl; using namespace h5; const h5std_string file_name("string_test.h5"); const h5std_string ds_name("data set 1"); const h5std_string attr_name("string attribute"); int main(void) { // create named file h5file file = h5file(file_name, h5f_acc_trunc); // create new dataspace dataset const int rank = 3; const int dim1 = 2; const int dim2 = 2; const int dim3 = 2; hsize_t dims[rank] = { dim1, dim2, dim3 }; dataspace dataspace = dataspace(rank, dims); // create new datatype dataset floattype datatype(predtype::native_float); // create dataset dataset dataset = file.createdataset(ds_name, datatype, dataspace); // set write buffer 'matrix' int q, r, s; float value; float matrix[dim1][dim2][dim3]; (q = 0; q < dim1; q++) (r = 0; r < dim2; r++) (s = 0; s < dim3; s++) { value = 1.111 + (q * r * s); matrix[q][r][s] = value; } // write info dataset dataset.write(matrix, datatype); // create new dataspace attribute dataspace attr_dataspace = dataspace(h5s_scalar); // create new string datatype attribute strtype strdatatype(predtype::c_s1, 256); // of length 256 characters // set write buffer attribute const h5std_string strwritebuf("this attribute of type strtype"); // create attribute , write attribute myatt_in = dataset.createattribute(attr_name, strdatatype, attr_dataspace); myatt_in.write(strdatatype, strwritebuf); // set read buffer attribute h5std_string strreadbuf(""); // open attribute , read contents attribute myatt_out = dataset.openattribute(attr_name); myatt_out.read(strdatatype, strreadbuf); // display attribute contents cout << "attribute contents: " << strreadbuf << endl; homecoming 0; }

doesn't many people interested in hdf5 visual c++ judging number of views. perhaps should warning me! in case, posterity offer next answers original question.

first of all, 1 needs careful path variable right in environments settings , set correctly 32 bit or 64 bit depending on want. instead of: c:\program files (x86)\hdf_group\hdf5\1.8.13\bin have: c:\program files (x86)\hdf group\hdf5\1.8.13\bin (notice missing underscore)

additionally, 1 has pay attending want 32 bit (use programme file (x86)) or 64 bit (use programme files). if knows of easier way run 32 bit , 64 bit programs on same machine utilize hdf5, please allow me know.

the other major problem illustration code itself. in it's original form, did not work. after much trial , error, tracked problem downwards utilize of h5std_string. when replaced these char [], worked. example, instead of using: const h5std_string file_name("string_test.h5"); used: char filename[128] = "string_test.h5"; , used h5file constructor so: h5file file = h5file(filename, h5f_acc_trunc); it's annoying didn't compile time error. constructor claims take std::string (which h5std_string is) in constructor h5file. quite possibly, there visual studio setting somewhere makes things original code work. i'm not knowledgeable plenty visual c++ know.

anyhow luck all.

dave

visual-c++ visual-studio-2013 hdf5

php - Accessing variables defined in form type in twig -



php - Accessing variables defined in form type in twig -

i don't know wrong twig cannot access variables , i'm getting method "name, origin, car" object "symfony\component\form\formview" not exist in carbrandbundle:default:both.html.twig @ line of them. missing? believe not twig issue.

note: 1-to-n relationship , 1 brand can have many cars.

brand entity

namespace car\brandbundle\entity; utilize doctrine\orm\mapping orm; utilize doctrine\common\collections\arraycollection; class brandentity { protected $id; protected $name; protected $origin; /** * @orm\onetomany(targetentity = "carentity", mappedby = "brand") * @var object $car */ protected $car; /** * constructor. */ public function __construct() { $this->car = new arraycollection(); } }

car entity

namespace car\brandbundle\entity; utilize doctrine\orm\mapping orm; class carentity { protected $id; protected $model; protected $price; /** * @orm\manytoone(targetentity="brandentity", inversedby="car") * @orm\joincolumn(name="brand_id", referencedcolumnname="id") * @var object $brand */ protected $brand; }

car form type

namespace car\brandbundle\form\type; utilize symfony\component\form\abstracttype; utilize symfony\component\form\formbuilderinterface; utilize symfony\component\optionsresolver\optionsresolverinterface; class cartype extends abstracttype { public function buildform(formbuilderinterface $builder, array $options) { $builder ->setaction($options['action']) ->setmethod('post') ->add('model', 'text', array('label' => 'model')) ->add('price', 'text', array('label' => 'price')) ->add('button', 'submit', array('label' => 'add')) ; } public function setdefaultoptions(optionsresolverinterface $resolver) { $resolver->setdefaults(array( 'data_class' => 'car\brandbundle\entity\carentity') ); } public function getname() { homecoming 'car'; } }

both form type

namespace car\brandbundle\form\type; utilize symfony\component\form\abstracttype; utilize symfony\component\form\test\formbuilderinterface; utilize symfony\component\optionsresolver\optionsresolverinterface; class bothtype extends abstracttype { public function builder(formbuilderinterface $builder, array $options) { $builder ->setaction($options['action']) ->setmethod('post') ->add('name', 'text', array('label' => 'name')) ->add('origin', 'text', array('label' => 'origin')) ->add('car', 'collection', array('type' => new cartype())) ->add('button', 'submit', array('label' => 'add')) ; } public function setdefaultoptions(optionsresolverinterface $resolver) { $resolver->setdefaults(array( 'data_class' => 'car\brandbundle\entity\brandentity', 'cascade_validation' => true )); } public function getname() { homecoming 'both'; } }

controller

namespace car\brandbundle\controller; utilize car\brandbundle\entity\brandentity; utilize car\brandbundle\form\type\bothtype; utilize symfony\bundle\frameworkbundle\controller\controller; class bothcontroller extends controller { public function indexaction() { $form = $this->createform(new bothtype(), new brandentity(), array('action' => $this->generateurl('bothcreate'))); homecoming $this->render('carbrandbundle:default:both.html.twig', array('page' => 'both', 'form' => $form->createview())); } }

twig

{{ form_label(form.name) }} {{ form_widget(form.name) }} {{ form_label(form.origin) }} {{ form_widget(form.origin) }} {% c in form.car %} {{ form_row(c.model) }} {% endfor %}

your problem lies entities. need getter & setters protected properties. in example:

protected $name; /** * set name * * @param string $name * @return brand */ public function setname($name) { $this->source = $name; homecoming $this; } /** * name * * @return string */ public function getname() { homecoming $this->name; }

php symfony2 twig

jquery - Add custom property in attributes magento -



jquery - Add custom property in attributes magento -

in magento, in page product, have products , can filters them. display 10 filters , want show 5 , hide 5, can in jquery .show()/.hide(). display not problem, th problem how can know if filter visible or not.

i think need add together custom property attributes, don't know how ?

not exclusively sure asking, if want give product new attribute, first

go catalog - attributes - manage attributes. click "add new attribute" fill in details type of attribute want. want dropdown values of "show" , "hide" for sake of example, assume have filled in attribute code "newattribute"

now, can add together products

go catalog - attributes - manage attributes sets , clicking product type want add together to drag , drop new attribute "unassigned attributes" area list of used attributes click "save attribute set"

your new fields appear when add together product.

to retrieve info in template, should utilize function along lines of

$_newattribute=$_product->getnewattribute();

newattribute name of attribute's code.

( note $_product object have have been defined first - should have been on page displaying product )

alternatively, if mean want utilize jquery know if visible or not, there solution here: jquery observe if element visible

jquery magento

asp.net mvc - Passing multiple parameters to an MVC controller -



asp.net mvc - Passing multiple parameters to an MVC controller -

i've searched , found several questions similar mine, answers specific op's situation help.

on main view, have table of items , action links each of items:

item name actions item #1 foo | bar item #2 foo | bar

the main view displays table next code:

@foreach (var item in model) { <tr> <td>@html.displayfor(modelitem => item.title)</td> <td> @html.actionlink("foo", "index", "test", item, null) | @html.actionlink("bar", "index", "test", item , null) </td> </tr> }

as can see, each item in main view's table links test controller/view.

the test controller's index action defined as:

public actionresult index(item item) { homecoming view(item); }

the test view defined take item model:

@model models.item

this works , test view displays item object's data.

however, need foo , bar display test controller/view in 2 distinct ways, or modes.

something like:

?mode=foo&item=item ?mode=bar&item=item

how pass both item object , mode test controller test view behave appropriately based on mode?

add mode route values. you'll have expand item's properties

@html.actionlink("foor", "index", "test", new { mode = "foo", propa = item.propa }, null)

asp.net-mvc asp.net-mvc-4

php - Trying to get property of non-object in controller -



php - Trying to get property of non-object in controller -

this controller

public function show($restaurant_id) { $data = restaurant::find($restaurant_id)->waitingtimes(); echo $data->first()->value; exit;

i got trying property of non-object though waitingtime model mapped database table has value column.

could help please? also, tell me can read documentation returning type of function find() thanks

edit 1

the info not empty; can see database, , restaurant table has id 20 , table waitingtimes has values restaurant_20 20

actually - improve map route model.

so in routes.php file:

route::model('restaurant', 'restaurant'); route::get('/restaurant/{restaurant}', ['as' => 'restaurant.show', 'uses' => restaurantcontroller@show]);

then in controller file:

public function show(restaurant $restaurant) { echo $restaurant->waitingtimes()->first()->value; }

you can read more route model binding here.

php laravel laravel-4 blade

sql - Crystal Report Select Only First Row -



sql - Crystal Report Select Only First Row -

let have next 2 tables:

table a:

companycode locationcode formnumber employeenumber ...

table b:

companycode locationcode formnumber employeenumber claimdate ...

table , table b joined using 4 parameters (companycode,locationcode,formnumber,employeenumber). these 4 parameters input report. 1 row in table can have multiple rows in table b.

in crystal report, each record in table a, want row earliest claimdate in table b.

using sql, can accomplished using:

select * tablea inner bring together tableb b on a.companycode = b.companycode , a.locationcode = b.locationcode , a.formnumber = b.formnumber , a.employeenumber = b.employeenumber a.companycode = @companycode , a.locationcode = @locationcode , a.formnumber = @formnumber , a.employeenumber = @employeenumber , b.claimdate in (select min(b.claimdate) tableb b b.companycode = @companycode , b.locationcode = @locationcode , b.formnumber = @formnumber , b.employeenumber = @employeenumber )

but i'm not sure how can in crystal report. tried using sql expression, seems sql look cannot pass study input.

you need create 4 parameters (companycode, locationcode , formnumber, employeenumber) in command.

the command's query:

select * tablea inner bring together tableb b on a.companycode = b.companycode , a.locationcode = b.locationcode , a.formnumber = b.formnumber , a.employeenumber = b.employeenumber a.companycode = {?companycode} , a.locationcode = {?locationcode} , a.formnumber = {?formnumber} , a.employeenumber = {?employeenumber} , b.claimdate in (select min(b.claimdate) tableb b b.companycode = a.companycode , b.locationcode = a.locationcode , b.formnumber = a.formnumber , b.employeenumber = a.employeenumber )

sql crystal-reports

java - naming methods with different return types but the same functionality -



java - naming methods with different return types but the same functionality -

i'm talking java, concept apply other languages --

we have 2 methods on same class have same basic functionality, provide different homecoming types. both methods things, 1 gets iterable can provide access things, , 1 gets collection includes things.

we know cannot (because won't compile):

iterable getthings() collection getthings()

so, have thoughts how name methods? seems easy prepare say:

iterable getiterableofthings collection getcollectionofthings

however, verbose , perhaps not best solution. question i'm asking imply our organization/coding approach somehow off mark, or valid question?

has else dealt scenario?

how about:

iterable getiterator(); collection getthings();

java

.net - How to properly structurate the visibility of this Class? -



.net - How to properly structurate the visibility of this Class? -

i'm trying improve old class i've wrote manage ini file, class contains 3 sub-classes (file, key, section) separate , organize procedures (procs ini in general, procs manage keys/values, , procs manage section names).

well, problem have in old class members shared (props/vars/objects/methods) , obviouslly result in disimbiguation, seek perfectionate visibility of members, , there i'm stuck.

the current usage of class this:

inifilemanager.filepath = "ini filepath" dim iniexist boolean = inifilemanager.file.exist

and usage should this:

dim ini new inifilemanager("ini filepath", textencoding) dim iniexist boolean = ini.file.exist dim another_ini new inifilemanager("another ini filepath without kind of conflict first instance", textencoding) dim another_iniexist boolean = another_ini.file.exist

below relevant code example, i'm stuck on exist method of file class 'cause cannot access filepath variable @ top-level class since don't set variable , exist method both shared did on old class version...

...so how can improve this?

note: please maintain in mynd other 2 sub-classes should have method named exist , other methods equal names such "[get]", not in file class (i don't know if problem need more retouches).

''' <summary> ''' manages ini file , it's sections load/save values. ''' </summary> public class inifilemanager #region " properties " ''' <summary> ''' indicates initialization file location. ''' </summary> private property filepath string = string.empty ''' <summary> ''' indicates initialization file encoding read/write. ''' </summary> private property textencoding system.text.encoding = system.text.encoding.default #end part #region " constructors " ''' <summary> ''' initializes new instance of <see cref="inifilemanager" /> class. ''' </summary> ''' <param name="inifile"> ''' indicates initialization file location. ''' </param> ''' <param name="textencoding">indicates textencoding read/write iniinitialization file.</param> public sub new(optional byval inifile string = nothing, optional byval textencoding system.text.encoding = nothing) if not string.isnullorempty(inifile) me.filepath = inifile else me.filepath = io.path.combine(application.startuppath, process.getcurrentprocess().processname & ".ini") end if if not textencoding nil me.textencoding = textencoding end if end sub #end part ''' <summary> ''' contains set of procedures manage ini file in general way. ''' </summary> private class [file] ''' <summary> ''' checks whether initialization file exist. ''' </summary> ''' <returns>true if initialization file exist, otherwise false.</returns> public function exist() boolean homecoming io.file.exists(mybase.filepath) end function ' more irrelevant methods here need access props , vars of top-level class... end class ' class here... ' , class here... end class

i think part of problem revealing rather handling much detail of hierarchy thru class. other part clinging 1980's 16bit windows tech when there much more robust mechanisms around today.

you have 4 classes (inimanager, file, section, key) manage 2 bits of info (key , value). since inimanager "house" others, can combined file - since there arent many file level operations. not need [sections]. existed store repeated attributes similar items like:

[maindb] path = file = foo = [report db] path = file = foo =

these intended provide initialization values in way loop thru collection of strings file1, file2... , read multiple sections in loop. simple set of settings, utilize single [default] section simplify class , use. then, downwards inimanager , keys. purposely exposing underlying hierarchy doesnt lend usability, imo.

so want, need sections property on inimanager exposes section related stuff. back upwards that, need inisection class (mainly methods sections) , inisections collection class. (some comments lead me surmise want load sections time , keys can deleted etc).

if really want sections().keys().method, have add together key class , keys collection class on inisection. bring grand total 5 classes manage 2 pieces of information. of course, can done half code , 1 class. of fluff there expose inner workings way mentioned. you'll have fun public vs friend maintain revealing things dont want to.

i dont have in code pinvokes; question deals class construction not ini management. methods empty , exist see how end poor user.

public class inimanager ' gory pinvokes go here friend cfgfile string public property iniexists boolean ' bit seemed missing ' collection property exposed @ inimgr level ' containing collection of sections. matryoshka dolls, within ' each collection of keys , values public property sections inisections ' no reason ini mgr exist without file public sub new(inifile string) cfgfile = inifile _iniexists = system.io.file.exists(cfgfile) _sections = new inisections(cfgfile) end sub ' worthwhile thing can think of "file" ' class ever do. public sub removefile() end sub public sub save() ' think need delete file first ' deleted sections disappear. of course of study sections code ' inquire doesnt harm either ' iterate inisections phone call save there, ' iterates keys 1 1 save them sections.save(cfgfile) end sub ' ****** inisections class collection public class inisections 'inherits collection(of inisection) private items collection(of inisection) private cfgfile string friend sub new(file string) cfgfile = file ' assuming comments ' loading entire file manage it. that: if system.io.file.exists(cfgfile) ' load getprivateprofilesectionnames collection ' mybase.items.add(section_name)...then each s inisection in items s.loadkeyvalues(cfgfile) next end if end sub ' friend! friend sub save(cfgfile string) each s inisection in items ' instruct each section write kvps s.save(cfgfile) next end sub ' dont know why empty accessor showing in intellisense default public readonly property item(name string) inisection if indexofsection(name) = -1 items.add(new inisection(name)) end if homecoming items(indexofsection(name)) end end property ' add together section public function add(name string) inisection dim sec new inisection(name) items.add(sec) homecoming sec end function ' remove section public sub remove(name string) items.removeat(indexofsection(name)) ' real way remove section rewrite file! ' back upwards method have load sections , keys ' time if dont need them can write ' out whole file omitting removed keys , sections. ' ' sir, kind of junk went dustbin rubik's cubes end sub public function exists(secname string) homecoming indexofsection(secname) <> -1 end function private function indexofsection(name string) integer n integer = 0 items.count - 1 ' s/b tolowerinvariant - makes screen scroll if items(n).sectionname.tolower = name.tolower homecoming n end if next homecoming -1 end function end class end class ' ************** inisection item class public class inisection ' methods go here sections, ' "host" keys collections private mykeys dictionary(of string, string) ' .keys collection (why calling code want ' mess whole collection???), alter add together key class ' , keys collection ' interface keys public property keys(name string) string if mykeys.containskey(name) homecoming mykeys(name) else homecoming "" end if end set(value string) if mykeys.containskey(value) mykeys(value) = value else mykeys.add(value, value) end if end set end property public property sectionname string public sub new(name string) sectionname = name mykeys = new dictionary(of string, string) end sub public sub removekey(name string) if mykeys.containskey(name) mykeys.remove(name) end if end sub friend sub save(inifile string) ' iterate keys writitng kvps ini end sub ' note friend called inisection class not user friend function loadkeyvalues(inifile string) integer ' presumably phone call getprivateprofilesection ' sectionname , parse ' current key=value pairs mykeys homecoming mykeys.count end function end class

sample syntax:

ini = new inimanager("c:\temp\ziggy.ini") dim foo string = ini.sections("foo").keys("bar") ini.sections("ziggy").keys("foo") = "zoey" ini.sections("ziggy").removekey("zacky")

these dont match syntactically because didnt create key class , keys collection class (5 classes 2 bits of info insane). alter setter matches, remove keys accessor , add together .readkey() , setkey matches syntactically , maintain keys collection internal. you'll end with:

ini.sections("ziggy").removekey("zacky") ini.sections("ziggy").readkey("ziggy") ini.sections("ziggy").setkey(keyname, "zoey")

at to the lowest degree match syntactically

ini.sections.add("ziggy") ini.sections.remove("zoey") if ini.sections.exists("zacky") console.beep() end if ' causes cascade ini -> sections -> keys save ini.save()

.net vb.net class class-structure

Brackets App Remove Auto Semicolon -



Brackets App Remove Auto Semicolon -

is there way remove auto semicolon in brackets app in css auto finish code hints?

thank you!

i don't think brackets ever auto-inserts semicolon in css currently. (very on did, removed over year ago). have extensions installed, such emmet? extension might causing behavior. if you're not sure, seek debug > reload without extensions , see if still happens (just restart brackets 1 time again re-enable extensions).

adobe-brackets

python - How do I improve the speed of this code? (Solving ODEs with scipy.integrate.odeint) -



python - How do I improve the speed of this code? (Solving ODEs with scipy.integrate.odeint) -

i trying solve relatively big ode scheme scipy.integrate.odeint module. implemented code , can solve equation correctly. process slow. profile code , realized of computing time spent on computing or generating ode scheme itself, sigmoid function expensive have take guess. here piece of code i'm using:

def __sigmoid(self, u): # homecoming .5 * ( u / np.sqrt(u**2 + 1) + 1) homecoming 0.5 + np.arctan(u) / np.pi def __connectionistmodel(self, g, t): """ returning ode scheme """ g_ia_s = np.zeros(self.ngenes * self.ncells) in xrange(0, self.ncells): in xrange(0, self.ngenes): g_ia = self.params["r"][a] *\ self.__sigmoid( sum([ self.params["w"][b + a*self.ngenes]*g[self.ngenes*i + b] b in xrange(0, self.ngenes) ]) +\ self.params["wm"][a]*self.mdata[i] +\ self.params["h"][a] ) -\ self.params["l"][a] * g[self.ngenes*i + a] # uncomment part including diffusion if == 0: g_ia += self.params["d"][a] * ( - 2*g[self.ngenes*i + a] + g[self.ngenes*(i+1) + a] ) elif == self.ncells-1: g_ia += self.params["d"][a] * ( g[self.ngenes*(i-1) + a] - 2*g[self.ngenes*i + a] ) else: g_ia += self.params["d"][a] * ( g[self.ngenes*(i-1) + a] - 2*g[self.ngenes*i + a] + g[self.ngenes*(i+1) + a] ) g_ia_s[self.ngenes*i + a] = g_ia homecoming g_ia_s def solve(self, inp): g0 = np.zeros(self.ngenes * self.ncells) t = np.arange(self.t0, self.t1, self.dt) self.integratedexpression = odeint(self.__connectionistmodel, g0, t, full_output=0) homecoming self.integratedexpression

as see in each iteration, should generate ncells*ngenes (100*3=300) equations , pass odeint. although i'm not sure guess generating equations expensive in comparing solving them. in experiment, solving whole scheme takes 7sec consists of 1sec of odeint , 6secs of __connectionistmodel.

i wondering if there way improve or not? tried utilize sympy define symbolic ode scheme , pass symbolic equations odeint didn't works since couldn't define array of symbols later access array.

in worst case, have deal or utilize cython speed solving process, wanted create sure i'm doing right , there no way improve it.

thanks help in advance.

[update]: profiling result,

ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 7.915 7.915 grntest.py:1(<module>) 1 0.000 0.000 7.554 7.554 grn.py:83(solve) 1 0.000 0.000 7.554 7.554 odepack.py:18(odeint) 1 0.027 0.027 7.554 7.554 {scipy.integrate._odepack.odeint} 1597 5.506 0.003 7.527 0.005 grn.py:55(__connectionistmodel) 479100 1.434 0.000 1.434 0.000 grn.py:48(__sigmoid) 479102 0.585 0.000 0.585 0.000 {sum} 1 0.001 0.001 0.358 0.358 grn.py:4(<module>) 2 0.001 0.001 0.207 0.104 __init__.py:10(<module>) 27 0.014 0.001 0.185 0.007 __init__.py:1(<module>) 7 0.006 0.001 0.106 0.015 __init__.py:2(<module>)

[update 2]: made code publicly available: pystgrn

vectorize, vectorize, vectorize more. , utilize info structures facilitate vectorization.

the function __connectionistmodel uses lot of access pattern a[i*m+j], equivalent access row i , column j in 2d array total of m columns. suggests 2d array right way store data. can eliminate loop on i function using numpy slicing notation , vectorizing follows:

def __connectionistmodel_vec(self, g, t): """ returning ode scheme """ g_ia_s = np.zeros(self.ngenes * self.ncells) g_2d = g.reshape((self.ncells, self.ngenes)) w = np.array(self.params["w"]) mdata = np.array(self.mdata) g_ia_s = np.zeros((self.ncells, self.ngenes)) in xrange(0, self.ngenes): g_ia = self.params["r"][a] *\ self.__sigmoid( (w[a*self.ngenes:(a+1)*self.ngenes]*g_2d).sum(axis=1) +\ self.params["wm"][a]*mdata +\ self.params["h"][a] ) -\ self.params["l"][a] * g_2d[:,a] g_ia[0] += self.params["d"][a] * ( - 2*g_2d[0,a] + g_2d[1,a] ) g_ia[-1] += self.params["d"][a] * ( g_2d[-2,a] - 2*g_2d[-1,a] ) g_ia[1:-1] += self.params["d"][a] * ( g_2d[:-2,a] - 2*g_2d[1:-1,a] + g_2d[2:,a] ) g_ia_s[:,a] = g_ia homecoming g_ia_s.ravel()

as far can see, returns same values original __connectionistmodel. bonus, function more compact. optimized function has same inputs , outputs original, performance, might want organize info in numpy arrays instead of lists avoid conversion lists arrays on every call. , i'm sure there other minor performance tweaks well.

anyway, original code gave me these profiling results (insert mandatory "my computer faster yours" brag here):

ncalls tottime percall cumtime percall filename:lineno(function) 1597 3.648 0.002 5.250 0.003 grn.py:52(__connectionistmodel) 479100 0.965 0.000 0.965 0.000 grn.py:48(__sigmoid) 479100 0.635 0.000 0.635 0.000 {sum} 1 0.017 0.017 5.267 5.267 {scipy.integrate._odepack.odeint} 1598 0.002 0.000 0.002 0.000 {numpy.core.multiarray.zeros}

with __connectionistmodel_vec, get:

ncalls tottime percall cumtime percall filename:lineno(function) 1597 0.175 0.000 0.247 0.000 grn.py:79(__connectionistmodel_vec) 4791 0.031 0.000 0.031 0.000 grn.py:48(__sigmoid) 4800 0.021 0.000 0.021 0.000 {method 'reduce' of 'numpy.ufunc' objects} 1 0.018 0.018 0.265 0.265 {scipy.integrate._odepack.odeint} 3197 0.013 0.000 0.013 0.000 {numpy.core.multiarray.array}

python scipy ode odeint

Does deleting a file removes all replication files as well in hdfs -



Does deleting a file removes all replication files as well in hdfs -

does deleting file removes replication files in hdfs?

is trash way recover deleted files hdfs?

replication factor used internal framework fault tolerance? network or other failures happen?

i trying relate deleting file, recovery trash, replication factor in hdfs.

a file in hdfs can removed using rmr command. however, hdfs supports trash feature helps recover files in case of accidental deletion of data. when trash feature enabled, file moved .trash folder under user's hdfs directory.

however, internally how works hdfs create metadata in trash folder identity file , associated block info needs deleted 1 time fs.trash.interval time interval finish after file deleted . actual file contents i.e. replicated blocks of file still nowadays on original info nodes nowadays before delete operation.

if user wants recover deleted file, done delete metadata info .trash folder , original info anyways lying on datanodes usual.

to reply query, deleting file doesn't delete file contents , blocks datanodes.

hdfs

kinect toolbox c# syntax -



kinect toolbox c# syntax -

i have been studying algorithm used in kinect toolbox compare vector sequences, struggling understand piece of code:

public static float distanceto(this list<vector2> path1, list<vector2> path2) { homecoming path1.select((t, i) => (t - path2[i]).length).average(); }

as far understand takes 2 sequences of 2d vectors , computes distance between them means of euclidean distance, is, calculates length of difference between vectors, had never seen syntax within parenthesis, specially =>.

any insight much appreciated.

you can unroll select statement.

path1.select((t, i) => (t - path2[i]).length) iterates on path1, every element in it, selects vector2 element , index in path1 list.

from intermediate result difference between 2 corresponding vectors @ same index (t - path2[i]), - parameter overload vector substraction method. difference calculate vector length squared(?) addition on elements.

average() in end takes average on given vector differences.

this c# code semantically same:

float sum = 0.0f; for(int = 0; < path1.count; i++) { sum += (path1[i] - path[2]).length; } homecoming sum / (float)path1.count;

or nicer linq zip expression:

path1.zip(path2, (left, right) => (left-right).length).average();

c# kinect toolbox

paperjs - Paper.js animating : Movement according to a paths normal -



paperjs - Paper.js animating : Movement according to a paths normal -

i trying animate line , normal ( line ). when alter position after or before setting rotation of normal unusual animation occurs.

is there has thought on that?

i have code in sketchpad:

http://sketch.paperjs.org/#s/jvjlb5taep4rky7bqgvubs+ocogstt2klaueeohzida2q+aztayoi8v/vbm7mfdlucqjne8xz0oe+raieft7cbioomluuonfu9wz6hjcd3njzll2vcih9edcn4fqxlhxsath2xz3//gkr9rgivtimucqpuzn2ds8zlojp6x4xygs5gu5yjo0/xkz8lelecwe0vp29aqlqslj4ish5vwpa0m4hncttijlc9lj3yhxcelzbj5z5fgqzcatc8bxryjfmgrc2b2xz7vmhqndsk2ymjtyc6boqwfy3mhr2bp0gpf96giqqgfvpysgwsuwunxkaril373m/6hwqj3vvahbp7abvqmi96jbjj/nstngknw2r8e8xyhyyuohmsopxvkujnugjjhninupyxftg+p2fp4twm9odkpk6w4l7xdddpan5rbcm/r6gxc4e4tdk5kfspnehipj2irrab3klogfrjwvc9pulcqpdqxxypzmaifwidlczisyc+plvf0jkdbezx607+tfflgzur/l3nv2gxfcw7ulgo/pp5c2jdnp3l7h2d1c6lslfcdjdpwl

var outerh = 200; var outerw = 300; var grouping = new group(); var spine = new path({x:0, y:0}); spine.add({x:0, y:outerh/4}); spine.add({x:-outerw, y:outerh}); spine.strokecolor = 'red'; var np = new path(); np.strokecolor = 'blue'; np.add(new point(0, 0)) np.add(new point(50, 0)); //np.pivot = np.bounds.topleft; group.addchildren([spine, np]); group.position = {x:200, y:300}; var loc = spine.getlocationat(120); var normal = spine.getnormalat(120); np.position = loc.point; np.rotate(normal.angle); view.onframe = function(event) { var sinus = math.sin(event.time ); var cosinus = math.cos(event.time ); // alter x position of segment point; spine.segments[2].point.y += cosinus ; spine.segments[2].point.x += sinus ; var loc = spine.getlocationat(120); var normal = spine.getnormalat(120); np.position = loc.point; //np.rotate(normal.angle); }

if uncomment -> np.rotate(normal.angle); np not rotating line normal point?

please read next post on mailing list explains behavior , offers alternative switch paper.js mode simplifies scenario:

https://groups.google.com/forum/#!searchin/paperjs/applymatrix/paperjs/4eirsgzcaui/sekont-pspwj

paperjs

jQuery validation: one radio button in any of several groups -



jQuery validation: one radio button in any of several groups -

i've got form 3 sets of radio buttons, let's say:

<input type="radio" name="answer_option1" value="1" id="ans_options1" /> <input type="radio" name="answer_option1" value="2" id="ans_options2" /> <input type="radio" name="answer_option1" value="3" id="ans_options3" /> <input type="radio" name="answer_option1" value="4" id="ans_options4" /> <input type="radio" name="answer_option2" value="5" id="ans_options5" /> <input type="radio" name="answer_option2" value="6" id="ans_options6" /> <input type="radio" name="answer_option2" value="7" id="ans_options7" /> <input type="radio" name="answer_option2" value="8" id="ans_options8" /> <input type="radio" name="answer_option3" value="9" id="ans_options9" /> <input type="radio" name="answer_option3" value="10" id="ans_options10" /> <input type="radio" name="answer_option3" value="11" id="ans_options11" /> <input type="radio" name="answer_option3" value="12" id="ans_options12" />

the form should pass validation (in jqueryvalidation.org sense) if 1 of these 12 radios selected. able create work usual methods of hanging "require" classes of 1 sort or off buttons, individual groups, not across groups -- selecting radio in grouping 1 still lead complaints missing selections in groups 2 , 3. dallied require_from_group, doesn't seem much better. thoughts? thanks!

quote op:

"the form should pass validation if 1 of these 12 radios selected. ..."

"... dallied require_from_group, doesn't seem much better."

the require_from_group method works fine me, didn't show plenty code know went wrong it. create sure include the additional-methods.js file.

my demo uses next jquery along html markup radio buttons, although made sure rename 3rd button grouping answer_option3.

$(document).ready(function() { $('#myform').validate({ rules: { answer_option1: { require_from_group: [1, '[name^="answer_option"]'] }, answer_option2: { require_from_group: [1, '[name^="answer_option"]'] }, answer_option3: { require_from_group: [1, '[name^="answer_option"]'] } }, groups: { // groups messages 1 arbitraryname: 'answer_option1 answer_option2 answer_option3' } }); });

demo: http://jsfiddle.net/qf2pg/1/

notes: groups alternative groups messages multiple fields one. perfect situation simultaneous messages on 3 fields when need satisfy 1 out of three.

alternative:

the .rules('add') method can leveraged alleviate repetitive rules declarations above.

$('[name^="answer_option"]').each(function() { $(this).rules('add', { require_from_group: [1, '[name^="answer_option"]'] }); });

demo 2: http://jsfiddle.net/qf2pg/2/

jquery jquery-validate

jsf - How to get new values of edited row of datatable? -



jsf - How to get new values of edited row of datatable? -

hello have editable datatable , want new values row so, next code have ....

this code datatable

row editing

<f:facet name="people"> <p:outputpanel> <h:outputtext value="search fields:" /> <p:inputtext id="globalfilter" onkeyup="pf('peoplestable').filter()" style="width:150px" /> </p:outputpanel> </f:facet> <p:ajax event="rowedit" listener="#{personinformation.onrowedit}" update="dt" /> <p:ajax event="roweditcancel" listener="#{personinformation.onrowcancel}" /> <p:ajax event="rowselect" listener="#{personinformation.onrowselect}" /> <p:ajax event="rowunselect" listener="#{personinformation.onrowunselect}" /> <p:column style="width:16px"> <p:rowtoggler /> </p:column> <p:column headertext="व्यक्ती क्र." filterby="#{per.id}" filtermatchmode="contains" style="width:30px;" > <p:celleditor > <f:facet name="output"><h:outputtext value="#{per.id}" /></f:facet> <f:facet name="input"><h:outputtext value="#{per.id}" style="width:100%" /></f:facet> </p:celleditor> </p:column> <p:column headertext="नाव" filterby="#{per.name}" filtermatchmode="contains" > <p:celleditor> <f:facet name="output"><h:outputtext value="#{per.name}" /></f:facet> <f:facet name="input"><p:inputtext value="#{per.name}" style="width:100%" label="name"/></f:facet> </p:celleditor> </p:column> <p:column headertext="पत्ता" filterby="#{per.address}" filtermatchmode="contains" > <p:celleditor> <f:facet name="output"><h:outputtext value="#{per.address}" /></f:facet> <f:facet name="input"><p:inputtext value="#{per.address}" style="width:100%" label="address"/></f:facet> </p:celleditor> </p:column> <p:column headertext="मोबाईल नंबर" filterby="#{per.mobilenumber}" filtermatchmode="contains" > <p:celleditor> <f:facet name="output"><h:outputtext value="#{per.mobilenumber}" /></f:facet> <f:facet name="input"><p:inputtext value="#{per.mobilenumber}" style="width:100%" label="mobile number"/></f:facet> </p:celleditor> </p:column> <p:column headertext="भेटीचे कारण" filterby="#{per.reason}" filtermatchmode="contains" > <p:celleditor> <f:facet name="output"><h:outputtext value="#{per.reason}" /></f:facet> <f:facet name="input"><p:inputtext value="#{per.reason}" style="width:100%" /></f:facet> </p:celleditor> </p:column> <p:column headertext="भेटीचे वेळ" style="width:200px;" filterby="#{per.d}" filtermatchmode="contains" > <p:celleditor> <f:facet name="output"><h:outputtext value="#{per.d}" /></f:facet> <f:facet name="input"><h:outputtext value="#{per.d}" /></f:facet> </p:celleditor> </p:column> <p:column style="width:32px"> <p:roweditor /> </p:column> <p:rowexpansion > <p:panelgrid columns="2" columnclasses="label,value" style="margin-left: 300px;width:300px"> <h:outputtext value="व्यक्ती क्र." /> <h:outputtext value="#{per.id}" /> <h:outputtext value="नाव" /> <h:outputtext value="#{per.name}" /> <h:outputtext value="पत्ता" /> <h:outputtext value="#{per.address}" /> <h:outputtext value="मोबाईल नंबर" /> <h:outputtext value="#{per.mobilenumber}" /> <h:outputtext value="भेटीचे कारण" /> <h:outputtext value="#{per.reason}" /> <h:outputtext value="भेटीचे वेळ" /> <h:outputtext value="#{per.d}" /> </p:panelgrid> </p:rowexpansion> </p:datatable>

and backing bean in want display new edited values...

public void onrowselect(selectevent event) { system.out.println(event.getobject().tostring()); datatable objdatatable = (datatable) event.getsource(); system.out.println("get row info : "+objdatatable.getrowdata("id")); personbean pb=new personbean(); pb=(personbean)objdatatable.getrowdata(); int id=pb.getid(); string name=pb.getname(); string address=pb.getaddress(); string mobilenumber=pb.getmobilenumber(); string reason=pb.getreason(); }

if want new value datatable 1 time has been updated should utilize rowedit event instead.

<p:ajax event="rowedit" listener="#{bean.listener}"/> <p:column> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{per.name}"/> </f:facet> <f:facet name="input"> <h:inputtext value="#{per.name}" required="true"/> </f:facet> </p:celleditor> </p:column> public void update(roweditevent event) { // utilize event.getobject() here }

jsf

Adding Columns in 2D array (Python) -



Adding Columns in 2D array (Python) -

so trying add together columns of 2d array except first 2 columns of array. if sum of row greater or equal 9 , less 12, want function print row. here sample of 2d array list of lists:

[[12606.000, 74204.000, 1.000, 1.000, 1.000, 1.000, 1.000, 0.000, 0.000], [12606.000, 105492.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000], [12606.000, 112151.000, 1.000, 1.000, 0.000, 0.000, 0.000, 0.000, 0.000], [12606.000, 121896.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000, 0.000]]

(some columns deleted formatting). here code:

def sumbinrow(a): """returns list of employees recording info @ to the lowest degree 9 months , fewer twelve. """ in range(len(a)): j in range(len(a[i])): if 9 <= sum(a[i][j+2]) <12: print a[i]

i maintain getting "type error" saying 'int' object not iterable.

basically, need iterate on each list, each list, take piece of list starting 2, sum , comparison.

def sumbinrow(a): """prints list of employees recording info @ to the lowest degree 9 months , fewer twelve. """ row in a: if 9 <= sum(row[2:]) < 12: print row

or in 1 line cause why not :p

def sumbinrow(a): """prints list of employees recording info @ to the lowest degree 9 months , fewer twelve. """ print [row row in if 9 <= sum(row[2:]) < 12]

python arrays list

reporting services - Dynamically create crystal report columns -



reporting services - Dynamically create crystal report columns -

i have created cross tab study create study dynamically according user's selected column.

but have got serious problem, wanna want hide other fields when fields empty (no info show).

the schema report:

<xs:element name="salsesummary"> <xs:complextype> <xs:sequence> <xs:element name="a1" type="xs:string"></xs:element> <xs:element name="a2" type="xs:string"></xs:element> <xs:element name="a3" type="xs:string"></xs:element> <xs:element name="a4" type="xs:string"></xs:element> <xs:element name="a5" type="xs:string"></xs:element> <xs:element name="a6" type="xs:string"></xs:element> <xs:element name="a7" type="xs:string"></xs:element> <xs:element name="a8" type="xs:string"></xs:element> <xs:element name="a9" type="xs:string"></xs:element> <xs:element name="a10" type="xs:string"></xs:element> <xs:element name="a11" type="xs:string"></xs:element> <xs:element name="a12" type="xs:string"></xs:element> <xs:element name="a13" type="xs:string"></xs:element> <xs:element name="a14" type="xs:string"></xs:element> <xs:element name="a15" type="xs:string"></xs:element> <xs:element name="a16" type="xs:string"></xs:element> <xs:element name="a17" type="xs:string"></xs:element> <xs:element name="a18" type="xs:string"></xs:element> <xs:element name="a19" type="xs:string"></xs:element> <xs:element name="a20" type="xs:string"></xs:element> <xs:element name="total" type="xs:decimal"></xs:element> </xs:sequence> </xs:complextype> </xs:element>

here way how map columns study

this how set custom styles

but when run it, how displays result.

you don't need have same fields in both rows , columns sections--choose one.

reporting-services crystal-reports crystal-reports-2008 crystal-reports-2010

java - How to bind with a different port -



java - How to bind with a different port -

i trying bind object name using different port default, 1099. using naming.bind.

naming.bind("myserver", server);

i have tried these , java.net.malformedurlexception:

naming.bind("myserver:2020", server); naming.bind("localhost:2020/myserver", server); naming.bind("//localhost:2020/myserver", server);

how can it? i've looked info everywhere , surprised there's nil said it.

try, 3rd option, replacing localhost 127.0.0.1.

a malformedurlexception thrown when either no legal protocol found in specification string or string not parsed.

java bind rmi

python - Django query filter exclude repeated items -



python - Django query filter exclude repeated items -

i want filter message this

messages = message.objects.filter(who_id=logged_user) | q(whose_id=logged_user)

my result =

who : 1 , : 2 : 2 , : 1 : 1 , : 2 : 2 , : 1 : 1 , : 3

but want result

who : 1 , : 2 : 1 , : 3

my model

class message(models.model): uuid = uuidfield(auto=true) = models.foreignkey(user,blank=true,related_name="who_%(class)s_objects") = models.foreignkey(user,blank=true,related_name="whose_%(class)s_objects") message = models.textfield() time = models.datetimefield(auto_now=true)

how exclude other results?

your query

messages = message.objects.filter(who_id=logged_user) | q(whose_id=logged_user)

returns messages that:

have who_id = logged_user or have whose_id = logged_user.

from question appears want messages that

have who_id = logged_user

i.e

messages = message.objects.filter(who_id=logged_user)

should work.

if that's not you're after, please specify logic of query.

python django

machine learning - document similarity with documents using synonyms -



machine learning - document similarity with documents using synonyms -

i have bunch of documents of documents re-create of other documents text jumbled , of words replaced synonyms. mentioned below 1 such illustration of sentence:

article 1 (original) : caught john snow in town making purchases @ kingslanding hardware store repair broken tractor. snow has farmed soybeans entire life, did father , fathers. asked him life on farm.

article 2 (duplicate) : obtained john snow in city in purchases create rising of hardware @ kingslanding repair broken motor tractor. snow have soya broad beans finish life have been treated, such father , fathers. asked him concerning life on agriculture company.

article 3 (duplicate) : took above john snow in city made purchases in warehouse of hardware of kingslanding repair broken tractor. snow has cultivated soybeans whole life, father , parents. asked him life in farm.

article 4 (duplicate) : caught myself compared john snow downtown making of purchases kingslanding store of material repair broken tractor. snow cultivated soya life whole, his/her father , fathers. questioned life farm.

i want document similarity ends tagging these documents in same group. suggestions along examples or tutorials appreciated.

it seems textbook case of locality sensitive hashing. check out this thread

machine-learning nlp scikit-learn stanford-nlp information-retrieval

angularjs - Handling URLs with ui-router's ui-sref -



angularjs - Handling URLs with ui-router's ui-sref -

i have file called menu.json such:

[ { "label": "search" "icon": "icon-search", "state": "search" }, { "label": "help", "icon": "icon-question-sign", "state": "http://help.abc.com" } ]

this file processed , returned server. utilize render navbar through ngrepeat directive.

<li ng-repeat="entry in menu_entries"> <!-- 'entry' each json object in above array --> <a ui-sref="{{entry.state}}"><i class="{{entry.icon}} icon-white"></i> {{entry.label}}</a> </li>

the states work great, , compiled proper html links, do states urls? must write kind of ui-router urlrouterprovider rule or otherwise function? how guys handle when there's mix of states & urls?

in these cases have bit different json file construction - have attribute called internal: true/fase each menu item , have simple if statement render link in different attribute.

angularjs angular-ui-router

android - ArcGIS Web Application wont load on mobile device -



android - ArcGIS Web Application wont load on mobile device -

i have created app arcgis web app builder , when hosted on local server works fine, when build app using apache cordova , load apk file onto phone , install it. app not load on phone , remain on splash screen. ideas?

this may obvious question, original arcgis app based on esri web-server applications or have own esri server? in previous conversations esri, have indicated apps must run through (or controlled by) servers , cannot stand-alone without server account. on stackoverflow can add together more insight, 1 test of see if whole web bundle run without web connection. usually, find basemaps,and other embedded files interact esri mothership.

android cordova gis arcgis

perl - find and replace in xml file -



perl - find and replace in xml file -

i want replace specific value in xml file.

my test xml below -

<field name="abc" isarray="false" islocked="false"> <description>this abc value</description> <comment></comment> <propertylist> <property name="abc" type="boolean"> <defaultvalue>false</defaultvalue> </property> </propertylist> <propertyvaluelist> <propertyvalue propertyname="abc"> <value>true</value> </propertyvalue> </propertyvaluelist> </field>

i want alter value true false propertyname=abc

any suggestions? sed/awk/perl do.

you through awk,

awk '/propertyname=\"abc\"/{print; getline; sub(/true/,"false")}1' file

xml perl awk sed

java - ImageMagick: converting piped images -



java - ImageMagick: converting piped images -

i'm attempting convert image in inputstream outputstream using im4java. docs, looks setting inputprovider input , specifying output stream should pipe converted image, a:

failed convert image: more argument images placeholders

here's function:

public static inputstream convert(inputstream imagestream){ seek { // set im4java properties. see {@link im4java} imoperation op = new imoperation(); op.scale(1000); op.compress("zip"); convertcmd convert = new convertcmd(); convert.setsearchpath(imlocation); logger.debug("imagemagick located at: " + convert.getsearchpath()); inputstream = imagestream; bytearrayoutputstream os = new bytearrayoutputstream(); pipe pipein = new pipe (is, null); pipe pipeout = new pipe(null, os); convert.setinputprovider(pipein); convert.setoutputconsumer(pipeout); convert.run(op, "-", "pdf:-"); is.close(); os.close(); pipeout.consumeoutput(is); homecoming is; }catch(exception e){ logger.debug("failed convert image: " + e.getmessage()); } homecoming null; }

thanks!

solved it, posting here posterity.

public static inputstream convert(string path, inputstream imagestream){ seek { imoperation op = new imoperation(); op.compress("zip"); //order matters here, create sure colorspace first arg set inputstream = imagestream; pipe pipein = new pipe (is, null); bytearrayoutputstream os = new bytearrayoutputstream(); pipe pipeout = new pipe(null, os); convertcmd convert = new convertcmd(); convert.setsearchpath(imlocation); convert.setinputprovider(pipein); convert.setoutputconsumer(pipeout); op.addimage("-"); op.addimage("pdf:-"); // execute operation final long starttime = system.nanotime(); convert.run(op); final long endtime = system.nanotime(); logger.debug("compressed"); logger.debug("done converting " + path); final long elapsedtimeinms = (endtime - starttime) / 1000000; logger.debug("took " + elapsedtimeinms); homecoming new bytearrayinputstream(os.tobytearray()); }catch(exception e){ logger.debug("failed convert image: " + e.getmessage()); } homecoming null; }

java imagemagick im4java