Friday, 15 July 2011

Using Python to create a dictionary with setters and getters -



Using Python to create a dictionary with setters and getters -

i have class method create dictionary. set , these values this:

class test(object): def __init__(self): self.config = {} def set_config_key(self, key, value): self.config[key] = value def _get_config_value(self, key): homecoming self.config[key]

in python 2.7 there improve way of doing this?

yes, can utilize attribute access the __getattr__ , __setattr__ methods instead:

class test(object): config = none def __init__(self): self.config = {} def __setattr__(self, key, value): if self.config none: # set config straight super(test, self).__setattr__(key, value) homecoming self.config[key] = value def __getattr__(self, key): homecoming self.config[key]

this translates test().foo test().config['foo'].

demo:

>>> t = test() >>> t.foo = 'bar' >>> t.foo 'bar' >>> t.config {'foo': 'bar'}

you map straight object __dict__, instead of self.config; if subclass dict object both mapping , takes arbitrary attributes:

class attrdict(dict): def __init__(self, *args, **kw): super(attrdict, self).__init__(*args, **kw) self.__dict__ = self

demo:

>>> class attrdict(dict): ... def __init__(self, *args, **kw): ... super(attrdict, self).__init__(*args, **kw) ... self.__dict__ = self ... >>> foo = attrdict() >>> foo.bar = 'baz' >>> foo {'bar': 'baz'} >>> foo.bar 'baz'

python

regex, image src may have many different paths and I want to replace with a specific path -



regex, image src may have many different paths and I want to replace with a specific path -

so have database wordpress multisite. i'm doing search , replace on table regex , need create src's of specific image name (image2.jpg) point single directory. here's example. may have:

src="http://domain.com/path/weird/different/image2.jpg

and

src="http://domain2.com/path2/differentpath/helloworld/image2.jpg

i need replace between src=" , /image.jpg specific domain/filepath.

i'm not great regex stuff, try, it's not strong suit. help appreciated.

search: src="[^"]*image2\.jpg

replace: src="http://mydomain.com/mypath/image2.jpg

the [^"]* eats characters not double quote.

in demo, see substitutions pane @ bottom.

in php (should work wordpress):

$replaced = preg_replace('/src="[^"]*image2\.jpg/', 'src="http://mydomain.com/mypath/image2.jpg', $str);

regex replace

sql - Merge replication deleting data on the subscriber -



sql - Merge replication deleting data on the subscriber -

i have 2 servers sql server 2012, , merge replication configured. working correctly, because network problem, subscriber days off line, , when connection returned, publisher deleting info saved on subscriber during off line period. tried delete , reconfigure replication, not working.

can help me?

thanks!

the publisher might marking records deleted on subscriber because don't exist on publisher anymore. if not case, reinitialize subscription publisher on client machine, , see if starts replicating successfully.

sql merge sql-server-2012 replication

android - Dynamic Caching of Data in JQuery Mobile, PhoneGap Application -



android - Dynamic Caching of Data in JQuery Mobile, PhoneGap Application -

i finished reading few sparse tutorials on caching/offline , making apps responsive when user not connected internet. quite interesting cause have beingness wondering how apps have beingness doing cause thinking database manipulation.

i relatively new caching mechanism , want implement in next project cause still learning.

the few tutorials have read talks caching static files pictures, .css files, .js files etc

my question this;

**question 1** how cache dynamic files e.g have apps when user want view profile, implement sending ajax request server populate profile page pictures , other profile details (texts). how cache these texts , pictures since dynamic?

**question 2** using different page (index.html, profile.html) jquery mobile mechanism, impact caching in way because have refresh page every time navigating new page show styling correctly?

this question may sound noob want larn , have read lot caching these question not addressed. hope helps. thanks...

answer given based on knowledge far.

1) can store / cache things localstorage it's preety basic won't take lot of time or coding or mechanism implement. profile data, image encoded string can saved in localsorage. first save profile info in localstorage. next time after app starts can load info localstorage , in mean time can create async ajax phone call server check if info modified. if so, can bring info 1 time again , update localstorage.

2) if utilize localstorage page transitions won't matter until reach localstorage size limit of 5 mb.

android jquery html caching cordova

c# - DataGridView default error inside a new thread -



c# - DataGridView default error inside a new thread -

really don't know if doing right programmatically or not hope point me out. have datagridview c# showing info linked mysql database , input boxes help inserting info database , goes alright, when decided create inserting operation in separate new thread next within add together button:

