Wednesday 15 June 2011

python - Transposing a numpy matrix causes cv's draw functions to throw errors -



python - Transposing a numpy matrix causes cv's draw functions to throw errors -

i've been running few problems using cv display images numpy matrices when transpose them.

consider next code.

import cv2, numpy np ... ones = np.ones((100,100)) onest = np.copy(ones.t) onesct = np.copy(ones.t, order='c') cv2.circle(ones, (50,50), 3, (0), thickness=-1) cv2.circle(onesct, (50,50), 3, (0), thickness=-1) cv2.circle(onest, (50,50), 3, (0), thickness=-1)

the first 2 "cv2.circle" calls work 3rd 1 gives me next error:

102 cv2.circle(ones, (50,50), 3, (0), thickness=-1) 103 cv2.circle(onesct, (50,50), 3, (0), thickness=-1) --> 104 cv2.circle(onest, (50,50), 3, (0), thickness=-1) typeerror: layout of output array img incompatible cv::mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)

why happen transposed matrices not if alter order in memory copied? me, matrices same.

at 1 level of abstraction, matrices same. @ lower level, 2 of them have info stored using c convention (row-major order) arrays, , other (onest) uses fortran convention (column-major order). apparently cv2.circle expects c-contiguous array.

you can check order using flags attribute. note f_contiguous flag of onest true:

in [24]: ones.flags out[24]: c_contiguous : true f_contiguous : false owndata : true writeable : true aligned : true updateifcopy : false in [25]: onest.flags out[25]: c_contiguous : false f_contiguous : true owndata : true writeable : true aligned : true updateifcopy : false in [26]: onesct.flags out[26]: c_contiguous : true f_contiguous : false owndata : true writeable : true aligned : true updateifcopy : false

a concise way check order info np.isfortran:

in [27]: np.isfortran(onest) out[27]: true

onest uses fortran order because transpose of 2-d array implemented in numpy swapping "strides" each dimension, without copying array of values in memory.

for example,

in [28]: x = np.array([[1, 2, 3], [4, 5, 6]]) in [29]: np.isfortran(x) out[29]: false in [30]: np.isfortran(x.t) out[30]: true

(this makes transpose operation efficient.)

you copied transposed array create onest, if @ docstring of np.copy, you'll see default value of order argument 'k', means "match layout of closely possible." in particular, preserves fortran order in case. onesct, on other hand, c-contiguous array because explicitly told np.copy order re-create using c convention.

python opencv numpy

c++ - Why does this double-free error happen? -



c++ - Why does this double-free error happen? -

i have base of operations , derived class:

in a.h:

//includes class { protected: static std::string a; //other dummy code };

in a.cpp

std::string a::a = "bar"; //other dummy code

in b.h:

#include "a.h" //other includes class b : public { public: int c; //other dummy code };

main.cpp:

#include "a.h" #include "b.h" int main() { printf("foo"); homecoming 0; }

now compile a.cpp , b.cpp 2 separate shared libraries "a.so" , "b.so" , link them against main.cpp. when run programme - quits corrupted-double-linked list error. running valgrind see there invalid free error. why happen?

i understand each .so file must have own re-create of static global variables, happens when derived class in different shared library while base of operations class in different shared library , there static variables in base of operations class? how memory allocated/destructed static variables in base of operations class, across libraries derived classes present?

i understand each .so file must have own re-create of static global variables

you understand incorrectly, unless linked a.o both a.so , b.so each .so file not have it's own re-create of static a::a. a.o should linked a.so , b.so shoould linked a.so, not a.o

c++ destructor double-free

javascript - Collapse Expand in jquery -



javascript - Collapse Expand in jquery -

i trying expand , collapse content in jquery. toggle responding reversely. when expanding, showing content bottom top , when collapsing, showing content top bottom. , also, when expanding, want image come right of content. , when collapsing, should collapse , set top.

before:

i need this:

here tried.

class="snippet-code-js lang-js prettyprint-override">ons.bootstrap(); $(document).ready(function() { $(".header").click(function() { $(".content").slidetoggle(); }); }); class="snippet-code-html lang-html prettyprint-override"><link href="http://components.onsen.io/onsen-css-components-default.css" rel="stylesheet" /> <link href="http://components.onsen.io/patterns/lib/onsen/css/onsenui.css" rel="stylesheet" /> <script src="http://components.onsen.io/patterns/lib/onsen/js/angular/angular.js"></script> <script src="http://components.onsen.io/patterns/lib/onsen/js/onsenui.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <ons-list-item style="min-height: 20px; line-height: 20px;" class="list__item ons-list-item-inner"> <div style="cursor:pointer; margin-left: 291px;" class="header"> <ons-icon style="font-size: 23px; font-weight: bold; color: #000000; width: 1em" icon="ion-navicon" class="ons-icon ion-more ons-icon--ion ons-icon--fw fa-lg"></ons-icon> </div> <div style="margin-left: 12px; margin-top: -15px; display: block;" class="content"> <span style="font-family: arial; font-size: 14px; color: #666666;">content 1<br>content 2</span> </div> </ons-list-item>

the .content div should start display:none if want accomplish effect.

javascript jquery html css

javascript - Single header for multiple web pages -



javascript - Single header for multiple web pages -

i want utilize 1 header pages in project directory website. little bit confused. if kept single header , import in web pages impact seo? can crawler crawl header each page? want way not impact seo of website.

try :

<html lang="en"> <head> <title></title> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="description" content=""> <?php include 'header.php'; ?>

in header.php utilize static content such css,javascript etc.

header.php

<link rel="icon" href="../../favicon.ico"> <link href="css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" href="css/responsive.css"> <link href='http://fonts.googleapis.com/css?family=open+sans:400,300,300italic,400italic,600,600italic,700,800,800italic,700italic' rel='stylesheet' type='text/css'> </head>

i think, problem solved doing this

javascript php html5 seo web-crawler

Is chrome.storage.sync data cleared when an extension or app is uninstalled? -



Is chrome.storage.sync data cleared when an extension or app is uninstalled? -

i have simple chrome extension uses chrome.storage.sync store list of tasks.

the next command in console clear sync info extension:

chrome.storage.sync.clear()

if users having problem syncing, can instruct them uninstall extension , install 1 time again have same effect command?

it's 1 of questions reply "why don't seek it?"

i have test extension published in chrome web store storage.sync testing. can confirm uninstalling chrome sync enabled nukes storage.

google-chrome google-chrome-extension

ios - How to use a protocol to SKPSMTPMessageDelegate in Swift? -



ios - How to use a protocol to SKPSMTPMessageDelegate in Swift? -

i'm using skpsmtpmessage send mails, when add together functions need skpsmtpmessagedelegate. add together this:

class viewcontroller: uiviewcontroller, skpsmtpmessagedelegate

but error: type 'viewcontroller" not conform protocol 'skpsmtpmessagedelegete'

an don't know how add together this, because need write @objc protocol ??