private void addtoolstripmenuitem_click(object sender, eventargs e){ try{ new thread(() =>{ // insertion code goes here //to update datagridview after inserting this.studentinfotableadapter.fill(this.schooldataset.studentinfo); }).start(); }catch(exception ex){...} }

so new dialog error popping-up in each new insert operation , nil saved, here error:

i thought error maybe caused of this conflicting in this.studentinfotableadapter.fill(this.schooldataset.studentinfo); did right error still there. suggestion help me out , appreciated.

finally i've got it, after hours of searching, reading, , trying found should utilize invoke specific line within thread this.studentinfotableadapter.fill(this.schooldataset.studentinfo); so becomes following:this.invoke(new methodinvoker(delegate { this.studentinfotableadapter.fill(this.schooldataset.studentinfo);})); i think error caused because line calls features main thread update datagridview while new thread executing , programmatically there exists cross-thread operation exception modifying or editing gui prevented except main thread error arises thread behavior! it's how did understand that. if i'm wrong please point me.

c# mysql datagridview

MySql Self Join Count -



MySql Self Join Count -

i have question concerning mysql query. there 2 tables, persons , married.

persons: id surname firstname id_father id_mother married: id personid1 personid2 marriage divorce

personid1 male , id2 female.

my goal getting list containing firstname, surname , number of kids of women or 1 time married person id = 1. somehow can't set in 1 select statement.

here 2 statements i've been using far.

select firstname, surname, id persons id in( select married.personid2 married married.personid1 = 1);

select persons.id_mother id, count(persons.id_mother) noofchildren persons grouping persons.id_mother;

thanks in advance

http://www.directupload.net/file/d/3661/vwqxeg8a_png.htm

i think query job.

select woman.firstname, woman.surname, count(kid.id) kids persons woman inner bring together married on married.personid2 = woman.id left bring together persons kid on kid.id_mother = woman.id married.personid1 = 1 grouping woman.id

mysql count group-by self-join

java - JavaFX main fxml not loading fxml -



java - JavaFX main fxml not loading fxml -

my app has tabbed panes, in order maintain fxml files manageable, have main fxml file contains tabs, , separate fxml each of other tabs. working fine, reason, app has stopped loading sec tab. tried loading solo in main app, works fine. tried creating new fxml file test, , loading it, works. but, won't load sec tab. also, there no output console.

edit: after more trials, i've narrowed downwards split pane. tried simple fxml button, fine, add together split pane , 2 buttons, , view doesn't render.

here main class: public class main extends application {

@override public void start(stage primarystage) { parent mainview; seek { mainview = fxmlloader.load(getclass().getresource("view/mainview.fxml")); scene scene = new scene(mainview); primarystage.settitle("horse show manager"); primarystage.setscene(scene); primarystage.show(); } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } public static void main(string[] args) { launch(args); } }

here mainview.fxml

<?import javafx.geometry.*?> <?import javafx.scene.control.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.gridpane?> <tabpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="800.0" prefwidth="800.0" tabclosingpolicy="unavailable" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8"> <tabs> <tab text="classes"> <fx:include source="grouppane.fxml" fx:id="grouppanecontent" /> </tab> <tab text="riders"> <fx:include source="riderpane.fxml" fx:id="riderpanecontent" /> </tab> </tabs> </tabpane>

here first pane

<?import javafx.collections.*?> <?import javafx.geometry.*?> <?import java.lang.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.anchorpane?> <?import javafx.collections.fxcollections?> <splitpane dividerpositions="0.4" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.view.grouppanecontroller"> <items> <tableview fx:id="table" editable="true" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0"> <columnresizepolicy> <tableview fx:constant="constrained_resize_policy" /> </columnresizepolicy> <columns> <tablecolumn fx:id="groupnumbercolumn" editable="false" prefwidth="40.0" text="class number" /> <tablecolumn fx:id="groupnamecolumn" editable="false" prefwidth="40.0" text="class name" /> </columns> </tableview> <gridpane alignment="center"> <columnconstraints> <columnconstraints hgrow="never" /> <columnconstraints hgrow="always" /> </columnconstraints> <rowconstraints> <rowconstraints minheight="10.0" vgrow="never" /> <rowconstraints vgrow="never" /> <rowconstraints vgrow="never" /> <rowconstraints vgrow="never" /> <rowconstraints vgrow="never" /> <rowconstraints vgrow="never" /> <rowconstraints vgrow="always" /> </rowconstraints> <children> <label text="number"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <label text="extra money" gridpane.rowindex="4"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <label text="fee" gridpane.rowindex="3"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <label text="gives points" gridpane.rowindex="5"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <label text="name" gridpane.rowindex="1"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <label text="placing" gridpane.rowindex="2"> <gridpane.margin> <insets bottom="10.0" left="5.0" right="5.0" top="10.0" /> </gridpane.margin> </label> <hbox alignment="top_right" prefheight="100.0" prefwidth="200.0" gridpane.columnindex="1" gridpane.rowindex="6"> <children> <button fx:id="addbutton" mnemonicparsing="false" onaction="#groupaddoredit" text="add"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> <button fx:id="editbutton" mnemonicparsing="false" onaction="#editing" text="edit"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> <button fx:id="deletebutton" mnemonicparsing="false" onaction= "#deletegroup" text="delete"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> </children> </hbox> <textfield fx:id="numberfield" gridpane.columnindex="1"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <textfield fx:id="namefield" gridpane.columnindex="1" gridpane.rowindex="1"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <textfield fx:id="feefield" gridpane.columnindex="1" gridpane.rowindex="3"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <textfield fx:id="extramoneyfield" gridpane.columnindex="1" gridpane.rowindex="4"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <choicebox fx:id="givespointschoicebox" maxwidth="1.7976931348623157e308" gridpane.columnindex="1" gridpane.hgrow="always" gridpane.rowindex="5"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> <items> <fxcollections fx:factory="observablearraylist"> <string fx:value="no" /> <string fx:value="yes" /> </fxcollections> </items> <value> <string fx:value="yes" /> </value> </choicebox> <choicebox fx:id="gradingchoicebox" maxwidth="1.7976931348623157e308" gridpane.columnindex="1" gridpane.rowindex="2"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> <items> <fxcollections fx:factory="observablearraylist"> <string fx:value="place" /> <string fx:value="time" /> <string fx:value="points" /> </fxcollections> </items> <value> <string fx:value="place" /> </value> </choicebox> </children> </gridpane> </items> </splitpane>

and second:

<?import javafx.geometry.*?> <?import javafx.scene.control.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.anchorpane?> <splitpane dividerpositions="0.5" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <items> <vbox> <children> <tableview vbox.vgrow="always"> <columns> <tablecolumn prefwidth="75.0" text="c1" /> <tablecolumn prefwidth="75.0" text="c2" /> </columns> <vbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </vbox.margin> </tableview> <tableview vbox.vgrow="always"> <columns> <tablecolumn prefwidth="75.0" text="c1" /> <tablecolumn prefwidth="75.0" text="c2" /> </columns> <vbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </vbox.margin> </tableview> </children> </vbox> <gridpane> <columnconstraints> <columnconstraints /> <columnconstraints hgrow="never" minwidth="0.0" /> <columnconstraints hgrow="sometimes" minwidth="0.0" /> </columnconstraints> <rowconstraints> <rowconstraints minheight="0.0" vgrow="never" /> <rowconstraints minheight="0.0" vgrow="never" /> <rowconstraints minheight="0.0" vgrow="never" /> <rowconstraints minheight="0.0" vgrow="never" /> <rowconstraints minheight="10.0" prefheight="30.0" vgrow="never" /> <rowconstraints minheight="0.0" vgrow="sometimes" /> <rowconstraints minheight="0.0" vgrow="never" /> <rowconstraints minheight="0.0" vgrow="sometimes" /> <rowconstraints minheight="0.0" vgrow="never" /> </rowconstraints> <children> <label text="number" gridpane.columnindex="1"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </label> <label text="name" gridpane.columnindex="1" gridpane.rowindex="1"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </label> <label text="fee" gridpane.columnindex="1" gridpane.rowindex="2"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </label> <label text="membership" gridpane.columnindex="1" gridpane.rowindex="3"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </label> <textfield gridpane.columnindex="2"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <textfield gridpane.columnindex="2" gridpane.rowindex="1"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> <vbox gridpane.columnindex="2" gridpane.rowindex="3"> <children> <radiobutton mnemonicparsing="false" text="current member"> <vbox.margin> <insets left="5.0" right="5.0" top="5.0" /> </vbox.margin> <togglegroup> <togglegroup fx:id="membershipgroup" /> </togglegroup> </radiobutton> <radiobutton mnemonicparsing="false" text="single membership" togglegroup="$membershipgroup"> <vbox.margin> <insets left="5.0" right="5.0" top="5.0" /> </vbox.margin> </radiobutton> <radiobutton mnemonicparsing="false" text="family membership" togglegroup="$membershipgroup"> <vbox.margin> <insets left="5.0" right="5.0" top="5.0" /> </vbox.margin> </radiobutton> <radiobutton mnemonicparsing="false" text="non-member" togglegroup="$membershipgroup"> <vbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </vbox.margin> </radiobutton> </children> </vbox> <tableview prefheight="200.0" prefwidth="200.0" gridpane.columnindex="1" gridpane.columnspan="2147483647" gridpane.rowindex="5"> <columns> <tablecolumn editable="false" maxwidth="1.7976931348623157e308" minwidth="-infinity" prefwidth="187.0" text="horses" /> </columns> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </tableview> <tableview prefheight="200.0" prefwidth="200.0" gridpane.columnindex="1" gridpane.columnspan="2147483647" gridpane.rowindex="7"> <columns> <tablecolumn prefwidth="75.0" text="class number" /> <tablecolumn prefwidth="75.0" text="class name" /> </columns> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </tableview> <hbox gridpane.columnindex="1" gridpane.columnspan="2147483647" gridpane.rowindex="6"> <children> <textfield hbox.hgrow="always"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </textfield> <button mnemonicparsing="false" text="button"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> </children> </hbox> <hbox alignment="center" gridpane.columnindex="1" gridpane.columnspan="2147483647" gridpane.rowindex="8" gridpane.valignment="center"> <children> <button alignment="center" mnemonicparsing="false" text="button" hbox.hgrow="always"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> <button alignment="center" mnemonicparsing="false" text="button" hbox.hgrow="always"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> </children> </hbox> <hbox prefheight="100.0" prefwidth="200.0" gridpane.columnindex="1" gridpane.columnspan="2147483647" gridpane.rowindex="4"> <children> <textfield hbox.hgrow="always"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </textfield> <button mnemonicparsing="false" text="add horse"> <hbox.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </hbox.margin> </button> </children> </hbox> <textfield gridpane.columnindex="2" gridpane.rowindex="2"> <gridpane.margin> <insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </gridpane.margin> </textfield> </children> </gridpane> </items> </splitpane>

sorry long code, , in advance help!

i think answering own question may bad form...but solution define 2 tabs fx:define , fx:include tags. fxml content can loaded. illustration below.

<tabpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="800.0" prefwidth="800.0" tabclosingpolicy="unavailable" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <fx:define> <fx:include fx:id="grouppanecontent" source="grouppane.fxml" /> <fx:include fx:id="riderpanecontent" source="riderpane.fxml" /> </fx:define> <tabs> <tab closable="false" text="classes" content="$grouppanecontent" /> <tab closable="false" text="riders" content="$riderpanecontent" /> </tabs> </tabpane>

edit: fxml doesn't render correctly initially. have manually resize app show up. leave comment if know how prepare this

java javafx javafx-2 fxml fxmlloader

sql server - SQL Comparing two Stored procedures between databases -



sql server - SQL Comparing two Stored procedures between databases -

i have 2 version of same database , need campare objects between them (stored procedures, views etc.)

actually ?m using sqldmo-sqlsmo retrieve text of each object perform text comparison. efective take long time if have more tan 1000+ objects.

my question is. there simple way perform comparing ? maybe md5 key generated on databases ?

why not query definitions straight sql server instead of having overheard of using management objects?

select sysobjects.name [object name] ,(case sysobjects.xtype when 'p' 'stored procedure' when 'tf' 'function' when 'tr' 'trigger' when 'v' 'view' end) [object type] ,syscomments.text [object definition] sysobjects bring together syscomments on sysobjects.id = syscomments.id sysobjects.xtype in ('p', 'tf', 'tr', 'v') , sysobjects.category = 0

i ran against database have here. returned ~1,500 definitions in 0.6 seconds. if run against each server collect definitions, can comparing on object name, type, , definition in 1 big loop.

this expensive operation memory-wise should pretty quick. of cpu time spent doing actual string comparisons.

as other questions "key" available can compare, there's no such hash or equivalent know of. in sys.syscomments table have ctext column (raw bytes of sql definition) , text column text representation of bytes.

fyi: if have visual studio 2010 premium or higher, there's built-in schema compare tool you. there's open dbdiff or many others free.

sql sql-server sqldmo sql-smo

php - How to recompose my codes on PhpStorm -



php - How to recompose my codes on PhpStorm -

is there way beautify , understandable php code on phpstorm. have tried reformat code not working.

for example; when write below line

$example = array("key_one" => "value one", "key_two" => "value two", "key_three" => "value three");

is there shortcut or settings on menu. code should recompose below.

$example = array( "key_one" => "value one", "key_two" => "value two", "key_three" => "value three" );

i hope have made sufficient explanation.

thank you.

it alt + ctrl + l. @ default keymap, found under help->default keymap reference

php phpstorm

objective c - How to pass parameters to controller in object oriented style -



objective c - How to pass parameters to controller in object oriented style -

when photo clicked check it's category , phone call http request function , configure parameters according photos category. here simplified code:

- (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { item *item = (item *) [self.recentitems objectatindex:indexpath.row]; if ( [item.type isequal: @"typea"] ) { connectionproperties.p1 = "a1" connectionproperties.p2 = "a2" } else if ( [item.type isequal: @"typeb"] ){ connectionproperties.p1 = "b1" connectionproperties.p3 = "b2" connectionproperties.p4 = "b3" } } albumdatacontroller = [[albumdatacontroller alloc] initwithconnectionproperty:connectionproperties andcommunicator:self.comm]; [albumdatacontroller fetchitemsforcategory:category itemssuccess:^(album *album) { photos = [[nsarray alloc] initwitharray:album.photos]; photoviewcontroller *photoviewcontroller = [[photoviewcontroller alloc] initwithphotos:photos]; [self presentviewcontroller: photoviewcontroller animated:yes completion:nil]; } }

i know not object oriented way. how should realize in object oriented way.

the object-oriented approach have subclasses of item create own connection properties (or improve yet have item protocol since objective-c doesn't have abstract methods).

example:

@interface item : nsobject - (connectionproperties *)connectionproperties; @end @implementation item - (connectionproperties *)connectionproperties { [self doesnotrecognizeselector:_cmd]; homecoming nil; } @end @interface itema : item @end @implementation itema - (connectionproperties *)connectionproperties { connectionproperties *connectionproperties = [[connectionproperties alloc] init]; connectionproperties.p1 = "a1"; connectionproperties.p2 = "a2"; homecoming connectionproperties; } @end @interface itemb : item @end @implementation itemb - (connectionproperties *)connectionproperties { connectionproperties *connectionproperties = [[connectionproperties alloc] init]; connectionproperties.p1 = "b1" connectionproperties.p3 = "b2" connectionproperties.p4 = "b3" homecoming connectionproperties; } @end

this way code doesn't need know internals of items:

- (void) tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { item *item = (item *) [self.recentitems objectatindex:indexpath.row]; albumdatacontroller = [[albumdatacontroller alloc] initwithconnectionproperty:item.connectionproperties andcommunicator:self.comm];

using protocol similar:

@protocol item <nsobject> - (connectionproperties *)connectionproperties; ... @end

objective-c oop object-oriented-analysis

android - How to run the MediaCodec Sample available at bigflake.com -



android - How to run the MediaCodec Sample available at bigflake.com -

bigflacke has sample code illustrate how utilize mediacodec api available in android 4.3 onward. question how run file test code. need create new project , add together code extending androidtestcase instead of activity.

here link bigflake.com

i want compress high resolution video low resolution. illustration or tutorial. please help.

for video resolution alter can utilize intel inde media pack, has nice samples set , tutorials how build , run app: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials-running-samples

it allows live streaming through wowza services youtube or other services, here tutorial: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials-video-streaming-from-device-to-youtube

android video-encoding android-mediarecorder

java - Changing The Font Of A JTextArea When Language Changes -



java - Changing The Font Of A JTextArea When Language Changes -

i coding simple java chat app. there possibility of knowing language user types in order take appropriate font?

something like

locale locale = inputcontext.getlocale(); string language = locale.getlanguage();

but must rely on locale setting. i'm here on high german locale, i'm happily typing english.

java user-interface

admob - AbMob Balance Issue -



admob - AbMob Balance Issue -

hi admob business relationship connected app gives me revenue. question see estimated earnings $11.13 in account>payment current balance shows $0..why? can explain why?

your current balance gets credited @ end of month. estimated earning that. estimated earnings current month.

admob

android - Interstitial ads for cocos2d-x -



android - Interstitial ads for cocos2d-x -

this question exact duplicate of:

how display interstitial ads after game ends

i new cocos2d-x. developed game in xcode using cocos2d-x , ported android. want utilize interstitial ads after game ends & when replay. should display on game on screen. using next code display ads. displayed before starting game , never displayed when replay game.

once quit , restart advertisement shown 1 time before starting new game. can please help me find solution?

protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); interstitial = new interstitialad(this); interstitial.setadunitid("***********"); adrequest adrequest = new adrequest.builder().build(); interstitial.loadad(adrequest); interstitial.setadlistener(new adlistener() { public void onadloaded() { displayinterstitial(); } }); } public void displayinterstitial() { if (interstitial.isloaded()) { interstitial.show(); } }

the problem phone call displayinterstitial() in oncreate(). need phone call later on when game over. modify oncreate() prevent advertisement appearing immediately:

protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); interstitial = new interstitialad(this); interstitial.setadunitid("***********"); adrequest adrequest = new adrequest.builder().build(); interstitial.loadad(adrequest); }

and later game on phone call displayinterstitial() show ad.

since barely gave info cannot give improve answer.

android c++ xcode5 cocos2d-x

clearscript - Javascript prototype reflection function -



clearscript - Javascript prototype reflection function -

i'm not sure of name of i'd goes this:

currently, have bunch of variables in javascript context $a126 or $b15.

before running, have load in 9000 of these variables , current values later parts of code can reference $xxx value.

the preloading not efficient @ , causing bottleneck.

as there substantial amount of code uses $xxx notation wondering if possible create universal alter $.xxx $ function performed lookup of value passed via after period.

so $.xxx analogous getitem(xxx)

this javascript environment in c# using clearscript, though don't think impact answer.

it looks like

function field(val){ var value = val; this.__definegetter__("xxx", function(){ homecoming value; }); this.__definesetter__("value2", function(val){ value = val; }); } var field = new field("test"); console.log(field.xxx)

---> 'test'

that illustration of i'm looking for. problem have general definegetter doesn't particular getter name.

javascript clearscript

android - How can I make it really easy for people to test my app? -



android - How can I make it really easy for people to test my app? -

i'm thinking sending apk few willing friends have them help test app. of them developers, not. create extremely easy them able send me logcat of crash.

i suppose give them zip batch file, adb, , whatever adb needs run. batch utilize adb filtered logcat. however, don't know much logcat's command line flags. need know logcat create happen? i'm not sure best approach. requires them have drivers installed , working , android debugging on... things of friends wouldn't do.

i think add together app market beta build, isn't i've ever done before. using android market distribute beta allow me knit-pick friends , allow them app? able send me feedback if this?

are there other approaches don't know of? love if there's on-device solution doesn't require them plug computer or have rooted device.

i think google play testing okay your. can give access google+ grouping (only friends) or ony several email addresses. example, can collect feedback in group. more details check link: https://support.google.com/googleplay/android-developer/answer/3131213?hl=en think it's easiest solution.

android testing

amazon web services - AWS Versioning - batch/mass restore to last version that isn't 0kb? -



amazon web services - AWS Versioning - batch/mass restore to last version that isn't 0kb? -

i made foolish error big image directory on our server mounted via s3fs ec2 instance , ran image_optim on it. seemed job until noticed missing files on website, when looked id noticed files had been left @ 0kb...

...now fortunately have versioning on , quick seems show @ exact same time on 0kb files right version well.

it has happened 1300 files in 2500 directory. question is, possible me batch process 0kb files , tell them restore latest version bigger 0kb??

the batch restore tool can find s3 browser causes restore files in folder latest version. in cases work 0kb files many won't, don't own programme rather command line script if possible.

once file(s) have become 0 bytes or 0kb, cannot recover them, @ to the lowest degree not easily. if mean restore / recover ext. backup work.

amazon-web-services amazon-s3 versioning batch-processing restore

swing - Java - My graphics flickers -



swing - Java - My graphics flickers -

this question has reply here:

java: how double-buffering in swing? 5 answers

i'm having problem. here's program. there scenery drawn using paint method. when nail space button, background change. whenever nail space, graphics flickers. heres code:

import javax.swing.*; import java.awt.*; import java.awt.event.*; public class scenery extends jframe implements keylistener { int c1=1; jlabel bg = new jlabel(new imageicon("bg.png")); jlabel pattern1 = new jlabel(new imageicon("p1.jpg")); jlabel pattern2 = new jlabel(new imageicon("p2.jpg")); jlabel pattern3 = new jlabel(new imageicon("p3.jpg")); jlabel pattern4 = new jlabel(new imageicon("p4.jpg")); jlabel pattern5 = new jlabel(new imageicon("p5.jpg")); int f[] = new int[2]; int p[] = new int[3]; container c = getcontentpane(); public scenery() { super("press space alter background"); c.setlayout(null); setsize(800,600); setvisible(true); setlocationrelativeto(null); setresizable(false); setdefaultcloseoperation(jframe.exit_on_close); addkeylistener(this); getcontentpane().setbackground(new color(22,145,217)); c.add(pattern1); pattern1.setbounds(0,0,800,600); pattern1.setvisible(false); c.add(pattern2); pattern2.setbounds(0,0,800,600); pattern2.setvisible(false); c.add(pattern3); pattern3.setbounds(0,0,800,600); pattern3.setvisible(false); c.add(pattern4); pattern4.setbounds(0,0,800,600); pattern4.setvisible(false); c.add(pattern5); pattern5.setbounds(0,0,800,600); pattern5.setvisible(false); } public void paint (graphics g) { super.paint(g); g.setcolor(color.cyan); g.fillrect(30,100,180,600); g.setcolor(color.black); g.drawrect(30,100,180,600); g.setcolor(color.yellow); g.fillrect(40,120,160,50); g.fillrect(40,200,160,50); g.fillrect(40,280,160,50); g.fillrect(40,360,160,50); g.fillrect(40,440,160,50); g.fillrect(55,520,55,80); g.fillrect(120,520,55,80); g.setcolor(color.black); g.drawrect(40,120,160,50); g.drawrect(40,200,160,50); g.drawrect(40,280,160,50); g.drawrect(40,360,160,50); g.drawrect(40,440,160,50); g.drawrect(55,520,55,80); g.drawrect(120,520,55,80);// g.setcolor(color.red); g.fillrect(410,190,370,20); g.setcolor(color.black); g.drawrect(410,190,370,20);// g.setcolor(color.orange); g.fillrect(420,210,350,200); g.setcolor(color.black); g.drawrect(420,210,350,200);// g.setcolor(color.red); g.fillrect(410,400,370,20); g.setcolor(color.black); g.drawrect(410,400,370,20);// g.setcolor(color.orange); g.fillrect(420,420,350,200); g.setcolor(color.black); g.drawrect(420,420,350,200);// g.setcolor(color.white); g.fillrect(440,230,50,50); g.fillrect(510,230,50,50); g.fillrect(580,230,50,50); g.fillrect(650,230,50,50); g.fillrect(710,230,50,50); g.fillrect(440,320,50,50); g.fillrect(510,320,50,50); g.fillrect(580,320,50,50); g.fillrect(650,320,50,50); g.fillrect(710,320,50,50); g.fillrect(440,450,50,50); g.fillrect(510,450,50,50); g.fillrect(580,450,50,50); g.fillrect(650,450,50,50); g.fillrect(710,450,50,50); g.fillrect(440,520,50,50); g.fillrect(510,520,50,50); g.fillrect(580,520,50,50); g.fillrect(650,520,50,50); g.fillrect(710,520,50,50); g.setcolor(color.black); g.drawrect(440,230,50,50); g.drawrect(510,230,50,50); g.drawrect(580,230,50,50); g.drawrect(650,230,50,50); g.drawrect(710,230,50,50); g.drawrect(440,320,50,50); g.drawrect(510,320,50,50); g.drawrect(580,320,50,50); g.drawrect(650,320,50,50); g.drawrect(710,320,50,50); g.drawrect(440,450,50,50); g.drawrect(510,450,50,50); g.drawrect(580,450,50,50); g.drawrect(650,450,50,50); g.drawrect(710,450,50,50); g.drawrect(440,520,50,50); g.drawrect(510,520,50,50); g.drawrect(580,520,50,50); g.drawrect(650,520,50,50); g.drawrect(710,520,50,50);// g.setcolor(color.black); g.fillrect(320,10,10,100); g.setcolor(color.white); g.drawrect(320,10,10,100); g.setcolor(color.black); g.fillrect(275,100,100,150); g.setcolor(color.white); g.drawrect(275,100,100,150); g.setcolor(color.black); g.fillrect(250,250,150,150); g.setcolor(color.white); g.drawrect(250,250,150,150); g.setcolor(color.black); g.fillrect(225,370,200,250); g.setcolor(color.white); g.drawrect(225,370,200,250); g.fillrect(290,120,70,25); g.fillrect(290,150,70,25); g.fillrect(290,180,70,25); g.fillrect(290,210,70,25); g.fillrect(265,270,123,25); g.fillrect(265,300,123,25); g.fillrect(265,330,123,25); g.fillrect(245,400,160,25); g.fillrect(245,430,160,25); g.fillrect(245,460,160,25); g.fillrect(245,490,160,25); g.fillrect(245,520,160,25); g.fillrect(245,550,160,25); g.setcolor(new color(153,76,0)); g.fillrect(150,350,15,260); g.fillrect(133,370,50,20); g.setcolor(color.black); g.drawrect(150,350,15,260); g.drawrect(133,370,50,20); g.setcolor(new color(153,76,0)); g.fillrect(400,350,15,260); g.fillrect(383,370,50,20); g.setcolor(color.black); g.drawrect(400,350,15,260); g.drawrect(383,370,50,20); g.setcolor(new color(153,76,0)); g.fillrect(650,350,15,260); g.fillrect(633,370,50,20); g.setcolor(color.black); g.drawrect(650,350,15,260); g.drawrect(633,370,50,20); g.setcolor(color.black); g.drawarc(-50, 320, 200, 100, 180, 180); g.drawarc(-50, 330, 200, 100, 180, 180); g.drawarc(-50, 340, 200, 100, 180, 180); g.drawarc(166,320,236,100,180,180); g.drawarc(166,330,236,100,180,180); g.drawarc(166,340,236,100,180,180); g.drawarc(414,320,236,100,180,180); g.drawarc(414,330,236,100,180,180); g.drawarc(414,340,236,100,180,180); g.drawarc(665,320,236,100,180,180); g.drawarc(665,330,236,100,180,180); g.drawarc(665,340,236,100,180,180); g.setcolor(color.orange); g.fillrect(20,470,170,20); g.setcolor(color.black); g.drawrect(20,470,170,20); g.setcolor(new color(249,216,83)); g.fillrect(32,490,150,120); g.setcolor(color.black); g.drawrect(32,490,150,120); g.setcolor(color.cyan); g.fillrect(40,505,30,30); g.fillrect(90,505,30,30); g.fillrect(40,555,30,30); g.fillrect(90,555,30,30); g.fillrect(135,520,40,90); g.setcolor(color.black); g.drawrect(40,505,30,30); g.drawrect(90,505,30,30); g.drawrect(40,555,30,30); g.drawrect(90,555,30,30); g.drawrect(135,520,40,90); g.setcolor(new color(179,91,255)); g.fillrect(225,470,170,20); g.setcolor(color.black); g.drawrect(225,470,170,20); g.setcolor(color.magenta); g.fillrect(236,490,150,120); g.setcolor(color.black); g.drawrect(236,490,150,120); g.setcolor(new color(153,255,51)); g.fillrect(249,505,30,30); g.fillrect(249,555,30,30); g.fillrect(289,505,30,30); g.fillrect(289,555,30,30); g.fillrect(335,520,40,90); g.setcolor(color.black); g.drawrect(249,505,30,30); g.drawrect(249,555,30,30); g.drawrect(289,505,30,30); g.drawrect(289,555,30,30); g.drawrect(335,520,40,90); // g.setcolor(new color(247,199,103)); g.fillrect(445,470,170,20); g.setcolor(color.black); g.drawrect(445,470,170,20); g.setcolor(color.green); g.fillrect(455,490,150,120); g.setcolor(color.black); g.drawrect(455,490,150,120); g.setcolor(color.darkgray); g.fillrect(469,505,30,30); g.fillrect(469,555,30,30); g.fillrect(519,505,30,30); g.fillrect(519,555,30,30); g.fillrect(560,520,40,90); g.setcolor(color.black); g.drawrect(469,505,30,30); g.drawrect(469,555,30,30); g.drawrect(519,505,30,30); g.drawrect(519,555,30,30); g.drawrect(560,520,40,90); } public static void main(string args[]) { new scenery(); } public void keypressed(keyevent e) { string key = e.getkeytext(e.getkeycode()); if (key.equals("space")); { int n1 = (int) (math.random()*5); if (n1==1) { pattern1.setvisible(true); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==2) { pattern1.setvisible(false); pattern2.setvisible(true); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==3) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(true); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==4) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(true); pattern5.setvisible(false); n1=0; } if (n1==1) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(true); n1=0; } } } public void keyreleased(keyevent e) { repaint(); } public void keytyped(keyevent e) { }

}

thanks in advance if respond.

never draw straight in top level window such jframe or japplet. instead draw in jpanel's paintcomponent method tutorials tell give double buffering default.

also, want off load of magic numbers file belong info , not code. i'd static parts of drawing onto bufferedimage , display image in paintcomponent method via g.drawimage(...).

also, utilize key bindings , not keylistener has been discussed in other similar questions on site, , utilize arrays or lists , seek refactor code create more streamline , less needless repetition. , utilize imageicons pattern images, , 1 jlabel , swap icons. if did this, code:

int n1 = (int) (math.random()*5); if (n1==1) { pattern1.setvisible(true); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==2) { pattern1.setvisible(false); pattern2.setvisible(true); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==3) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(true); pattern4.setvisible(false); pattern5.setvisible(false); n1=0; } if (n1==4) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(true); pattern5.setvisible(false); n1=0; } if (n1==1) { pattern1.setvisible(false); pattern2.setvisible(false); pattern3.setvisible(false); pattern4.setvisible(false); pattern5.setvisible(true); n1=0; } }

if set pattern imageicons arraylist called patternlist, code simply:

int randomindex = (int) math.random() * patternlist.size(); mylabel.seticon(patternlist.get(randomindex));

you tell me easier debug , maintain.

java swing jframe paint

Android Getting Error ActivityNotFoundException -



Android Getting Error ActivityNotFoundException -

i'm new here in android programming seems can't find error need help

every time log in , click button btnlogin app stops.

login class

public class doclogin extends fragment { imageview ivicon; textview tvitemname, tvregister; edittext user, pass; button btnlogin; sqlcontroller dbcon; sessionmanager session; public doclogin() { } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.doc_log_in, container, false); session = new sessionmanager(getactivity()); dbcon = new sqlcontroller(getactivity()); dbcon.open(); // log in user = (edittext) view.findviewbyid(r.id.etuser); pass = (edittext) view.findviewbyid(r.id.etpassword); btnlogin = (button) view.findviewbyid(r.id.btnlogin); // sign tvregister = (textview) view.findviewbyid(r.id.tvregdoc); tvregister.setmovementmethod(linkmovementmethod.getinstance()); tvregister.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub fragmentmanager fm = getfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); ft.replace(r.id.content_frame, new docreg()); ft.commit(); homecoming false; } }); // btnlogin onclicklistener btnlogin.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { // todo auto-generated method stub dbcon = new sqlcontroller(getactivity()); dbcon.open(); log.v("logindetails", user.gettext().tostring() + "../.." + pass.gettext().tostring()); cursor cur = dbcon.getuser_information(user.gettext() .tostring(), pass.gettext().tostring()); if (cur.getcount() != 0) { fragmentmanager fm = getfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); ft.replace(r.id.content_frame, new docprofile()); ft.commit(); } else { alertdialog alertdialog = new alertdialog.builder( getactivity()).create(); alertdialog.settitle("login error"); alertdialog .setmessage("doctor code , password not match"); alertdialog.setbutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // todo auto-generated method stub // dismiss dialog } }); alertdialog.show(); } } }); homecoming view; } }

this error i'm getting

06-23 14:11:16.483: e/trace(4864): error opening trace file: no such file or directory (2) 06-23 14:11:27.783: e/androidruntime(4864): fatal exception: main 06-23 14:11:27.783: e/androidruntime(4864): android.content.activitynotfoundexception: unable find explicit activity class {com.droid/com.droid.doclogin}; have declared activity in androidmanifest.xml? 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.instrumentation.checkstartactivityresult(instrumentation.java:1541) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.instrumentation.execstartactivity(instrumentation.java:1416) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.activity.startactivityforresult(activity.java:3351) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.activity.startactivityforresult(activity.java:3312) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.activity.startactivity(activity.java:3522) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.activity.startactivity(activity.java:3490) 06-23 14:11:27.783: e/androidruntime(4864): @ com.droid.sessionmanager.checklogin(sessionmanager.java:41) 06-23 14:11:27.783: e/androidruntime(4864): @ com.droid.docprofile.oncreateview(docprofile.java:43) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:829) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1035) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.backstackrecord.run(backstackrecord.java:635) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1397) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.fragmentmanagerimpl$1.run(fragmentmanager.java:426) 06-23 14:11:27.783: e/androidruntime(4864): @ android.os.handler.handlecallback(handler.java:615) 06-23 14:11:27.783: e/androidruntime(4864): @ android.os.handler.dispatchmessage(handler.java:92) 06-23 14:11:27.783: e/androidruntime(4864): @ android.os.looper.loop(looper.java:137) 06-23 14:11:27.783: e/androidruntime(4864): @ android.app.activitythread.main(activitythread.java:4745) 06-23 14:11:27.783: e/androidruntime(4864): @ java.lang.reflect.method.invokenative(native method) 06-23 14:11:27.783: e/androidruntime(4864): @ java.lang.reflect.method.invoke(method.java:511) 06-23 14:11:27.783: e/androidruntime(4864): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 06-23 14:11:27.783: e/androidruntime(4864): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 06-23 14:11:27.783: e/androidruntime(4864): @ dalvik.system.nativestart.main(native method)

but after declaring doclogin class in androidmanifest

this error

06-23 14:09:53.463: e/androidruntime(4791): fatal exception: main 06-23 14:09:53.463: e/androidruntime(4791): java.lang.runtimeexception: unable instantiate activity componentinfo{com.droid/com.droid.doclogin}: java.lang.classcastexception: com.droid.doclogin cannot cast android.app.activity 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread.performlaunchactivity(activitythread.java:1983) 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2084) 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread.access$600(activitythread.java:130) 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread$h.handlemessage(activitythread.java:1195) 06-23 14:09:53.463: e/androidruntime(4791): @ android.os.handler.dispatchmessage(handler.java:99) 06-23 14:09:53.463: e/androidruntime(4791): @ android.os.looper.loop(looper.java:137) 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread.main(activitythread.java:4745) 06-23 14:09:53.463: e/androidruntime(4791): @ java.lang.reflect.method.invokenative(native method) 06-23 14:09:53.463: e/androidruntime(4791): @ java.lang.reflect.method.invoke(method.java:511) 06-23 14:09:53.463: e/androidruntime(4791): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 06-23 14:09:53.463: e/androidruntime(4791): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 06-23 14:09:53.463: e/androidruntime(4791): @ dalvik.system.nativestart.main(native method) 06-23 14:09:53.463: e/androidruntime(4791): caused by: java.lang.classcastexception: com.droid.doclogin cannot cast android.app.activity 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.instrumentation.newactivity(instrumentation.java:1053) 06-23 14:09:53.463: e/androidruntime(4791): @ android.app.activitythread.performlaunchactivity(activitythread.java:1974) 06-23 14:09:53.463: e/androidruntime(4791): ... 11 more