@objc protocol skpsmtpmessagedelegate{ //code here? }

thanks!

if you're getting message not conforming skpsmtpmessagedelegate, doesn't mean have define protocol. means protocol defined (in skpsmtpmessage.h) , you've failed implement messagesent and/or messagefailed. create sure implement both of functions in viewcontroller class:

func messagesent(message: skpsmtpmessage!) { <#code#> } func messagefailed(message: skpsmtpmessage!, error: nserror!) { <#code#> }

ios objective-c xcode swift

How to add a file as attachment in Spring integraion Webservices outbound gateway -



How to add a file as attachment in Spring integraion Webservices outbound gateway -

i have spring integration outbound gateway webservices. till time, send request in xml format web services. now, need send file part of request web service. how that? below spring integration chain existing configuration:

<!-- chain process requests xxxxx--> <int:chain id="pstestchain" input-channel="pstestinputchannel" > <!-- set transformer input message --> <int:transformer method="transform" ref="testrequestxformer"/> <!-- spring integration chain first adds service name , service operation headers spring integration message using header <int:header-enricher> <int:header name="#{xxxxxxxxx}" value="testsearch" /> <int:header name="#{xxxxxx}" value="searchbytestidentifier" /> </int:header-enricher> <!-- ws outbound gateway used create outgoing soap call. --> <int-ws:outbound-gateway id="simplegateway" destination-provider="testdestinationprovider" message-sender="testhttpsmessagesender" interceptor="test_wss4jinterceptor" header-mapper="testsoapheadermapper"/> <!-- set transformer output message --> <int:transformer method="transform" ref="testresponsexformer"/> </int:chain>

take look, please, mtom sample spring ws project.

since spring integration ws module based on spring ws, think there won't mutch difference build jaxb object attachements message payload , send <int-ws:outbound-gateway> marshaller injection.

we have open issue on matter, don't have plenty time see should there.

i've raised ticket spring integration samples track ability of mtom in spring integration.

attachment spring-integration

function - C: How do I make a number always round up -



function - C: How do I make a number always round up -

i'm wanting create function calculates cost based on time. time less 3 hours, homecoming flat rate charge of $2. each hr or part of hr on that, charge additional $0.50. hours input user float info type 2 decimal places. how can create round time whole hour? here's code have far function:

int calculatecharges(float hours) { if (hours <= 3){ homecoming 2.00 } else

first of all, utilize info type int, cannot hold fractional values (and implicitly round them towards zero, before function ever called.) should utilize double instead, since proper datatype fractional numbers.

you want utilize ceil(x) function, gives nearest whole number larger or equal x.

#include <math.h> double calculatecharges(double hours) { if (hours <= 3) { homecoming 2.00; } else { // homecoming $2.00 first 3 hours, // plus additional $0.50 per hr begun after homecoming 2.00 + ceil(hours - 3) * 0.50; } }

c function rounding

Can PHP filesize() method be spoofed with image metadata? -



Can PHP filesize() method be spoofed with image metadata? -

the php filesize() method used determine size of file in bytes. 1 illustration determine size of image file. if method gets info images metadata, possible spoofed modifying image metadata somehow, or method calculate file size based on true contents of image file?

<?php filesize(); ?>

the function filesize

returns size of file in bytes, or false (and generates error of level e_warning) in case of error.

http://php.net/manual/en/function.filesize.php

it not in way seek interpret image metadata.

php image image-processing metadata filesize

PHP DOTNET Interop with C# Windows Form Application? -



PHP DOTNET Interop with C# Windows Form Application? -

is possible have php interact running c# windows form application?

i've created com exposed dlls before , called them php using dotnet object didn't seem work me "windows form application". need create com dll , have somehow interact windows form application?

edit:

i decided write quick exe in .net3.5 client framework , see if methods available php then. appears run methods now, bizzare! guess possible v3.5 client , not v4.5.

this c# , php code:

c#

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace example.interop.formtext { public partial class form1 : form { public form1() { initializecomponent(); } public int sum(int a, int b) { homecoming + b; } public int minus(int a, int b) { homecoming - b; } } }

php

<?php $app = new dotnet("example.interop.formtext", "example.interop.formtext.form1"); echo $app->minus(19, 20); ?>

i haven't tested see if can run function interacts ui though. test next, unfortunately don't think can fallback on v3.5 project.

what want this:

out-of-process com component

i did vb6 programme 15 years ago , worked say! had main form, nail asp 3.0 site. had guts of site's app in , served admin, had no problem updating ui either com methods fired.

description link below (this reply useless without due complexity of problem; link includes download sample app. maybe can google text if link dies).

in microsoft windows operating systems, microsoft com technology enables software components communicate other software components. can utilize microsoft com technology create reusable software components. can develop applications linking these components , take advantage of windows services. out-of-process server objects implemented in executable file , run in separate process space.

http://support.microsoft.com/kb/977996

c# php com interop

Simulate a tfs style changeset in the enterprise version of github -



Simulate a tfs style changeset in the enterprise version of github -

i have 3 environments; dev, test , staging/prod. in our previous model of using team foundation server, have 3 branches of code matched each of these 3 environments.

developers work locally , when had code complete, they'd check dev branch. when checking in, tfs automatically creates called changeset. check-in kick off build of files code gets deployed dev environment.

when developer happy code in dev, they'd merge changeset test branch. they'd pull finish list of of available changesets dhad not been merged test, they'd select theirs , check test branch. again, kick off build , output files deployed test.

once qa happy changes, dev merge changeset prod branch. kicking off build , files deployed staging area. developer , qa them promote these files prod.

all of allow multiple developers work on same files using changeset mentality. when specific changeset (or set of changesets) merged environment, changes merged.

in relatively new exposure git, cannot seem find way select specific "pull requests" (which assume similar tfs changeset) 1 branch branch. when seek create pull request 1 branch branch, wants pull in not pull request, every other pull request made in lower branch other developers too. magic way create happen?

note: unfortunately don't have notion of "release". have 5 scrum teams working on 1 website on 200 pages. each scrum team has own sprints , can release multiple scrum stories during sprint. have internally 1 dev environment, , 1 test environment , 1 prod environment. not our environments used these 5 scrum teams, these dev/test/prod sites used various other teams integration efforts applications sell , client business relationship management , purchasing. cannot alter infrastructure.

note: not give-and-take if "changeset" methodology right or proper. question of how accomplish behavior in github/git.

note: set of scrum-based agile teams. work stories. many 60 stories can actively in development @ 1 time our big team of 25+ developers. when 1 story ready prod, promote prod environment atomic unit. think of changeset story.

i have 2 thoughts:

don't way. instead, should git-flow. http://danielkummer.github.io/git-flow-cheatsheet/ , http://nvie.com/posts/a-successful-git-branching-model/ explanations. @ it's core, git-flow naming convention branches, it's not tied git @ all. in essence, have feature branches each developer or dev team works on. 1 time finish feature, merge develop. develop "done features" -- not "done done" rather "feature complete." when deem time release, fork new release/someversion branch (name match release name), , work qa harden release. commits on release/someversion branch bug fixes. 1 time it's plenty deploy, fast-forward master branch release branch force production. master represents what's in production. deploy, merge release/someversion develop bug fixes mainline of development. project manager / product owner can think of develop branch "the latest," , developers can go on on feature branches until they're feature complete. (hint, create features little -- hr or day. features not releases.)

so why improve way doing it? if feature done, ready plenty qa start banging on it, it's done plenty part of next release. picking , choosing features around each other lead subtle , unpredictable bugs. since you're re-merging @ each step, have possibility you'll merge incorrectly, creating bug. you're creating unique product each step, production different set of features vetted in dev , test. (will bad things? inquire pharmacist if these drugs interact when taken together.)

git-flow works great cadences have coordinated, infrequent, larger releases. closer continuous delivery, ceremony in way. @ point, may take flip github flow or similar lighter-weight naming convention.

if you're really, really, (see above "you shouldn't way" comment) convinced should way, first, go convince rubber duck , have talked out of it. if you're still really, convinced need this, you'll need squash commits creating 1 big commit entire feature, cherry pick changeset between branches.

there's few disadvantages "squash , cherry-pick" approach. 1. lose history. since you're squashing history together, have maintain features in contained bundles, , edit bundle whole. 1 of primary premises of source command audit history -- both roll if goes wrong, , reference when need larn why works way or talk it. (see "git blame".) when squash, intentionally remove learning tool. 2. you're playing features place in different orders. you're doing merges. makes git awesome merging easy. makes git merging easy in little pieces. methodology of squashing associated feature 1 huge commit , cherry-picking between branches means you're doing big merges ... means hard.

yeah, know you're quite enamored way it's been, , don't want telling babe ugly. sorry. babe ugly. on bright side, doesn't need be. git flow awesome, , can facilitate velocity team needs.

github tfs changeset

jquery - Javascript callbacks gets processed faster than others -



jquery - Javascript callbacks gets processed faster than others -

i'm using javascript sdk plugin facebook create feed on webpage.

the problem during load feed gets unordered, if have setup callback chain.

i think gets unordered because "second" async phone call gets processed faster "first" async call.

this first time i've been using callbacks, doing right?

how can solve feed gets unordered if calls finish faster others?

the code below relevant code , under working status.

function initfeed(){ fb.api('/{id}/feed', function(response){ var feedarray = response.data; $.each(feedarray, function(){ var $this = $(this)[0]; //status object single status in feed setstatus($this, processstatus); //processstatus function defined below }); }); } function setstatus(statusobject, callbackprocessstatus){ fb.api("/{personid}?fields=id,link,name,picture", function (response) { var html = /* generates html based statusobject , response */ callbackprocessstatus(html); }); } function processstatus(html){ $('#fb-status-wrapper').append(html); }

(was uncertain on title of post, please edit if think not descriptive enough) best regards

indeed cannot rely on order in requests finish. way sure, phone call sec 1 if first 1 done. slow downwards loading quite lot.

another possibility remember each request 1 is, , insert items in right order (insert before 'later' one, if 1 received earlier).

i think easiest way that, create placeholders items within each loop, placeholders inserted in right order. when requests return, place responses in right placeholder.

it this. 2 lines , couple of tiny changes. couldn't test without api, hope idea.

function initfeed(){ fb.api('/{id}/feed', function(response){ var feedarray = response.data; $.each(feedarray, function(index){ var $this = $(this)[0]; //status object single status in feed // create container per item within wrapper. var $itemcontainer = $('<div></div>'); $('#fb-status-wrapper').append($itemcontainer); // pass container api function. setstatus($this, processstatus, $itemcontainer); //processstatus function defined below }); }); } function setstatus(statusobject, callbackprocessstatus, $container){ fb.api("/{personid}?fields=id,link,name,picture", function (response) { var html = /* generates html based statusobject , response */ // pass item place holder/container processing procedure. callbackprocessstatus(html, $container); }); } function processstatus(html, $container){ $container.append(html); }

javascript jquery facebook-javascript-sdk

javascript - AngularJS Multi-Step Form Using UI-Router (With Navigation Links) -



javascript - AngularJS Multi-Step Form Using UI-Router (With Navigation Links) -

i followed tutorial implement own multi-step form: http://scotch.io/tutorials/javascript/angularjs-multi-step-form-using-ui-router

the problem here works if page form page , nil else. have spa has 4 pages, 1 of registration form.

home registration mechanics terms & conditions

my index.php

<div class="container"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" ui-sref="home"><img src="assets/img/logo.png" alt=""></a> </div> <nav class="navbar navbar-default" role="navigation"> <ul class="nav navbar-nav home"> <li><a ui-sref="home">home</a></li> <li><a ui-sref="registration">registration</a></li> <li><a ui-sref="mechanics">mechanics</a></li> <li><a ui-sref="terms-conditions">terms & conditions</a></li> </ul> </nav> </div><!-- .container-fluid --> <div ui-view=""></div><!-- load contents via angular views --> </div><!-- .container -->

i using ui-router navigate through these pages. works okay. tried utilize ui-router within registration page nested views, apparently not behave expected. want registration page load first nested view, not bind it. here nested views:

registration-profile.php (should default view) registration-artist.php (step 2) registration-share.php (final step)

here stateprovider code mixing 2 (navigation , registration nested views):

spinnrapp.config(function ($stateprovider, $urlrouterprovider) { // // set states $stateprovider .state('home', { url: "/", templateurl: "app/components/home/home.php" }) .state('registration', { url: "/registration", templateurl: "app/components/registration/registration.php", controller: "regcontroller" }) .state('registration.profile', { // nested state registration form url: "/profile", // url nested /registration/artist templateurl: "app/components/registration/partials/registration-profile.php" }) .state('registration.artist', { // nested state registration form url: "/artist", // url nested /registration/artist templateurl: "app/components/registration/partials/registration-artist.php" }) .state('registration.share', { // each nested state have own view url: "/share", // url nested /registration/share templateurl: "app/components/registration/partials/registration-share.php" }) .state('mechanics', { url: "/mechanics", templateurl: "app/components/mechanics/mechanics.php" }) .state('terms-conditions', { url: "/terms-conditions", templateurl: "app/components/terms/terms-conditions.php" }); // // unmatched url, redirect / $urlrouterprovider.otherwise("/"); });

this registration.php looks like:

<form id="signup-form" ng-submit="processform()"> <!-- our nested state views injected here --> <div id="form-views" ui-view></div> </form>

for reason, 'ui-view' not binding registration-profile.php, should default view 1 time page visited. seems issue here? doing wrong not aware of? learning angularjs, btw.

scotchdesign have supplied plunk of code code based o, http://plnkr.co/edit/m03tygtfqnh09u4x5phc?p=preview

$urlrouterprovider.otherwise('/form/registration');

also, default view 1 set '/', i.e. 'home' state, if want have 'registration' view first either: alter 'home' have url '/home', , have 'stateengine' service phone call $state.go based on criteria, or set 'registration's url '/'.

javascript angularjs

c# - Read XML file with several namespaces -



c# - Read XML file with several namespaces -

i have xml file several namespaces. cant value/ text of nodes.

<?xml version="1.0" encoding="utf-8"?> <!--xml file created microsoft dynamics c5--> <invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:invoice-2" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:commonaggregatecomponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:commonbasiccomponents-2" xmlns:udt="urn:un:unece:uncefact:data:specification:unqualifieddatatypesschemamodule:2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:commonextensioncomponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:qualifieddatatypes-2"> <cbc:ublversionid schemeagencyid="320" schemeagencyname="urn:oioubl:id:profileid-1.1">2.0</cbc:ublversionid> <cbc:customizationid>oioubl-2.02</cbc:customizationid> <cbc:profileid schemeid="urn:oioubl:id:profileid-1.2" schemeagencyid="320">procurement-bilsim-1.0</cbc:profileid> <cbc:id>88481</cbc:id> <cbc:issuedate>2012-05-21</cbc:issuedate> <cbc:invoicetypecode listid="urn:oioubl:codelist:invoicetypecode-1.1" listagencyid="320">380</cbc:invoicetypecode> <cbc:documentcurrencycode>dkk</cbc:documentcurrencycode> <cbc:accountingcost></cbc:accountingcost> <cac:orderreference> <cbc:id>zz</cbc:id> <cbc:salesorderid>36433</cbc:salesorderid> <cbc:issuedate>2012-05-21</cbc:issuedate> </cac:orderreference> </invoice>

i'm trying read of nodes cant. here example.

xmldocument doc = new xmldocument(); doc.load(@"c:\temp\88481.xml"); xmlnamespacemanager manager = new xmlnamespacemanager(doc.nametable); manager.addnamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:commonbasiccomponents-2"); manager.addnamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:commonaggregatecomponents-2"); manager.addnamespace("qdt", "urn:oasis:names:specification:ubl:schema:xsd:qualifieddatatypes-2"); manager.addnamespace("xsd", "http://www.w3.org/2001/xmlschema"); manager.addnamespace("udt", "urn:un:unece:uncefact:data:specification:unqualifieddatatypesschemamodule:2"); manager.addnamespace("ccts", "urn:un:unece:uncefact:documentation:2"); manager.addnamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:commonextensioncomponents-2"); manager.addnamespace("", "urn:oasis:names:specification:ubl:schema:xsd:invoice-2"); xmlnodelist list = doc.selectnodes("//invoice/cbc:id", manager);

but node list have no elements ?

you close first time.

like jon skeet mentioned, "invoice" root element don't need declare new namespace.

xmldocument doc = new xmldocument(); doc.load(@"c:\temp\88481.xml"); xmlnamespacemanager manager = new xmlnamespacemanager(doc.nametable); manager.addnamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:commonbasiccomponents-2"); manager.addnamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:commonaggregatecomponents-2"); manager.addnamespace("qdt", "urn:oasis:names:specification:ubl:schema:xsd:qualifieddatatypes-2"); manager.addnamespace("xsd", "http://www.w3.org/2001/xmlschema"); manager.addnamespace("udt", "urn:un:unece:uncefact:data:specification:unqualifieddatatypesschemamodule:2"); manager.addnamespace("ccts", "urn:un:unece:uncefact:documentation:2"); manager.addnamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:commonextensioncomponents-2"); //manager.addnamespace("", "urn:oasis:names:specification:ubl:schema:xsd:invoice-2"); xmlnodelist list = doc.selectnodes("//cbc:id", manager);

c# xml

sql server - Many-To-Many Cascading Delete Breeze -



sql server - Many-To-Many Cascading Delete Breeze -

i have 4 entities a, b, c, , d.

a has many bs , cs.

b has many ds.

and there many-to-many relationship between c , d.

this many-to-many relationship in bring together table exposed breeze entity cd.

i want found cascading delete deleting first entity in of next rows yields cascading delete.

a -> b -> d -> cd b -> d -> cd d -> cd -> c -> cd c -> cd

all other foreign keys have cascading delete except -> c. every time effort set cascading delete sql server 2012 gives me next error:

unable create relationship 'fk_dbo.c_dbo.a_aid'. introducing foreign key constraint 'fk_dbo.c_dbo.a_aid' on table 'c' may cause cycles or multiple cascade paths. specify on delete no action or on update no action, or modify other foreign key constraints. not create constraint. see previous errors.

how can resolve error , close i'm looking for?

as there multiple cascade paths, sql server complaining on delete cascade option

one path c->cd , c->a->b->d->cd

you can define foreign key out on delete cascade option

you can create insetad of delete trigger on table c , delete corresponding row in table a

sql-server entity-framework database-design ef-code-first breeze

jsf 2 - Redirect 404 error with Prettyfaces 3.3.X and JSF 2.2 -



jsf 2 - Redirect 404 error with Prettyfaces 3.3.X and JSF 2.2 -

i want redirect 404 errors custom url prettyfaces. seek lot of thing can't find right solution case (despite lot of post this)

here informations

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jsf configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.facelets_skip_comments</param-name> <param-value>true</param-value> </context-param> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - prettyfaces configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <context-param> <param-name>com.ocpsoft.pretty.development</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.ocpsoft.pretty.base_packages</param-name> <param-value>com.lagoon.project.web</param-value> </context-param> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - server configuration - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <session-config> <session-timeout>30</session-timeout> </session-config> <welcome-file-list> <welcome-file>/</welcome-file> </welcome-file-list> <error-page> <exception-type>404</exception-type> <location>/page-introuvable</location> </error-page> </web-app>

under web pages\modules\website

<?xml version="1.0" encoding="utf-8"?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>todo supply title</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <div>404</div> </body> </html>

the bean

import com.ocpsoft.pretty.faces.annotation.urlmapping; import javax.enterprise.context.requestscoped; import javax.faces.bean.managedbean; @requestscoped @urlmapping(id = "pagewebsitepagenotfound", pattern = "/page-introuvable", viewid = "/modules/website/pagenotfound.xhtml") @managedbean(name = "pagewebsitepagenotfound") public class pagewebsitepagenotfound { }

and pom file

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.lagoon</groupid> <artifactid>project</artifactid> <version>0.1.0-snapshot</version> <packaging>war</packaging> <name>project</name> <properties> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <java.version>1.7</java.version> <jsf.version>2.2.8-02</jsf.version> <spring.version>4.1.1.release</spring.version> </properties> <dependencies> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - web - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <dependency> <groupid>com.sun.faces</groupid> <artifactid>jsf-api</artifactid> <version>${jsf.version}</version> </dependency> <dependency> <groupid>com.sun.faces</groupid> <artifactid>jsf-impl</artifactid> <version>${jsf.version}</version> </dependency> <dependency> <groupid>com.ocpsoft</groupid> <artifactid>prettyfaces-jsf2</artifactid> <version>3.3.3</version> </dependency> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - misc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <dependency> <groupid>javax</groupid> <artifactid>javaee-web-api</artifactid> <version>7.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <compilerarguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerarguments> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.3</version> <configuration> <failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputdirectory>${endorsed.dir}</outputdirectory> <silent>true</silent> <artifactitems> <artifactitem> <groupid>javax</groupid> <artifactid>javaee-endorsed-api</artifactid> <version>7.0</version> <type>jar</type> </artifactitem> </artifactitems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>

when seek "/page-introuvable" jsf show me page... if seek "/somethingelse" have standard 404 error navigator

how can ?

thanks

in web.xml set block of cody

<error-page> <error-code>404</error-code> <location>/404page.xhtml</location> </error-page>

it intercept 404 error , redirect page page, define page @ <location>/404page.xhtml</location>.

jsf jsf-2 jsf-2.2 prettyfaces

jquery - PrettyPhoto Auto play Slideshow not working -



jquery - PrettyPhoto Auto play Slideshow not working -

i have installed wordpress in local machine , using theme named happy health, there default flex slider came theme, have configured slideshow , want create slideshow auto play without clicking manually

i checked within directory

c:\xampp\htdocs\mainstreetpt\wp-content\themes\happyhealth\script

i saw 10 files jquery , found 2 files flex slider, are

jquery.flexslider.js

jquery.prettyphoto.js

(function($) { $.prettyphoto = {version: '3.1.5'}; $.fn.prettyphoto = function(pp_settings) { pp_settings = jquery.extend({ hook: 'rel', /* attribute tag utilize prettyphoto hooks. default: 'rel'. html5, utilize "data-rel" or similar. */ animation_speed: 'fast', /* fast/slow/normal */ ajaxcallback: function() {}, slideshow: 5000, /* false or interval time in ms */ autoplay_slideshow: false, /* true/false */

this sample code jquery.prettyphoto.js, autoplay here not working

the exact files lies here (click link) jquery.prettyphoto.js , sec file (click link) jquery.flexslider.js can guys help in making tabs autoplay

jquery wordpress flexslider

c# - Socket Error The requested address is not valid in its context -



c# - Socket Error The requested address is not valid in its context -

while trying set socketoption using :

listener.setsocketoption(socketoptionlevel.ip, socketoptionname.addmembership, new multicastoption(ipaddress));

i getting next exception ;

the requested address not valid in context

my listmer is:

socket listener = new socket(addressfamily.internetwork, sockettype.dgram, protocoltype.udp);

and ip 3.212.x.x

is problem because of ip ?

the problem in statement:

listener.setsocketoption(socketoptionlevel.ip, socketoptionname.addmembership, new multicastoption(ipaddress));

msdn outline constructor :

public multicastoption( ipaddress grouping )

so multicastoption looks grouping broadcast had passed localip , problem.

i instead updated code:

ipaddress ip = ipaddress.parse("224.5.6.7"); socket _socketserver = new socket(addressfamily.internetwork, sockettype.dgram, protocoltype.udp); _socketserver.setsocketoption(socketoptionlevel.ip, socketoptionname.addmembership, new multicastoption(ip)); _socketserver.setsocketoption(socketoptionlevel.ip, socketoptionname.multicasttimetolive, 1);

c# sockets multicast

dynamics crm - Generate Paging Cookie for CRM RetrieveMultiple Plugin -



dynamics crm - Generate Paging Cookie for CRM RetrieveMultiple Plugin -

i'm in odd situation, need generate paging cookie crm ordinarily generated crm service (more on why below) can't find it's schema or documentation covering it.

the format i've deduced follows, can confirm it's complete?:

<cookie page="{page no#}"> <{first sort column logical name} first="{value of first returned items sort column - format unknown}" last="{value of lastly returned items sort column - format unknown}" /> </cookie>

my situation i've written retrievemultiple plugin returns pseudo entity exists in external database, since organisation service isn't fetching info cannot rely on crm provide value me.

the paging cookie required iterate on odata queries, though ignored plugin free utilize own logic, i'm beingness cought validation message whenever include skip querystring parameter:

[-2147220715]: paging cookie required retrieve more records. update query retrieve total records below 5000

is there way suppress error message?

i have done investigation paging cookie format, these findings, update these findings time permitting if new features become apparent.

the paging cookie html encoded string, i'd love write proper schema if had time functional design have do:

"cookie" root element "cookie" has single int attribute "page", page no#, counting 1 the kid nodes of "cookie" logical names of order fields, complex types suffixed "name", i.e: "owneridname", "statecodename" these kid nodes have 4 potential attributes 2 present "first"/"last" text/name values sort column of first , lastly result record respectively, i.e: first=&quot;active&quot; last=&quot;inactive&quot; the alternative parameters "firstnull" , "lastnull" "1" if present, replace either "first"/"last" attribute respectively , indicate first value of sort column result set null , vice versa there 1 final kid node of "cookie" named primary key field on queried entity, contains first/last attributes these set guid id of records surrounded in "{}" braces added: if first , lastly values long strings, values trimmed 2000 characters before string encoded added: first , lastly values double html encoded, e.g: line feeds &amp;#xa;

plugins dynamics-crm crm dynamics-crm-2013

java - store data to MongoDB Collection in millisecond -



java - store data to MongoDB Collection in millisecond -

i write application in java store info udp broadcast , store them mongodb. udp sent in millisecond , contain text file separate coma (about 30 fields).

but meet problem follow (problem show in 4-5 minutes run program).

connect success doc inserted connect success doc inserted connect success com.mongodb.mongotimeoutexception: timed out after 10000 ms while waiting server matches anyserverselector{}. client view of cluster state {type=unknown, servers=[{address=127.0.0.1:27017, type=unknown, state=connecting, exception={com.mongodb.mongoexception$network: exception opening socket}, caused {java.net.socketexception: many open files}}] @ com.mongodb.basecluster.getserver(basecluster.java:82) @ com.mongodb.dbtcpconnector.getserver(dbtcpconnector.java:654) @ com.mongodb.dbtcpconnector.access$300(dbtcpconnector.java:39) @ com.mongodb.dbtcpconnector$myport.getconnection(dbtcpconnector.java:503) @ com.mongodb.dbtcpconnector$myport.get(dbtcpconnector.java:451) @ com.mongodb.dbtcpconnector.authenticate(dbtcpconnector.java:624) @ com.mongodb.dbapilayer.doauthenticate(dbapilayer.java:195) @ com.mongodb.db.authenticatecommandhelper(db.java:765) @ com.mongodb.db.authenticate(db.java:721) @ udpgpslistener.main(udpgpslistener.java:108)

and below code in java :

datagramsocket serversocket = new datagramsocket(2020); byte[] receivedata = new byte[2048]; datagrampacket receivepacket = new datagrampacket(receivedata, receivedata.length); serversocket.receive(receivepacket); string dtcollection = new string(receivepacket.getdata(), "utf8"); string[] arrcollection = dtcollection.split(","); string dtfield = "unittime,ab1,ab2,ab3,ab4,ab5,ab6,ab7,cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8,cc9,cc9,cc10,m01,m02,m03,m04,m05,m06,m07"; string[] arrfield = dtfield.split(","); string gbcollection=""; (int m=0; m<arrcollection.length; m++) { gbcollection+=arrfield[m] + "=" +arrcollection[m] +","; } seek { mongoclient mclient = new mongoclient(); //mongoclient mclient = new mongoclient("127.0.0.1", 27017); db db = mclient.getdb("mms"); system.out.println("connect success"); boolean auth = db.authenticate("user1", "passw0rd".tochararray()); dbcollection coll = db.getcollection("tgps"); basicdbobject doc = new basicdbobject(arrfield[0], arrcollection[0]). append(arrfield[1], arrcollection[1]). append(arrfield[2], arrcollection[2]). append(arrfield[3], arrcollection[3]). append(arrfield[4], arrcollection[4]). append(arrfield[5], arrcollection[5]). append(arrfield[6], arrcollection[6]). append(arrfield[7], arrcollection[7]). append(arrfield[8], arrcollection[8]). append(arrfield[9], arrcollection[9]). append(arrfield[10], arrcollection[10]). append(arrfield[11], arrcollection[11]). append(arrfield[12], arrcollection[12]). append(arrfield[13], arrcollection[13]). append(arrfield[14], arrcollection[14]). append(arrfield[15], arrcollection[15]). append(arrfield[16], arrcollection[16]). append(arrfield[17], arrcollection[17]). append(arrfield[18], arrcollection[18]). append(arrfield[19], arrcollection[19]). append(arrfield[20], arrcollection[20]). append(arrfield[21], arrcollection[21]). append(arrfield[22], arrcollection[22]). append(arrfield[23], arrcollection[23]). append(arrfield[24], arrcollection[24]). append(arrfield[25], new date()); coll.insert(doc); system.out.println("doc inserted"); } catch(unknownhostexception e) { system.err.println(e.getclass().getname() + ": " + e.getmessage() ); } catch(mongoexception e) { e.printstacktrace(); }

i assume

udp sent in millisecond

you mean update may occur every millisecond.

anyway encounter problem:

java.net.socketexception: many open files

i assume receive events in kind of loop.

in case, may problem:

mongoclient mclient = new mongoclient();

you should init mongoclient 1 time before start listening events, otherwise connection opened , never closed every event consume.

this should go obtaining db, authenticating , getting collection. i.e

mongoclient mclient = new mongoclient(); //mongoclient mclient = new mongoclient("127.0.0.1", 27017); db db = mclient.getdb("mms"); system.out.println("connect success"); boolean auth = db.authenticate("user1", "passw0rd".tochararray()); dbcollection coll = db.getcollection("tgps");

all these should happen once before start receiving events.

java mongodb nosql

android - ItemClick not bound on Button in MvxGridView -



android - ItemClick not bound on Button in MvxGridView -

i have problem binding click event on item of mvxgridview (i'm using itemclick binding).

all rendering fine , stuff. when utilize textview goclick method fired properly. when alter textview button in itemtemplateview, goclick method not invoked more.

according this reply (option number 1) should work fine. in button case not.

any help appreciated, i'm stuck here.

my viewmodel:

public class myviewmodel : mvxviewmodel { private ienumerable<mylistitem> items; public myviewmodel() { this.items = new list<mylistitem> { new mylistitem {name = "item1"}, new mylistitem {name = "item2"}, }; } public ienumerable<mylistitem> items { { homecoming this.items; } } public icommand selectitem { { homecoming new mvxcommand<mylistitem>(this.goclick);} } public void goclick(mylistitem item) { //dosomething } }

my layout mvxgridview:

<?xml version="1.0" encoding="utf-8" ?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@color/black" > <mvx.mvxgridview android:layout_width="300dp" android:layout_height="match_parent" android:gravity="center" android:horizontalspacing="10dp" android:numcolumns="3" android:stretchmode="columnwidth" android:verticalspacing="10dp" local:mvxitemtemplate="@layout/itemtemplateview" local:mvxbind="itemssource items; itemclick selectitem" /> </linearlayout>

my itemtemplateview (which works fine textview)

<?xml version="1.0" encoding="utf-8" ?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" > <textview android:layout_height="wrap_content" android:layout_width="match_parent" local:mvxbind="text name" /> <!-- click on button not work --> <!-- <button android:layout_height="wrap_content" android:layout_width="match_parent" local:mvxbind="text name" /> --> </linearlayout>

android xamarin mvvmcross

ruby - add superior statment in activerecord hash condition -



ruby - add superior statment in activerecord hash condition -

i have hash witch contains many conditions want add together status wich utilize superior statment how can exmple

// conditions hash of conditions conditions[:id]="> 100" personels=personel.find(:all, :conditions=>conditions)

usually (not sure if understood goal) store multiple conditions in array add together more conditions using arrays << append operator, like:

conditions array: conditions = [] conditions << "id > '100'" conditions << "name '%#{params[:name]}%'" # # ... more conditions here # conditions = conditions.join(' , ') personel.where(conditions) conditions hash: conditions = {} conditions[:id] = "> '100'" conditions[:name] = "like '%#{params[:name]}%'" # # ... more conditions here # conditions = conditions.map{|k,v| "#{k} #{v}"}.join(' , ') personel.where(conditions)

ruby activerecord

sql - ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: integer ~~ unknown -



sql - ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: integer ~~ unknown -

i switched mysql postgresql utilize in heroku. search not work. can't figure out wrong operator. actionview::template::error (pg::undefinedfunction: error: operator not exist: integer ~~ unknown.

2014-11-11t19:59:58.082607+00:00 app[web.1]: processing alllistingscontroller#search_listings js 2014-11-11t19:59:58.105074+00:00 app[web.1]: 4: <% @listings.each |listing| %> 2014-11-11t19:59:58.102205+00:00 app[web.1]: ^ 2014-11-11t19:59:58.105066+00:00 app[web.1]: hint: no operator matches given name , argument type(s). might need add together explicit type casts. 2014-11-11t19:59:58.105083+00:00 app[web.1]: app/controllers/all_listings_controller.rb:14:in `search_listings' 2014-11-11t19:59:58.110318+00:00 heroku[router]: at=info method=get path="/search_listings?q=500&_=1415735994648" host=subleasy.herokuapp.com request_id=24a21078-d3fd-4bce-9afb-bfc9d976c0a7 fwd="50.247.32.153" dyno=web.1 connect=1ms service=35ms status=500 bytes=1754 2014-11-11t19:59:58.103449+00:00 app[web.1]: completed 500 internal server error in 21ms 2014-11-11t19:59:58.102207+00:00 app[web.1]: hint: no operator matches given name , argument type(s). might need add together explicit type casts. 2014-11-11t19:59:58.105076+00:00 app[web.1]: 5: $("div.search_list").append("<%= escape_javascript(render('all_listings/listings_partial', a_listing: listing )) %>") 2014-11-11t19:59:58.105073+00:00 app[web.1]: 3: 2014-11-11t19:59:58.103270+00:00 app[web.1]: rendered all_listings/search_listings.js.erb (5.1ms) 2014-11-11t19:59:58.105071+00:00 app[web.1]: 2: $("div.search_list").html("") 2014-11-11t19:59:58.105081+00:00 app[web.1]: app/views/all_listings/search_listings.js.erb:4:in `_app_views_all_listings_search_listings_js_erb___729824412217144086_70218143810320' 2014-11-11t19:59:58.102209+00:00 app[web.1]: : select "listings".* "listings" (rent '%500%' or city '%500%' or state '%500%' or address '%500%') order rent asc limit 5 offset 0 2014-11-11t19:59:58.105078+00:00 app[web.1]: 6: <% end %> 2014-11-11t19:59:58.102199+00:00 app[web.1]: pg::undefinedfunction: error: operator not exist: integer ~~ unknown 2014-11-11t19:59:58.105068+00:00 app[web.1]: : select "listings".* "listings" (rent '%500%' or city '%500%' or state '%500%' or address '%500%') order rent asc limit 5 offset 0): 2014-11-11t19:59:58.105084+00:00 app[web.1]: 2014-11-11t19:59:58.082630+00:00 app[web.1]: parameters: {"q"=>"500", "_"=>"1415735994648"} 2014-11-11t19:59:58.105058+00:00 app[web.1]: 2014-11-11t19:59:58.105061+00:00 app[web.1]: actionview::template::error (pg::undefinedfunction: error: operator not exist: integer ~~ unknown 2014-11-11t19:59:58.105063+00:00 app[web.1]: line 1: select "listings".* "listings" (rent '%500... 2014-11-11t19:59:58.105065+00:00 app[web.1]: ^ 2014-11-11t19:59:58.077155+00:00 app[web.1]: started "/search_listings?q=500&_=1415735994648" 50.247.32.153 @ 2014-11-11 19:59:58 +0000 2014-11-11t19:59:58.102203+00:00 app[web.1]: line 1: select "listings".* "listings" (rent '%500... 2014-11-11t19:59:58.105070+00:00 app[web.1]: 1: 2014-11-11t19:59:58.105085+00:00 app[web.1]: 2014-11-11t19:59:58.105079+00:00 app[web.1]: 7: $(".hidetable").hide()

my method

def search_listings @listings = listing.where("rent ? or city ? or state ? or address ?", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%").order(sort_column + " " + sort_direction).paginate(:per_page => 5, :page => params[:page]) respond_to |format| format.js end end def sort_column listing.column_names.include?(params[:sort]) ? params[:sort] : "rent" end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" end

schema.rb

create_table "listings", force: true |t| t.integer "user_id" t.string "address" t.string "city" t.string "state" t.date "lease_start" t.string "lease_length" t.string "lease_type" t.integer "rooms" t.text "description" t.string "email" t.string "phone" t.integer "rent" t.integer "zipcode" t.datetime "created_at" t.datetime "updated_at" t.string "photo_file_name" t.string "photo_content_type" t.integer "photo_file_size" t.datetime "photo_updated_at" t.float "latitude", limit: 24 t.float "longitude", limit: 24 end

why won't work in postgresql when works flawlessly in mysql???

it seems trying utilize like operator on integer column (namely rent). don't believe work (at to the lowest degree in postgres).

according answers here might want seek add together cast:

@listings = listing.where("cast(rent text) ? or city ? or state ? or address ?", ...

sql ruby-on-rails ruby postgresql heroku

cloud - How to work around rate limits? -



cloud - How to work around rate limits? -

i've been attempting utilize git annex onedrive api , unfortunately i've been rate limited numerous times when pushing files.

the microsoft team has been rather opaque these limits i'm wondering:

whether traditional methods exponential falloff way work around issue? whether limits low interacting api upload big amounts of info worth @ all?

on latter question, give hard number, i've started receiving rate limits @ ~1000 requests , 6gib of info uploaded in hour. these numbers seem low me.

there workaround utilize bits endpoint onedrive, allows big files uploaded onedrive. way around upload limit encountering livesdks.

this documentation available on msdn shortly, until then, here doc describing how create these kinds of requests: https://gist.github.com/rgregg/37ba8929768a62131e85

cloud onedrive onedrive-api

xml - .Net (C#) cannot deserialize Java web service response -



xml - .Net (C#) cannot deserialize Java web service response -

i consuming java based web service .net application. problem arise, when got deserialized response web service, of fields in response comes null values, if @ xml response, response has proper values. guess main problem .net cannot deserialize response properly. here wsdl, method using "getforeignenterpriselist".

xml response is

<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" /> <s:body> <ns6:getforeignenterpriselistresponse xmlns="http://api.vetrf.ru/schema/base" xmlns:ns2="http://api.vetrf.ru/schema/argus" xmlns:ns3="http://api.vetrf.ru/schema/institutions" xmlns:ns4="http://api.vetrf.ru/schema/ikar" xmlns:ns5="http://api.vetrf.ru/schema/base/register" xmlns:ns6="http://api.vetrf.ru/schema/argus/enterprise/ws-definitions" xmlns:ns7="http://api.vetrf.ru/schema/argus/ws-definitions"> <ns2:enterpriselist offset="0" total="14058" count="1"> <ns2:enterprise> <uuid>06e4a78e-053d-11e1-99b4-d8d385fbc9e8</uuid> <guid>cb1483ab-2c7d-db46-445c-09849ae9b761</guid> <active>true</active> <last>true</last> <status>100</status> <createdate>2009-10-08t12:50:47+04:00</createdate> <updatedate>2009-10-08t12:50:47+04:00</updatedate> <ns2:name>cargill meat solutions corporation</ns2:name> <ns2:englishname> </ns2:englishname> <ns2:activity>Убой КРС, разделка, хранение говядины</ns2:activity> <ns2:englishactivity>cattle slaughter, beef cutting, beef storage</ns2:englishactivity> <ns4:address> <ns4:addressview>friona</ns4:addressview> <ns4:enaddressview> </ns4:enaddressview> </ns4:address> <ns4:country> <uuid>91134526-4373-ec59-4a1e-e0e99bd50b7b</uuid> <guid>cac8a802-3c65-397d-895d-c0495bf6ea61</guid> </ns4:country> <ns4:region> <uuid>c7bad316-6564-787c-c502-6a9e8afdc093</uuid> <guid>bbee471c-0548-7190-cca9-5897eedbeac3</guid> <ns4:hasstreets>false</ns4:hasstreets> </ns4:region> <ns2:numberlist> <ns2:enterprisenumber>86 Е</ns2:enterprisenumber> </ns2:numberlist> </ns2:enterprise> </ns2:enterpriselist> </ns6:getforeignenterpriselistresponse> </s:body> </s:envelope>

this .net generated class enterprise node need get.

class="snippet-code-html lang-html prettyprint-override">[system.codedom.compiler.generatedcodeattribute("system.xml", "4.0.30319.18408")] [system.serializableattribute()] [system.diagnostics.debuggerstepthroughattribute()] [system.componentmodel.designercategoryattribute("code")] [system.xml.serialization.xmltypeattribute(namespace="http://api.vetrf.ru/schema/argus")] public partial class enterprise : genericversioningentity { private string namefield; private string englishnamefield; private string activityfield; private string englishactivityfield; private address addressfield; private country countryfield; private part regionfield; private district districtfield; private string[] numberlistfield; private string typefield; /// <remarks/> [system.xml.serialization.xmlelementattribute(order=0)] public string name { { homecoming this.namefield; } set { this.namefield = value; this.raisepropertychanged("name"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=1)] public string englishname { { homecoming this.englishnamefield; } set { this.englishnamefield = value; this.raisepropertychanged("englishname"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=2)] public string activity { { homecoming this.activityfield; } set { this.activityfield = value; this.raisepropertychanged("activity"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=3)] public string englishactivity { { homecoming this.englishactivityfield; } set { this.englishactivityfield = value; this.raisepropertychanged("englishactivity"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=4)] public address address { { homecoming this.addressfield; } set { this.addressfield = value; this.raisepropertychanged("address"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=5)] public country country { { homecoming this.countryfield; } set { this.countryfield = value; this.raisepropertychanged("country"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=6)] public part region { { homecoming this.regionfield; } set { this.regionfield = value; this.raisepropertychanged("region"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=7)] public district district { { homecoming this.districtfield; } set { this.districtfield = value; this.raisepropertychanged("district"); } } /// <remarks/> [system.xml.serialization.xmlarrayattribute(order=8)] [system.xml.serialization.xmlarrayitemattribute("enterprisenumber", isnullable=false)] public string[] numberlist { { homecoming this.numberlistfield; } set { this.numberlistfield = value; this.raisepropertychanged("numberlist"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(datatype="integer", order=9)] public string type { { homecoming this.typefield; } set { this.typefield = value; this.raisepropertychanged("type"); } } }

.net cannot deserialize "address", "country", "region", "numberlist" nodes.

and illustration of how .net generated class country node comes null.

class="snippet-code-html lang-html prettyprint-override">[system.codedom.compiler.generatedcodeattribute("system.xml", "4.0.30319.18408")] [system.serializableattribute()] [system.diagnostics.debuggerstepthroughattribute()] [system.componentmodel.designercategoryattribute("code")] [system.xml.serialization.xmltypeattribute(namespace="http://api.vetrf.ru/schema/ikar")] public partial class country : genericversioningentity { private string namefield; private string fullnamefield; private string englishnamefield; private string codefield; private string code3field; private bool isrussiafield; private bool isrussiafieldspecified; private bool iscustomsunionfield; private bool iscustomsunionfieldspecified; /// <remarks/> [system.xml.serialization.xmlelementattribute(order=0)] public string name { { homecoming this.namefield; } set { this.namefield = value; this.raisepropertychanged("name"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=1)] public string fullname { { homecoming this.fullnamefield; } set { this.fullnamefield = value; this.raisepropertychanged("fullname"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=2)] public string englishname { { homecoming this.englishnamefield; } set { this.englishnamefield = value; this.raisepropertychanged("englishname"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=3)] public string code { { homecoming this.codefield; } set { this.codefield = value; this.raisepropertychanged("code"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=4)] public string code3 { { homecoming this.code3field; } set { this.code3field = value; this.raisepropertychanged("code3"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=5)] public bool isrussia { { homecoming this.isrussiafield; } set { this.isrussiafield = value; this.raisepropertychanged("isrussia"); } } /// <remarks/> [system.xml.serialization.xmlignoreattribute()] public bool isrussiaspecified { { homecoming this.isrussiafieldspecified; } set { this.isrussiafieldspecified = value; this.raisepropertychanged("isrussiaspecified"); } } /// <remarks/> [system.xml.serialization.xmlelementattribute(order=6)] public bool iscustomsunion { { homecoming this.iscustomsunionfield; } set { this.iscustomsunionfield = value; this.raisepropertychanged("iscustomsunion"); } } /// <remarks/> [system.xml.serialization.xmlignoreattribute()] public bool iscustomsunionspecified { { homecoming this.iscustomsunionfieldspecified; } set { this.iscustomsunionfieldspecified = value; this.raisepropertychanged("iscustomsunionspecified"); } } }

any ideas?

its because of xml namespaces, of ns2: , ns4: etc.

you strip these out of message text including namespace declarations, hacky quick. or including names spaces in object this

xmlroot(namespace = "http://api.vetrf.ru/schema/")] public class enterprise { [xmlelement(namespace = "http://api.vetrf.ru/schema/ikar")] public address address{ get; set; } [xmlelement(namespace = "http://api.vetrf.ru/schema/ikar")] public country country { get; set; } ... } xmlroot(namespace = "http://api.vetrf.ru/schema/ikar")] public class address { .... }

havent tried guess, luck!

c# xml web-services wsdl

cascading deletes - EclipseLink Remove Cascade -



cascading deletes - EclipseLink Remove Cascade -

i have been developing web application running on glassfish server. utilize jpa eclipselink implementation.

these 2 entity classes. represent relation between them below. when start glassfish server , delete lesson entity, cascade works. deletes of test entities of it. add together lesson entity , test entity related it. when seek delete lesson entity, @ time cascade not work , throws "foreign key constraint" error. after server restarting, cascade 1 time again works. ??? difference? why cascade operation work @ startup?

thank you.

@entity public class lesson implements serializable { ... @onetomany( fetch = fetchtype.lazy, cascade = { cascadetype.merge, cascadetype.remove }, mappedby = "lesson" ) private list< test > tests; ... } @entity public class test implements serializable { ... @manytoone( targetentity = lesson.class, fetch = fetchtype.lazy ) @joincolumn( name = "lessonno", insertable = true, updatable = true, nullable = false ) private lesson lesson; ... }

eclipselink cascading-deletes jpa-2.1

Adding and accessing values to key in python dictionary -



Adding and accessing values to key in python dictionary -

i'm writing python script reads players name , stats sentence in .txt file, updates stats within dictionary , prints out average stats. i'm having problem assigning multiple values same 'player' key, getting logic below correctly update player stats. .group part giving me problem too. how can this?

import re, sys, os, math if len(sys.argv) < 2: sys.exit("usage: %s filename" % sys.argv[0]) filename = sys.argv[1] if not os.path.exists(filename): sys.exit("error: file '%s' not found" % sys.argv[1]) line_regex = re.compile(r"^(\w+ \w+) batted (\d+) times (\d+) hits , (\d+) runs") line = [line.strip() line in open(filename)] f = open (filename) playerstats = {'players': [0, 0, 0]} players in playerstats: player = line.group(1) atbat = line.group(2) nail = line.group(3) if player in playerstats: playerstats[player][0] += atbat playerstats[player][1] += nail if player not in players: player = line.group(1) playerstats[player][0] = atbat playerstats[player][1] = nail avgs = 0 else: playerstats[player][0] = player playerstats[player][0] = atbat playerstats[player][1] = nail playerstats[player][2] = 0 player in players: avgs[player] = round(float(hits[player])/float(atbats[player]), 3) print "%s: %.3f" % (player, avgs[player])

traceback (most recent phone call last): file "ba.py", line 19, in player = line.group(1) attributeerror: 'list' object has no attribute 'group'

you should alter this

playerstats = {'players': hits, atbats, avgs}

to

playerstats = {'players': [0, 0, 0]}

the latter stores value list , former not valid python syntax.

to modify 1 of these values do, example

playerstats[player][1] = 5 # atbat value

you alter nested construction like

playerstats = {'players': {'hits' : 0, 'atbats' : 0, 'avgs' : 0)}

then modify values as

playerstats[player]['hits'] = 3

python dictionary

java - How to safely remove the commas on an ArrayList? -



java - How to safely remove the commas on an ArrayList? -

i have arraylist place float values.

xevent.add(filetimestamp); xevent.add(x); xevent.add(zcsv + "\n"); string formatedstring = xevent.tostring() .replace("[", "") // remove right bracket .replace("]", "") // remove left bracket

the problem arraylist places comma separate values. how can rid of comma without getting rid of comma in locales used decimal mark? on u.s. utilize period decimal mark, removing commas work, on countries utilize comma decimal mark end ruining data.

i'm not sure can errase ',' string without ruining data, recomend using for() info

string formatedstring=""; for(string s: xevent){ formatedstring += s; }

like info within string without ']','[' or ','. hope helps you.

java android regex

loops - Java switch not working -



loops - Java switch not working -

im having problem getting switch working. uncompilable source code date.java:75. also, when programme returns results - homecoming month name dd, yyyy along have doing mm/dd/yyyy. if point me in right direction, i'd appreciate it.

import java.util.calendar; import java.util.gregoriancalendar; import java.util.scanner; public class date { private gregoriancalendar date = null; private string[] months = new string[]{ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" }; public date(int month, int day, int year) { date = new gregoriancalendar(year, month-1, day); } public date(string month, int day, int year) { date = new gregoriancalendar(year, this.getmonth(month), day); } public date(int dayofyear, int year) { date = new gregoriancalendar(); date.set(calendar.day_of_year, dayofyear); date.set(calendar.year, year); } private int getmonth(string month) { (int i=0; i<months.length; ++i) if (month.tolowercase().equals(months)) //equals(months)) homecoming i; homecoming 0; } public string tostring() { homecoming date.get(calendar.month)+1 + "-" + date.get(calendar.date) + "-" + date.get(calendar.year); } public static void main(string[] args) { int mo; int dy; int yr; string moo; // month name string boolean wronginput = false; { scanner input = new scanner( system.in ); // scanner read input wronginput = false; int menu = input.nextint(); // menu selection system.out.printf( "enter 1 format: mm/dd/yyyy \n"); system.out.printf( "enter 2 format: month dd,yyyy \n"); system.out.printf( "enter 3 exit \n"); system.out.printf( "choice:"); switch(menu) { case '1' : // mm/dd/yyyy ui system.out.printf( "enter month (1-12): "); mo = input.nextint(); system.out.printf( "enter day of month: "); dy = input.nextint(); system.out.printf( "enter year: "); yr = input.nextint(); date = new date(mo, dy, yr); //chew system.out.println(a); //spit break; case '2' : // month dd,yyyy ui system.out.printf( "enter month name: "); moo = input.next(); system.out.printf( "enter day of month: "); dy = input.nextint(); system.out.printf( "enter year: "); yr = input.nextint(); date b = new date(moo, dy, yr); //chew system.out.println(b); //spit break; case '3' : // eop system.exit(0); break; default: system.out.println("invalid selection."); wronginput = true; break; } while(wronginput); }

you passing integer , checking character. 1 int while '1' character in java.

in code menu int not char cases should case 1: , not case '1':

so alter switch

switch(menu){ case 1: //your code break; case 2: //your code break; //..and on }

right ascii values of characters '1','2'.. compared int value passed menu not going equal ascii value of char '1' 81 while 82 '2' totally useless in scenario.

java loops switch-statement

node.js - How to make a form-data request with koa? -



node.js - How to make a form-data request with koa? -

i trying replicate login form's behaviour through koa.

the login form does:

<form id="loginform" method="post" action="http://myaddress:3000/auth" enctype="multipart/form-data">

i'm using koa request , form-data modules:

var form = new formdata(); form.append('identification', 'userid'); form.append('password', 'userpassword'); var options = { url: db_server_url + 'auth', method: 'post', formdata: form }; var response = yield request(options); console.log('response.statuscode: ' + response.statuscode);

but 400 response.

i've tried using form.submit(db_server_url + 'auth', function(err, res) { ... } works, koa's yield functionality , ideally want avoid having deal callbacks.

any ideas?

koa accepts multiple yield inputs can obtained current code more or less depending on current setup:

a promise. form-data doesn't seem utilize them, we'll create 1 q

var q = require('q'); var promise = q.ninvoke(form, "submit", db_server_url + 'auth'); var response = yield promise; console.log('response.statuscode: ' + response.statuscode);

or thunk, wrapper function used in answer, there libraries can handle wrapping (here, thunkify-wrap):

var thunkify = require('thunkify-wrap'); var submit = thunkify(form.submit, form); // context needed in case var response = yield submit(db_server_url + 'auth'); console.log('response.statuscode: ' + response.statuscode);

node.js multipartform-data koa

javascript - Combine js & css: how to deal with relative paths? -



javascript - Combine js & css: how to deal with relative paths? -

i have php system, view objects can inlcude css , js files via core function. scheme combines included js , css files min.css , min.js , site utilize two. problem is, files contains relative paths , minified ones @ location, have bunch of broken links. can write absolute paths, when load 3rd party library, problem occur (and don't want overwrite them obviously). don't utilize method libs, wonder there solution kind of problem?

maybe should this:

<script> var base_url = <?=get_base_url();?> </script> <script type="text/css" src="js/compressed.js"></script>

and in compressed.js, utilize absolute path's this:

(for example, ajax call):

$.get( base_url + 'path/file' , function(data){});

the thing solution have refactor code..

javascript css relative-path

sql - Loop and assign non-unique GUID to sets of values? -



sql - Loop and assign non-unique GUID to sets of values? -

i'm sure in easy one, can't go past conceptualization syntax: have table of features 1 named feature may populate several rows e.g:

[name], [guid] fred, null fred, null fred, null tom, null mary, null mary, null mary, null mary, null

what i'd assign 1 guid per name:

fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} fred, {3b26af27-9d42-481c-a8c8-be1819dccda5} tom, {ee64b706-def0-4e5c-a5fd-0c219962042e} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401} mary, {fd158f90-9705-4a18-b82c-baca29441401}

declare @tmp table ( name varchar(30), guid uniqueidentifier ) insert @tmp select x.name, newid() (select distinct name mytable) x update mytable set guid = tmp.guid mytable t inner bring together @tmp tmp on t.name = tmp.name

sql sql-server sql-server-2008 guid

html - Sort DIV randomly or by title -



html - Sort DIV randomly or by title -

i have grid, containing boxes images , text below:

<div id="grid"> <!-- -------------------------- box markup -------------------------- --> <div class="box" data-category="beerary"> <div class="box-image"> <div data-thumbnail=".." ></div> </div> <div class="box-caption"> <div class="box-title">title 1</div> <div class="box-text"> random text... </div> </div> </div> <!-- -------------------------- box markup -------------------------- --> <div class="box" data-category="restaurant"> <div class="box-image"> <div data-thumbnail=".." ></div> </div> <div class="box-caption"> <div class="box-title">title 2</div> <div class="box-text"> random text... </div> </div> </div>

and want create button in order sort boxes randomly or via box-title. tried using tinysort saw here didnt work.

may have help?

edit: below tried http://jsfiddle.net/vbql2m82/ think somehow have flag box-title in order sort them.

html

html - Form To Upload Multiple Images & Data To MySQL DB Via PHP -



html - Form To Upload Multiple Images & Data To MySQL DB Via PHP -

we developing application internal utilize upload 2 images , text boxes mysql database via form , php script.

we can simple form work text boxes submitted no image fields, , can form image fields work , upload images mysql database blob, when combining 2 can upload images, , not text boxes.

please find below code our php upload script, when our form submitted uploads database 2 image fields blob, not other text fields, help point out have gone wrong appreciated:

<?php $con=mysqli_connect("localhost","username","password","outofhours"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $maxsize = 10000000; //set approx 10 mb $sitename = mysqli_real_escape_string($con, $_post['sitename']); $siteaddress = mysqli_real_escape_string($con, $_post['siteaddress']); $sitepostcode = mysqli_real_escape_string($con, $_post['sitepostcode']); $eqmake = mysqli_real_escape_string($con, $_post['eqmake']); $eqmodel = mysqli_real_escape_string($con, $_post['eqmodel']); $eqdesc = mysqli_real_escape_string($con, $_post['eqdesc']); $eqserial = mysqli_real_escape_string($con, $_post['eqserial']); $eqassetno = mysqli_real_escape_string($con, $_post['eqassetno']); $eqconttype = mysqli_real_escape_string($con, $_post['eqconttype']); $brewery = mysqli_real_escape_string($con, $_post['brewery']); $date = mysqli_real_escape_string($con, $_post['date']); $onsitetime = mysqli_real_escape_string($con, $_post['onsitetime']); $offsitetime = mysqli_real_escape_string($con, $_post['offsitetime']); $custprintname = mysqli_real_escape_string($con, $_post['custprintname']); $custposition = mysqli_real_escape_string($con, $_post['custposition']); $engname = mysqli_real_escape_string($con, $_post['engname']); // check if file submitted if(!isset($_files['engsig1'])) { echo '<p>please select file</p>'; } else { seek { $msg= upload(); //this upload image echo $msg; //message showing success or failure. } catch(exception $e) { echo $e->getmessage(); echo 'sorry, not upload file'; } } // upload function function upload() { include "file_constants.php"; $maxsize = 10000000; //set approx 10 mb //check associated error code if($_files['engsig1']['error']==upload_err_ok) { //check whether file uploaded http post if(is_uploaded_file($_files['engsig1']['tmp_name'])) { //checks size of uploaded image on server side if( $_files['engsig1']['size'] < $maxsize) { //checks whether uploaded file of image type $finfo = finfo_open(fileinfo_mime_type); if(strpos(finfo_file($finfo, $_files['engsig1']['tmp_name']),"image")===0) { // prepare image insertion $imgdata1 =addslashes (file_get_contents($_files['engsig1']['tmp_name'])); $imgdata2 =addslashes (file_get_contents($_files['custsig1']['tmp_name'])); // set image in db... // database connection mysql_connect($host, $user, $pass) or die (mysql_error()); // select db mysql_select_db ($db) or die ("unable select db".mysql_error()); // our sql query $sql = "insert oohours (sitename, siteaddress, sitepostcode, eqmake, eqmodel, eqdesc, eqserial, eqassetno, eqconttype, brewery, date, onsitetime, offsitetime, custprintname, custsig1, custposition, engname, engsig1) values ('$sitename', '$siteaddress', '$sitepostcode', '$eqmake', '$eqmodel', '$eqdesc', '$eqserial', '$eqassetno', '$eqconttype', '$brewery', '$date', '$onsitetime', '$offsitetime', '$custprintname', '{$imgdata1}', '$custposition', '$engname', '{$imgdata2}')"; // insert image mysql_query($sql) or die("error in query: " . mysql_error()); $msg='<p>image saved in database id ='. mysql_insert_id().' </p>'; } else $msg="<p>uploaded file not image.</p>"; } else { // if file not less maximum allowed, print error $msg='<div>file exceeds maximum file limit</div> <div>maximum file limit '.$maxsize.' bytes</div> <div>file '.$_files['engsig1']['name'].' '.$_files['engsig1']['size']. ' bytes</div><hr />'; } } else $msg="file not uploaded successfully."; } else { $msg= file_upload_error_message($_files['engsig1']['error']); } homecoming $msg; } // function homecoming error message based on error code function file_upload_error_message($error_code) { switch ($error_code) { case upload_err_ini_size: homecoming 'the uploaded file exceeds upload_max_filesize directive in php.ini'; case upload_err_form_size: homecoming 'the uploaded file exceeds max_file_size directive specified in html form'; case upload_err_partial: homecoming 'the uploaded file partially uploaded'; case upload_err_no_file: homecoming 'no file uploaded'; case upload_err_no_tmp_dir: homecoming 'missing temporary folder'; case upload_err_cant_write: homecoming 'failed write file disk'; case upload_err_extension: homecoming 'file upload stopped extension'; default: homecoming 'unknown upload error'; } } ?>

you error lies in fact using mysql , mysqli functions through each other. doesnt work. either go mysqli or got mysql .. go mysqli.

i mean, check yourself. sanitize them mysqli, within upload function connect database, utilize mysql function.

// set image in db... // database connection mysql_connect($host, $user, $pass) or die (mysql_error()); // select db mysql_select_db ($db) or die ("unable select db".mysql_error()); // our sql query $sql = "insert oohours (sitename, siteaddress, sitepostcode, eqmake, eqmodel, eqdesc, eqserial, eqassetno, eqconttype, brewery, date, onsitetime, offsitetime, custprintname, custsig1, custposition, engname, engsig1) values ('$sitename', '$siteaddress', '$sitepostcode', '$eqmake', '$eqmodel', '$eqdesc', '$eqserial', '$eqassetno', '$eqconttype', '$brewery', '$date', '$onsitetime', '$offsitetime', '$custprintname', '{$imgdata1}', '$custposition', '$engname', '{$imgdata2}')"; // insert image mysql_query($sql) or die("error in query: " . mysql_error()); $msg='<p>image saved in database id ='. mysql_insert_id().' </p>';

is mysql function, while utilize rest mysqli

<?php $con=mysqli_connect("localhost","username","password","outofhours"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $maxsize = 10000000; //set approx 10 mb $sitename = mysqli_real_escape_string($con, $_post['sitename']); $siteaddress = mysqli_real_escape_string($con, $_post['siteaddress']); $sitepostcode = mysqli_real_escape_string($con, $_post['sitepostcode']); $eqmake = mysqli_real_escape_string($con, $_post['eqmake']); $eqmodel = mysqli_real_escape_string($con, $_post['eqmodel']); $eqdesc = mysqli_real_escape_string($con, $_post['eqdesc']); $eqserial = mysqli_real_escape_string($con, $_post['eqserial']); $eqassetno = mysqli_real_escape_string($con, $_post['eqassetno']); $eqconttype = mysqli_real_escape_string($con, $_post['eqconttype']); $brewery = mysqli_real_escape_string($con, $_post['brewery']); $date = mysqli_real_escape_string($con, $_post['date']); $onsitetime = mysqli_real_escape_string($con, $_post['onsitetime']); $offsitetime = mysqli_real_escape_string($con, $_post['offsitetime']); $custprintname = mysqli_real_escape_string($con, $_post['custprintname']); $custposition = mysqli_real_escape_string($con, $_post['custposition']); $engname = mysqli_real_escape_string($con, $_post['engname']);

so @ point, have established connection mysql in function, text in mysqli sanitized, has no clue it. simple said bove, chose 1 or other ;)

php html mysql database image

java - When I try to return the index values of an item in a multidimensional array, I do not get numbers. I get a weird set of characters. Why? -



java - When I try to return the index values of an item in a multidimensional array, I do not get numbers. I get a weird set of characters. Why? -

i have code below supposed homecoming index values of item in multidimensional array. however, when run it, gives me instead:

found at: [i@7ea987ac public static string findword(char[][]board, string word) { (int row = 0; row < board.length; row++) { (int col = 0; col < board[row].length; col++) { if (board[row][col] == word.charat(0)) { homecoming "found at: " + new int[] {row,col}; } } } homecoming "not found."; }

what wrong code not giving me right index values?

you're getting default tostring() array, alter this

return "found at: " + new int[] {row,col};

to utilize arrays.tostring(int[]) like

return "found at: " + arrays.tostring(new int[] {row,col});

java multidimensional-array indexing return

html - Center parent div with dynamic and set width child divs -



html - Center parent div with dynamic and set width child divs -

this contains both logo , navigation bar within main parent div.

the logo has set width , navigation bar has dynamic width. navigation bar 100px right of logo.

at moment perfect except @ left of screen. identical in every aspect, except @ center of screen.

i've looked , tried different methods found on-line, seem mess layout. ideas? in advance.

html

<div id="allhead"> <div id="logo"></div> <div id="navigation"></div> </div>

css

#allhead { position: relative; } #logo { width : 100px; height : 80px; background-color: green; } #navigation { position: absolute; max-width: 600px; left: 100px; top: 10px; right: 0px; height : 60px; background-color: orange; }

centering div of unknown width

when div widths variable, centering technique below works well. uses outer , inner wrapper.

the outer wrapper div set text-align:center.

the inner wrapper inline-block, , responds text-align:center outer wrapper. uses text-align:left overwrite text center first wrapper.

the logo , menu floated next each other.

this technique centering when widths can variable.

in illustration nav wrap under logo on smaller screen sizes. beneficial on smaller screens.

jsfiddle example

#allhead { text-align:center; } .center-inner { text-align:left; display:inline-block; } #logo { width : 100px; height : 80px; background-color: green; float:left; } #navigation { max-width: 600px; background-color: orange; float:left; }

here layout maintain logo , nav using css table displays. since of import main menu, divs added css table , table row browser stability.

jsfiddle

#allhead { text-align:center; } .center-inner { text-align:left; display:inline-block; } .nav-bar-table { display:table; } .nav-bar-table-row { display:table-row; } #logo { width : 100px; height : 80px; background-color: green; display:table-cell; } #navigation { max-width: 600px; background-color: orange; display:table-cell; padding:.5em; }

and lastly, here's jsfiddle experiment using absolute positioning similar original example, padding controlling centering. won't post code because absolute center close hard achieve, , top examples better.

html css dynamic width center