any ideas on this?

the activitynotfound exception shown because cannot find said activity. instead of class you've created, create android activity of same , declare in android manifest.

android activitynotfoundexception

php - Complicated relationship properties on Neo4j database -



php - Complicated relationship properties on Neo4j database -

i developing route planner on neo4j education purpose.i developed algorithm , using both of cypher query , rest api in project.bu there problem non-fixed me.i trying calculate different routes neo4j dijkstra, shortestpath , own algorithm.

for example, there nonsense routes calculating neo4j.the output gives many times transfer bus user,when utilize dijsktra algorithm in neo4j.also, it's shortestpath.i want give 5 times transfer maximum.how can prevent problem?

also, neo4j gives output on next segment of code;

0 => array( 'stop' => '1', 'stopid' => '163', 'stopname' => 'kalihi-palama bus facility', 'routeid' => (int) **132**, 'routename' => 'kalihi via school street express', 'routeshortname' => 'w3', 'relationship' => array( 'routeid' => (int) 79, 'routetype' => 'route', 'endnode' => '1' ) ), (int) 1 => array( 'stop' => '0', 'stopid' => '4523', 'stopname' => 'kalihi transit center', 'routeid' => (int) 1, 'routename' => 'kaimuki-kalihi', 'routeshortname' => '**132**', 'relationship' => array( 'routeid' => (int) 1, 'routetype' => 'route', 'endnode' => '54' ) ), (int) 2 => array( 'stop' => '54', 'stopid' => '38', 'stopname' => 's beretania st + opp kalakaua ave', 'routeid' => (int) **2**, 'routename' => 'waikiki-school-middle', 'routeshortname' => '2', 'relationship' => array( 'routeid' => (int) 2, 'routetype' => 'route', 'endnode' => '54' ) ), (int) 3 => array( 'stop' => '53', 'stopid' => '37', 'stopname' => 'kalakaua ave + s king st', 'routeid' => (int) **132**, 'routename' => 'waikiki-school-middle limited', 'routeshortname' => '2l', 'relationship' => array( 'routeid' => (int) 132, 'routetype' => 'route', 'endnode' => '53' ) ) ...

it's no sense giving routeid=2 bus.because, when off bus, can on same buss again.it's not smarty.how can prevent this?

i utilize code in next segment;

start n=node(5), m=node(45) match p=shortestpath(n-[r:route*..100]-m) homecoming p

thanks, best regards

php algorithm neo4j cypher dijkstra

c# - Serial communication, issues using native com port vs prolific usb->serial -



c# - Serial communication, issues using native com port vs prolific usb->serial -

i not exclusively sure if problem code, or hardware problem.

i have programme communicates one-way (receive only) equipment (fire alarm command panels specific.) when wrote program, done on pc doesn't have native serial port, used prolific serial->usb dongle. worked, part. got random 3f/? in info when connected 1 of 2 types of facps, figured converter acting up, stripped them output.

then ported on work laptops, dell's native com ports. , info garbled nonsense (mostly 3f/?.) see right character, it's nonsense. not right length of nonsense. using prolific converter, "works" in info expect - add-on of 3f/? between every single character. displayed fine if strip bad characters, that's inexpensive hack when else wrong.

an illustration of expected data, , received data:

//expected: fire alarm magnet lift shaft hoistway lift shaft z111 heat(fixed) 09:34:19a fri jun 06, 2014 l02d041 //received (approximation, not actual copy/paste don't have on pc): f?i?r?e?a?l?r?m??????? ????????m????t????e?lev?t?r s?h?a?f?t??h?o??s?t?w?a?y??? e?e??t???s?h?a?f?t ?z1?1?1heat(fixed) 0?9?:?34?19??af?r?i?j???n?6??2?1?4????

my current method of retrieving info via datareceivedhandler event , readline(). used readexisting() , readbyte(), result same each, went readline, because works best info i'm receiving (80 characters followed eol)

the port settings correct, 9600/8/1/none/xonxoff, per manufacturer , personal experience. both prolific converter , native serial port work fine in other programs such putty, procomm, or manufacturer software. @ 1 point ran called serialmon see sending, , getting same garbled non-sense. used test various port settings, no avail.

i wrote identical software in python , worked fine on both native com port on laptop , prolific converter. fact python software worked , other terminal programs work makes me think it's .net/c# need prepare on end.

so yeah... insight appreciated. serial relevant code below.

//declaring serialport com = new serialport(); //opening port com.portname = properties.settings.default.com; com.baudrate = properties.settings.default.baudrate; com.parity = properties.settings.default.parity; com.stopbits = properties.settings.default.stopbits; com.databits = properties.settings.default.databits; com.handshake = properties.settings.default.handshake; com.open(); //reading info buf = com.readline();

tl;dr: serial programme works, bad data, using prolific 2303 dongle. programme not work using native com port. other programs (putty, procomm, etc) work fine using both. similar python programme on same laptop works fine prolific , native com port. tried other port settings, tried port monitoring program. send help.

edit: equipment sends info in ascii form

thanks help guys. turns out parity error. serial port not accepting parity.none when assigned via user property, when cast parity type. defaulting parity.even (despite msdn saying none default?). ended doing setting properties application , letting user toggle between 2 acceptable sets, instead of having free run of port settings. seems have solved issue, , parity error free on both native serial port , converter.

what tipped me off setting parityreplace character, markus suggested. @ point became clear parity error. i'm still not sure why serialmon programme using getting same results, parity set none.

for reference, errorreceived not raised @ point.

again, help everyone.

c# serial-port

c++ - 'QMetaObject::connectSlotsByName: No matching signal for' error when building on Ubuntu QT -



c++ - 'QMetaObject::connectSlotsByName: No matching signal for' error when building on Ubuntu QT -

this question has reply here:

qmetaobject::connectslotsbyname: no matching signal 1 reply

i realise question has been asked before, though circumstances different , have found none of other answers helpful, new qtcreator.

i trying build project qtcreator, builds fine on osx when building ubuntu error:

qmetaobject::connectslotsbyname: no matching signal on_actionwrite_device_triggered()

the project still builds , partly works, not write external device (the point of program).

can give walkthrough of need do, previous answers have said explicitly connecting things, not gone details how this. tips on searching through project find create prepare (i didn't write original program).

any help appreciated tom

check out this: http://qt-project.org/doc/qt-4.8/qmetaobject.html#connectslotsbyname

the method connectslotsbyname tries connect slots signals using next form:

void on_<object name>_<signal name>(<signal parameters>);

object name , signal name separated underscore. i'm not sure may problem object name (actionwrite_device) contains underscore , hence not clear signal name (it either device_triggered or triggered). same holds object name. ambiguity might cause trouble.

c++ qt ubuntu

How to get rid of ascii encoding error in python -



How to get rid of ascii encoding error in python -

string = "deepika padukone, esha gupta or yami gautam - who's looks hotter , sexier? vote! - it's ... deepika padukone, esha gupta or yami gautam…. deepika padukone, esha gupta or yami gautam ... tag: deepika padukone, esha gupta, kalki koechlin, rang de basanti, soha ali khan, yami ... amitabh bachchan , deepika padukone seen in shoojit sircar's piku ..." fp = open("test.txt", "w+"); fp.write("%s" %string);

after running above code have got next error.

file "encode_error.py", line 1 syntaxerror: non-ascii character '\xe2' in file encode_error.py on line 1, no encoding declared; see http://www.python.org/peps/pep-0263.html details

you have u+2026 horizontal ellipsis character in string definition:

... deepika padukone, esha gupta or yami gautam…. ... ^

python requires declare source code encoding if utilize non-ascii characters in source.

your options to:

declare encoding, specified in linked pep 263. it's comment must first or sec line of source file.

what set depends on code editor. if saving files encoded utf-8, comment looks like:

# coding: utf-8

but format flexible. can spell encoding too, example, , utilize = instead of :.

replace horizontal ellipsis 3 dots, used in rest of string

replace codepoint \xhh escape sequences represent encoded data. u+2026 encoded utf-8 \xe2\x80\xa6.

python

twitter-bootstrap container should overlap another container -



twitter-bootstrap container should overlap another container -

i trying allow 1 container-fluid overlap container. sec container should positioned @ origin of first column. container-fluid should positioned @ border of browser screen.

i have tried far position: absolute , position: relative. here jsbin: http://jsbin.com/uforiyex/768/

anyone can help me accomplish that?

to sec container in first, add together top:0; .second css.

.second { background-color: #38a453; position: absolute; top: 0; }

twitter-bootstrap

Project Euler 3 Java ArithmeticException -



Project Euler 3 Java ArithmeticException -

this gets prime factors of number keeps going , outputs negative factors of number reason, help? link question here: http://projecteuler.net/problem=3

public static void main(string[] args) { long number = 600851475143l; divchecker(number); } public static void divchecker(long n) { int div = 2; while (div * div < n) { if (n % div == 0) { primechecker(div); div++; } else { div++; } } } public static void primechecker(long n) { int div = 2; while (div * div < n) { if (n % div != 0) { div++; } else { break; } } if (n % div != 0) { system.out.println(n); } }

output here:

71 839 1471 6857 -716151937 -408464633 -87625999 -10086647 -5753023 -1234169 -486847 -104441 -59569 -6857 -1471 -839 -71 -1 exception in thread "main" java.lang.arithmeticexception: / 0 @ bucky.divchecker(bucky.java:13) @ bucky.main(bucky.java:7)

your multiplications int overflowing, yielding "negative" factors.

declare div variables long instead of int.

long div = 2; // 2 places in code

with change, output only, , windows calculator verifies product original number factor, 600851475143l:

71 839 1471 6857

java

python - Which format is this config file in? -



python - Which format is this config file in? -

i have parse config files this:

begin key1 "value1" key2 "value2" begin key3 "value3" key4 "value4" end end

what format , there ready-made parser can utilize (preferably in perl/python)?

i don't know name of format, parser::mgc can create lite work of one.

by defining simple self-recursive parse method recognises begin blocks inner scopes, can build recursive tree of hash references input.

package myparser; utilize base of operations 'parser::mgc'; utilize strict; utilize warnings; # need exclude linefeeds whitespace pattern sub pattern_ws { qr/[\t ]+/ } sub parse { $self = shift; %items; $self->sequence_of( sub { $self->any_of( sub { # begin ... end block $self->expect( 'begin' ); $self->commit; $self->expect( qr/\n/ ); $self->scope_of( undef, sub { force @{$items{begin}}, $self->parse; }, 'end' ); $self->expect( qr/\n/ ); }, sub { # key "value" $key = $self->token_ident; $self->commit; $items{$key} = $self->token_string; $self->expect( qr/\n/ ); }, ) }); homecoming \%items; }

this can printed @ end, perhaps using data::dump:

use data::dump 'pp'; print stderr pp(myparser->new->from_file(\*stdin));

this gives

{ begin => [ { begin => [{ key3 => "value3", key4 => "value4" }], key1 => "value1", key2 => "value2", }, ], }

python perl config

wicked pdf - Header HTML has 100% height with wkhtmltopdf 0.12 -



wicked pdf - Header HTML has 100% height with wkhtmltopdf 0.12 -

i using wkhtmltopdf 0.12 wicked_pdf or pdfkit , header takes 100% of page height.

it creates these problems :

pages empty there many more pages should

solved adding

<!doctype html>

at top of header html file.

somewhat capricious, know...

wkhtmltopdf wicked-pdf pdfkit

c# - EPPlus date format but excel shows error -



c# - EPPlus date format but excel shows error -

ws.column(5).style.numberformat.format = "m/d/yyyy";

i setting column's cell format date, in spite of exel shows error besides every cell.???

i next write date excel

datecell.formula = string.format("=date({0},{1},{2})", clientfiledate.year, clientfiledate.month, clientfiledate.day);

c# epplus

wix - Install a file only if both the features are selected -



wix - Install a file only if both the features are selected -

there 2 features - feature1 , feature2;i need install file if both features selected, have written:

<component id="cmpcfa15f2c5dc1eeea145360ea017fb322" guid="*"> <condition><![cdata[(&feature1=3) , (&feature2=3)]]></condition> <file id="filcb4bd4847e5bdfc79a4308d520941a22" keypath="yes" source="$(var.binsourcedir)\hello.exe" /> </component>

but not work, help appreciated.what missing?.thanks in advance

feature states in component conditions won't work. see http://www.joyofsetup.com/2008/04/09/feature-states-in-component-conditions/ breakdown of why doesn't work.

wix windows-installer wix3 wix3.6 wix3.7

layout - Android Tablet Lyaout -



layout - Android Tablet Lyaout -

i noticed app not appear in googleplay tablet. created different layouts , inserted supports screens in manifest. missing? have studied documentation not understand missing. give thanks help. in manifest

<supports-screens android:smallscreens="true" android:normalscreens="true" android:largescreens="true" android:xlargescreens="true" android:anydensity="true" />

and created folders layouts:

layout-sw600dp layout-sw720dp layout-large layout-xlarge layout-xxlarge

and various drawable folders:

drawable drawable-hdpi drawable-ldpi drawable-mdpi drawable-xhdpi drawable-xxhdpi

the problem various things. need set right minimum , target sdk versions, provide screenshots of tablet layout of app , back upwards screen-sizes. creating folders isn't enough, need provide right drawables there, too.

to see missing, developer console.

if want sure app included in “designed tablets” view, go developer console check tablet optimization tips. if see issues listed there, you’ll need address them in app , upload new binary distribution. if there no issues listed, app eligible included in “designed tablets" view in top lists.

source: http://android-developers.blogspot.de/2013/10/more-visibility-for-tablet-apps-in.html

android layout tablet

node.js - phonegap run android - create Command failed with exit code 8 - linux -



node.js - phonegap run android - create Command failed with exit code 8 - linux -

i did googleing find nil approriate. help appreciated. seek naked vm sure having no nodejs install or dependency issue.

christian

sudo apt-get install nodejs sudo apt-get install nodejs-legacy sudo npm install -g phonegap sudo npm install -g cordova sudo apt-get install ant chris@mint16 ~/project/dev $ phonegap create my-app [phonegap] create called options /home/chris/project/dev/my-app com.phonegap.helloworld helloworld [phonegap] customizing default config.xml file [phonegap] created project @ /home/chris/project/dev/my-app chris@mint16 ~/project/dev $ cd my-app/ chris@mint16 ~/project/dev/my-app $ phonegap run android [phonegap] detecting android sdk environment... [phonegap] using local environment [phonegap] adding android platform... /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126 throw e; ^ error: error occurred while listing android targets @ /home/chris/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29 @ _rejected (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24) @ /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30 @ promise.when (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31) @ promise.promise.promisedispatch (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41) @ /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44 @ flush (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17) @ process._tickcallback (node.js:415:13) { [error: /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: command failed exit code 8] code: 8 } [error] /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: command failed exit code 8

i've faced same issue, problem path sdk tools not setup:

so seek following:

export path=$path:/usr/local/adt-bundle/sdk/tools export path=$path:/usr/local/adt-bundle/sdk/platform-tools export path=$path:/usr/local/adt-bundle/sdk/build-tools

android node.js cordova

Declare an integer in Java without using 'int' -



Declare an integer in Java without using 'int' -

i don't know utilize , please help me ? illustration cant utilize

short hour; long totalnumberofstars; //no can't utilize long or short

your question isn't clear,

long = (long) 1; short s = (short) 2; byte b = (byte) 3; integer = 4; int v = 5; char ch = 'a' + 1; // <-- or, 'b'

are integer (or integral) types. compared floating point types,

double d = 1.0; float f = 2.0f;

java integer

javascript - Chrome extension event page persistent for certain pages? -



javascript - Chrome extension event page persistent for certain pages? -

i have event page sets big connection indexeddb.

the extension uses database quite through message passing , wondering whether best maintain background persistent page alone.

i thinking maybe opening port connection , not closing it, bad idea?

when comes indexeddb can have 1 connection @ time, meaning if intend of having other pages (frames) access it, leaving open not work. however, if using messaging system, have windows talk same point of access , hence maintain connection open. it's not bad thought if plan on doing that, maintain in mind if allow multiple instances of application run in parallel, might not idea.

javascript google-chrome-extension

javascript - How to fire event on general DOM object resize with jquery -



javascript - How to fire event on general DOM object resize with jquery -

there event on window resize.

$(window).resize(function() { ... });

but if want fire event on type if dom objects, like:

$('div#mydiv').resize(function() { ... ));

but above seemed not work. possible , convenient? or other way?

this plugin offers ability create resize events based on element:

a cross-browser, event-based, element resize detection.

in short, implementation not utilize internal timer observe size changes (as implementations found do). uses scroll events on browsers, , onresize event on ie10 , below.

the method used not detects javascript generated resize changes changes made css pseudo classes e.g. :hover, css animations, etc.

https://github.com/sdecima/javascript-detect-element-resize

javascript jquery

I get {"error":"unauthorized"} when trying to run .php file on Apache server -



I get {"error":"unauthorized"} when trying to run .php file on Apache server -

php file need run on localhost server. have downloaded mamp , changed apache port 80. added file htdocs folder , when run server , go localhost can see .php file in list. when click on next error: {"error":"unauthorized"} , nil else. im using file ios app , need know can access file via localhost adress. im new php if help grateful. thanks.

the code:

<?php header('content-type:application/json'); $appid = $_post['appid']; $restapi = $_post['restapi']; $alert = $_post['alert']; $channels = str_replace(' ', '', $_post['channels']); $channels = explode(",",$channels); $url = 'https://api.parse.com/1/push'; $data = json_encode( array( 'channels' => $channels, 'type' => 'ios', 'data' => array( 'alert' => $alert, 'sound' => 'push.caf', 'badge' => 'increment' ) ),true ); $curl = curl_init(); $curlarray = array( curlopt_post => true, curlopt_postfields => $data, curlopt_returntransfer => true, curlopt_header => false, curlopt_encoding => "gzip", curlopt_httpheader => array( 'x-parse-application-id: ' . $appid, 'x-parse-rest-api-key: ' . $restapi, 'content-type: application/json', 'content-length: ' . strlen($data), ), curlopt_url => $url ); curl_setopt_array($curl, $curlarray); $response = curl_exec($curl); $code = curl_getinfo($curl, curlinfo_http_code); curl_close($curl); echo $response; ?>

php apache localhost mamp

ios - Searching a UITableView: cell images won't change -



ios - Searching a UITableView: cell images won't change -

i filtering array in way provide content table view:

- (void)filtercontentforsearchtext:(nsstring*)searchtext scope:(nsstring*)scope { nspredicate *resultpredicate = [nspredicate predicatewithformat:@"self contains[c] %@", searchtext]; filteredtabledata = [[allfilenames filteredarrayusingpredicate:resultpredicate] mutablecopy]; } -(bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring { [self filtercontentforsearchtext:searchstring scope:[[self.searchdisplaycontroller.searchbar scopebuttontitles] objectatindex:[self.searchdisplaycontroller.searchbar selectedscopebuttonindex]]]; homecoming yes; }

when alter text in search bar, search done , see cells similar names popping up. cell.imageview.image seems not changing. right title label image before search in cell... why happen?

ios

sql - How to select constant value if the Considered value not found? -



sql - How to select constant value if the Considered value not found? -

first of all, i'm sorry bad title i'm selected question. :)

in database have employee , comment tables seen below. each employee can save his/her activities in comment table , manager can see study of employees activity.

i'm using query select employees activity each month in specific year.

select month , isnull(( select ( firstname + '' + lastname ) dbo.employee employeeid = c.employeeid ), '') [name] , isnull(count(employeeid), 0) [count] dbo.comment c year = 1393 grouping month , employeeid order c.employeeid

and result is:

but want this, if each of employees haven't activity in each month, select row month|name|0 month , employee.

how can that?

update i'm changed query this:

declare @aa table ( m int ) declare @c int= 1 while @c < 13 begin insert @aa ( m ) values ( @c -- m - int ) set @c = @c + 1 end select m , ( select ( firstname + ' ' + lastname ) dbo.employee employeeid = c.employeeid ) [name] , count(commentid) [count] dbo.comment c right bring together @aa on m = month grouping m , employeeid order m

and result is:

but want have result:

below 1 method, using cte , cross bring together employee/month combinations.

with employees ( select employeeid , firstname + '' + lastname name dbo.employee ) ,months ( select month (values(1),(2),(3),(4),(5),(6),(7),(8),(8),(10),(11),(12)) months(month) ) select m.month ,e.name ,(select count(*) dbo.comment c c.employeeid = e.employeeid , c.month = m.month , c.year = 1393 ) count months m cross bring together employees e order month ,name;

sql sql-server entity-framework group-by

jquery - use $.subscribe in file javascript -



jquery - use $.subscribe in file javascript -

when utilize methods illustration $.subscribe('grillacompleta',function(){...}; in file javascript, not work; if utilize in same jsp page, work.

it work:

<script type="text/javascript"> $.subscribe('grillacompleta',function(){...}; </script>

don't work, if code in file javascript:

<script type="text/javascript" src="js/codigojavascript.js"></script>

codigojavascript.js short:

function onchangeturnomarcacion(event){ $('#txtbuscar').val(''); $('#grilla').jqgrid('setgridparam',{url:'cargarmarcacion.html? idperiodo='+$('#cboperiodos').val()+'&idcentrocosto='+$('#cbounidades') .val()+"&turno="+event.value}).trigger('reloadgrid'); }; $.subscribe('grillacompleta',function(){ var grid = $("#grilla"); var ids = grid.jqgrid("getdataids"); ( var = 0; < ids.length; i++) { var id = ids[i]; var row = grid.jqgrid("getrowdata",id); ( var j = 1; j < 32; j++) { if (j<10){ var color = row["d0"+j+"_c"]; grid.jqgrid('setcell',id,'d0'+j,'',{'background-color':color},{'title':j}); }else{ var color = row["d"+j+"_c"]; grid.jqgrid('setcell',id,'d'+j,'',{'background-color':color},{'title':j}); } } } }); function onchangeperiodomarcacion(event){ $('#txtbuscar').val(''); $('#grilla').jqgrid('setgridparam',{url:'cargarmarcacion.html? idperiodo='+event.value+'&idcentrocosto='+$('#cbounidades') .val()+"&turno="+$('#cboturnos').val()}).trigger('reloadgrid'); };

is practice have code in file javascript.

the $.subsribe() bound document, create sure document ready.

$(document).ready(function(){ $.subscribe(...); ... });

note functions in javascript don't require ending semicolon.

javascript jquery struts2 jqgrid

php - List brand only once from table -



php - List brand only once from table -

i have table of products. each product has field 'brand'

i need list brands on page, more 1 product can have same brand. how list brand once? soi 5 products have same brand name im not getting brand name 5 times.

$data=mysqli_query($link, "select brand products"); while($info=mysqli_fetch_array($data)){ $output .= '<div class="brands">'; $output .=$info["brand"]; $output.='</div>';

this outputs every instance of brand

thanks

select distinct brand products

this should work.

php mysql

javascript - Query through Json object -



javascript - Query through Json object -

this json:

[{"id":1,"order":1,"isdone":true,"text":"abc","date":"6/14/2014"}, {"id":2,"order":2,"isdone":false,"text":"cde","date":"6/15/2014"}, {"id":3,"order":3,"isdone":false,"text":"fgh","date":"6/16/2014"}]

what efficient way count of isdone == true?

you can utilize plain javascript iteration:

var a=[{"id":1,"order":1,"isdone":true,"text":"abc","date":"6/14/2014"},{"id":2,"order":2,"isdone":false,"text":"cde","date":"6/15/2014"},{"id":3,"order":3,"isdone":false,"text":"fgh","date":"6/16/2014"}] var ct=0; a.foreach(function(entry) { if(entry.isdone)ct++; }); alert(ct);

javascript

javascript - jQuery convert one element to another -



javascript - jQuery convert one element to another -

i have div element below;

<div class="editabletxt" data-model-attr="myattr" data-model-id="302">value</div>

i want converted to

<input class="editbox" data-model-attr="myattr" data-model-id="302" value="value" />

is there generic way same?

assume within callback & $(this) represents div element..

try

$('.editabletxt').each(function () { var $input = $('<input/>').val($.trim(this.innerhtml)); $.each(this.attributes, function (i, attr) { $input.attr(attr.name, attr.value); }); $(this).replacewith($input) })

demo: fiddle

javascript jquery

c# - ModelState validation checking multiple boolean property -



c# - ModelState validation checking multiple boolean property -

i have view model have multiple boolean properties, in controller have checking modelstate.isvalid before proceeding service layer. want create modelstate.isvalid homecoming false if none of boolean property set true, there way create happen?

here sample class

public class role { public int id {get; set;} [required(errormessage = "please come in role name")] public string name {get; set;} public bool iscreator {get; set;} public bool iseditor {get; set;} public bool ispublisher {get; set;} }

i implement own validation method on model. model end looking this:

public class role : ivalidatableobject { public int id {get; set;} [required(errormessage = "please come in role name")] public string name {get; set;} public bool iscreator {get; set;} public bool iseditor {get; set;} public bool ispublisher {get; set;} public ienumerable<validationresult> validate(validationcontext validationcontext) { if (!this.iscreator && !this.iseditor && !this.ispublisher)) { yield homecoming new validationresult("you must creator, editor or publisher"); } } }

notice how model:

implements ivalidateableobject has method named validate returns type ienumerable<validationresult>

during model binding process method automatically called , if validation result returned modelstate no longer valid. using familiar code in controller create sure don't take action unless custom conditions check out:

public class somecontroller { public actionresult someaction() { if (modelstate.isvalid) { //do stuff! } } }

c# asp.net-mvc viewmodel model-validation

cocoa: how do I draw camera frames on to the screen -



cocoa: how do I draw camera frames on to the screen -

what trying display photographic camera feeds within nsview using avfoundation. know can achieved using "avcapturevideopreviewlayer". however, long term plan frame processing tracking hand gestures, prefer draw frames manually. way did utilize "avcapturevideodataoutput" , implement "(void)captureoutput: didoutputsamplebuffer: fromconnection:" delegate function.

below implementation of delegate function. within delegate function create cgimage sample buffer , render onto calayer. not work not see video frames rendered on screen. calayer (mdrawlayer) created in function "awakefromnib" , attached custom view in story board. verify calayer creation setting background colour orange , works.

- (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer: (cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection { cvimagebufferref pixelbuffer = cmsamplebuffergetimagebuffer(samplebuffer); cvpixelbufferlockbaseaddress(pixelbuffer, 0); uint8_t *baseaddress = (uint8_t *)cvpixelbuffergetbaseaddress(pixelbuffer); size_t bytesperrow = cvpixelbuffergetbytesperrow(pixelbuffer); size_t width = cvpixelbuffergetwidth(pixelbuffer); size_t height = cvpixelbuffergetheight(pixelbuffer); cgcolorspaceref colorspace = cgcolorspacecreatedevicergb(); cgcontextref newcontext = cgbitmapcontextcreate(baseaddress,width,height, 8, bytesperrow, colorspace, kcgbitmapbyteorder32little | kcgimagealphapremultipliedfirst); cgimageref imgref = cgbitmapcontextcreateimage(newcontext); mdrawlayer.contents = (id) cfbridgingrelease(imgref); [mdrawlayer display]; cvpixelbufferunlockbaseaddress(pixelbuffer, 0); }

obviously not doing correctly, how should render photographic camera frames 1 1 onto calayer? also, know if approach correct. standard way of doing this?

your help appreciated. thanks:)

cocoa camera avfoundation

magnific popup - Modal dialog. - Confusing -



magnific popup - Modal dialog. - Confusing -

i trying open simple modal dialog , have been struggling this. can

any 1 please help? html code(please remove pre). doesnot work.

can 1 please tell **strong text**me why? have not been getting kind of output need.

any 1 help me.

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="css/magnific-popup.css" rel="stylesheet" /> <script src="js/jquery.magnific-popup.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script> </head> <body> <a class="popup-modal" href="#test-modal">open modal</a> <div id="test-modal" class="white-popup-block mfp-hide"> <h1>modal dialog</h1> <p>you won't able dismiss usual means (escape or click button), can close programatically based on user choices or actions.</p> <p><a class="popup-modal-dismiss" href="#">dismiss</a></p> </div> <script> $(function () { $('.popup-modal').magnificpopup({ type: 'inline', preloader: false, focus: '#username', modal: true }); $(document).on('click', '.popup-modal-dismiss', function (e) { e.preventdefault(); $.magnificpopup.close(); }); }); </script> </body> </html>

load jquery before magnific-popup plugin, relies on jquery (i've never used i'm assuming seeeing pre-appended withfixed 'jquery')

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link href="css/magnific-popup.css" rel="stylesheet" /> <!-- jquery loaded first here... --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></script> <!-- plugins after... --> <script src="js/jquery.magnific-popup.js"></script> </head> <body>

magnific-popup