Posts

Showing posts from May, 2013

asp.net mvc - MVC Viewmodel cant access model with View -

how can access viewmodel view? code follows:-, i have 2 models (using entity framework) have view model of:- public class viewmodelstory { public ienumerable<tbl_gcb_newsitem> gcb_newsitem { get; set; } public ienumerable<tbl_gcb_itemcomment> comemnts { get; set; } } my contoller populates models by:- viewmodelstory.gcb_newsitem = (from in db.tbl_gcb_newsitem i.intitemidentifier.tostring() == storyid select i).singleordefault(); viewmodelstory.comemnts = (from in db.tbl_gcb_itemcomment i.intitemidentifier.tostring() == storyid select i).tolist<tbl_gcb_itemcomment>(); i return model by return partialview("newsstory", viewmodelstory); then in view have following declaration @model viewmodelstory @using gcbsmvc.models to access model have tried various linq , directly querying model, nothi

asp.net - c# how to give relative path in web.config -

here folder structure d: |_ myproject | |_web.config |_ sample |_xml-file in web.config have given absolute path as: <add key="xmlpath" value=" d:\sample\xml file" /> now, how can change path relative path? tried below , not working. <add key="xmlpath" value=" ..\..sample\xml-file" /> i have old old code. whenever wanted put relative file-path-name in settings-xml-config, call helper function(s). public class directoryhelpers { public static string findphysicalrootdirectory(page p) { string rootdir; //rootdir = p.server.mappath("/"); rootdir = p.server.mappath("~/"); return rootdir; } public static string findvirtualrootdirectory(page p) { return "~/"; } } and example: public partial class directorycheck : system.web.ui.page { protected void page_load(object sender, eventargs e) {

Cordova + Ionic App run in background and resume to the last screen -

i'm developing new version of app kind of stopwatch after amount of time make step or reach checkpoint. stopwatch should run hours , hours , hours without stop. when app works in foreground there no problems when app pass in background strange happens , after amount of time seems app killed, , when come app restarted. the old app made cordova + sencha touch don't had behavior , stay days running in background (without using plugins this). i don't need app stay running in background because need know when stopwatch started, come , resume app last screen. how can do? thanks! there many things happen meanwhile app in background, save current app state on app exit/pause event, save clock time. once user return, somehow read last state, "recreate" last state, check current time , compute time has passed update stopwatch. you rely on server time instead of device time.

Git fetch and merge error but file not modified -

Image
after fetching remote (git fetch origin), have following commmit tree, , working on "personal_commit" ---develop----origin/develop \----personal_commit. i checked out develop, , try perform merge fast-forwards origin/develop. way, can later rebase personal_commit on develop. error: "your local changes following file overriden merge" "please, commit changes or stash them before can merge". but there no pending changes on file ! please me resolve this. notes: although file automatically generated, , can discard safely, possible in 1 of branches, had removed git repository in past. this answer not work because there no changes stash or commit. you have untracked file alldiagnostics.cs on local machine, being fetched in upstream code well. since git diff shows diff tracked files only, hence not appearing in output. also, seem have ignore rule file in .gitignore , because of doesn't appear in output of git status eit

android - Share only text if file attachement failed via ACTION_SEND -

i have issue while sharing both text , file using share intent. when select gmail share, takes both text , file know, cannot share files via whatsapp. want if file attachment failed text should share not happening. using below code: intent intent = new intent(); intent.setaction(android.content.intent.action_send_multiple); intent.settype("*/*"); intent.putextra( android.content.intent.extra_text, "test messge"); intent.putparcelablearraylistextra(intent.extra_stream, uris); startactivity(intent); please suggest some. like others have mentioned, cannot make whatsapp or behave way want. if whatsapp doesn't handle text , uri , chooses ignore it, there not can it. however, depending on how badly want work gracefully, can: approach 1: get list of packages match intent using: packagemanager packagemanager = context.getpackagemanager(); list<resolveinfo

java - No qualifying bean of type found for dependency in AuthenticationProvider -

hi i'm trying custom authenticationprovider i'm, having torubles autowire annotation. have class find users in database , authenticate them ldap server, have logic cant manage pass autowire error. this class implements websecurityconfigureradapter package com.abc.config; @configuration @enablewebmvcsecurity @componentscan(basepackages = {"com.abc.auth"}) public class configsecurity extends websecurityconfigureradapter { @autowired private authprovider authent; <--- autowire gives me troubles @override protected void configure( httpsecurity http ) throws exception { http .authenticationprovider(authent) .authorizerequests() .anyrequest().authenticated() .and() .formlogin() .loginpage("/prueba") .permitall() .and() .logout()

javascript - Looking for pattern to chain AJAX calls -

we have ajax web application, , common pattern have number of ajax calls call 1 after other. common when save multiple attached entities. example might savecustomer() --> savecustomeraddress() --> savecustomersorder() . we have when methoda() succeeds, ie first method, calls methodb() , , forth (see code below). disadvantage pattern is hard see going on. if read methoda() have no idea reading method name calls methodb() , methodc() . other disadvantage if want change chaining have rewrite lot of code, , if want call method individually, can't done because call methods downstream. function tester() { this.url = 'https://public.opencpu.org/ocpu/library/'; this.save = function() { this.methoda(); } this.methoda = function () { var self = this; $.ajax({ url: self.url, async: true }).always(function (processeddataorxhrwrapper, textstatus, xhrwrapperorerrorthrown) { //check

php - show/hide magento cart in wordpress -

i'm working on site based on wordpress uses magento deal e-commerce (not choice, it's how site setup). when product selected, links through magento shopping cart. have site wide "view cart" link in head of site links magento cart. i'd hide link if cart empty. working soley in magento use hide link: <?php $_cartqty = $this->getsummarycount() ?> <?php if ($_cartqty >0): ?> <a href="link">link cart</a> <?php endif ?> but doesn't work wordpress... there way cart count magento wp use along lines of... <?php if (sizeof($cart) > 1)) : ?> <a href="link">link cart</a> <?php endif ?> <?php require_once '../app/mage.php'; //root app/mage.php of magento mage::app(); //run mage::getsingleton('core/session', array('name'=>'frontend')); //load session $count = mage::helper('checkout/cart')->getsummarycount(); //read count

vb.net - How to load a form again without exiting the application? -

i have 2 form. form1 , form2. in form1 there's button go form2 if click. if click button if form1, form2 load , integer become 1. if click button in form2, integer become 0 , form1. since im in form1, if click again button in form1 go form2 form2 not load again. theres way load again form? heres example: form1: public class form1 private sub button1_click(sender object, e eventargs) handles button1.click me.hide() form2.show() end sub end class form2: public class form2 dim integer = 0 private sub form2_load(sender object, e eventargs) handles mybase.load = 1 msgbox("load complete!!") end sub private sub button1_click(sender object, e eventargs) handles button1.click = 0 me.hide() form1.show() end sub end class thanks in advance! form2's load method gets called once because normal life cycle form. load event gets called once before form loaded first time.

ios - Unable to run the app on iPod -

i have app runs on iphone has ios 7.1 . when changed deployment target 6.1 , tried run app on ipod touch ,it giving me following error undefined symbols architecture armv7: "std::__1::basic_streambuf<wchar_t, std::__1::char_traits<wchar_t> >::sync()", referenced from: vtable std::__1::basic_stringbuf<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > in libxl could please tell me wrong?

linux - nginx-php doesn't work with own build nginx -

i compiled nginx configure command: ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master then did make install install it, has been added can't execute php file, gives me error when try open page :( (i have installed php-fpm) here nginx.conf file: #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65

python - After compiling ans installing wxPython Robot IDE cannot see it -

i have compiled wxpython 2.8.12.1 downloaded sourceforge, following log of make install (this install part). have ran make in main dir , make install (with output). /usr/bin/install -c -d /usr/local/lib /usr/bin/install -c -m 644 /root/packages/wxpython/wxpython-src-2.8.12.1/lib/libwx_base-2.8.so /usr/local/lib /usr/bin/install -c /root/packages/wxpython/wxpython-src-2.8.12.1/lib/libwx_base-2.8.so.0.8.0 /usr/local/lib (cd /usr/local/lib ; rm -f libwx_base-2.8.so libwx_base-2.8.so.0; ln -s libwx_base-2.8.so.0.8.0 libwx_base-2.8.so.0; ln -s libwx_base-2.8.so.0 libwx_base-2.8.so) /usr/bin/install -c -d /usr/local/lib /usr/bin/install -c -m 644 /root/packages/wxpython/wxpython-src-2.8.12.1/lib/libwx_base_net-2.8.so /usr/local/lib /usr/bin/install -c /root/packages/wxpython/wxpython-src-2.8.12.1/lib/libwx_base_net-2.8.so.0.8.0 /usr/local/lib (cd /usr/local/lib ; rm -f libwx_base_net-2.8.so libwx_base_net-2.8.so.0; ln -s libwx_base_net-2.8.so.0.8.0 libwx_base_net-2.8.so.0; ln -s lib

c# - Custom "At least" attribute -

i'm trying create attribute validate model. in model have list. list must have determined number of items matches criteria, "at least 1 active item" or "at least 1 active item "john" name". my code this: public class foo { [atleast(1, new tuple<string, object>("active", true))] public list<item> listofsomething { get; set; } [atleast(1, new tuple<string, object>("active", true), new tuple<string, object>("name", "john"))] public list<item> anotherlist { get; set; } } public class item { public string name { get; set; } public bool active { get; set; } } public class atleastattribute : validationattribute { public int minlength { get; set; } public tuple<string, object>[] propertiesandvalues { get; set; } public atleastattribute(int minlength,params tuple<string, object>[] propsnvalues) { minlength = minlength;

jquery - Isotope filter not showing/hiding specific classes -

i have spent many hours on trying work , have no luck. i followed documentation here: http://isotope.metafizzy.co/filtering.html so want show has class 'box' , hide else. added line of code js: $('.items').isotope({ itemselector: '.box', filter: '.box' }); i have tried other js lines of code, including one: $container.isotope({ filter: '.box' }); none of them seem work. here (partial) html: <div class="metro-layout vertical"> <div class="header"> <h1>my street life</h1> <div class="controls"> <span class="down" title="scroll down"></span> <span class="up" title="scroll up"></span> <span class="next" title="scroll left"></span> <span class="prev" title="scroll right">&l

sql server 2014 - SQL query -- no consistent key -- search multiple columns in one table based upon value in another -

i trying join products table prod_ref table based upon multiple conditions. problem there isn't consistent key join these 2 tables. the upc code unique each item in prod_ref , there more 1 match in products table (or no match @ all). , want test match on columns upc1, upc2, upc3, upc4, upc5, , upc6 products table upc column in prod_ref. it gets further complicated because (not all) of upc codes in prod_ref table have leading zero. need consider if "upc n" codes products "contained in" upc code in prod_ref . if no match can found bump down consider combination manufacturer name , part # , hope match. this gets little tricky in there partial match manufacturer name, exact match part #. (but, more 1 manufacturer have same part number associated product.) so, want me tackle beast? :) in advance. the prod_ref table ~ 3million rows. thee products table ~ 16k rows. we can put indexes , such wherever want. [products] id upc 1 up

c++ - Comparing CString to TCHAR by ==? -

i have cstring pointer , being compared tchar in following way: if(srttest[i] == _t('\n')) //do where strtest cstring* strtest; i wonder if correct, considering not tchar-pointer. compiles ok. code old , no 1 seems have complained it, makes me wonder though. yes, it's ok (assuming strtest valid pointer , i valid index). since strtest cstring* , strtest[i] cstring . , there free operator== overload accepts const cstring& param1 , lpctstr param2 , you'd expect. the msdn documentation here . second overload 1 matters: bool operator ==( const cstring& s1, lpctstr s2 ); (the documentation out of date , signature see when trace actual code different, effect same) markransom alerted me fact code compares strtest[i] character rather string. that's still ok, because there operator== overload takes cstring / char . it's not listed in documentation linked to, here's actual code looks in vs2012 version: friend bool operat

android - Can and should I use two fragments in a Activitiy -

i have little bit experience android , i'm not sure how resolve design problem. maybe know solution. build activity this: http://i.stack.imgur.com/cwqau.png the user should have choice drag marker on map or enter adress. define whole layout in xml without extend map fragment. have example how can split screen 80/20 2 fragments? are fragments right choice? just use single fragment in case. in xml you'll want linearlayout can utilize weights achieve 80/20 described above. <linearlayout> <mapfragment/> <edittext/> </linearlayout> give linearlayout "vertical" orientation , assign weights of 4 , 1 children split them 80/20%. if isn't enough go off, let me know , can explain further. luck!

ios - Unknown cpu type when compiling OpenSSL FIPS Capable libraries for arm64 or arm7s -

i can (at least without warnings , resulting .a files) compile arm7, x86_64, , i386. when compile arm64, unknown cpu type 100000c, no adjustments made . when compile arm7s, unknown cpu type 100000c, no adjustments made . script 2 architectures, modified , uses environment scripts https://github.com/noloader/openssl-1.0.1i-ios below including arm7, works , arm7s , arm64, followed log tail arm64. scripts build non-fips libraries before modification. incore_macho , fips canisters pre-generated , referenced script. created fips canisters modifying instructions openssl fips 2.0 user guide ios appendix, incredibly dated , not work on own. how can 1 compile fips capable library these 2 platforms? edit: i see libssl.a , libcrypto.a have been created , have correct architectures, incore_macho returns identical unknown cpu type error. update: using copy of incore_macho updated armv7 @jww @ https://github.com/noloader/incore_macho , compiles without error arm7s, i'm under assu

java - In a xml file,How can I get the data in a label depending on another label in the same level of node? -

i have xml file following: <root> <doc> <str name="name">test1</str> <str name="uri">test1.com</str> </doc> <doc> <str name="name">test2</str> <str name="uri">test1.com</str> </doc> </root> i want parsing file. name using dom4j. for(element doc : docs ){ list<element> strs = doc.elements(); for(element str : strs ){ if("name".equals(str.attributevalue("name"))){ system.out.println(str.gettext()); } } } how can data of 'uri' after getting data of 'name'under same node 'doc'? thaks lot! isn't enough following: for(element doc : docs ){ list<element> strs = doc.elements(); for(element str : strs ){ if("name".equals(str.attributevalue("name"))){

In phaser.js capture touch events on the canvas -

i'm trying make simple game has single input based on lessmilk.com's flappy bird tutorial . on keyboard hit space jump, on touch enabled devices i'd have users touch anywhere on canvas jump. looking @ input docs seems straight forward capture touch input sprite, i'd user able click/touch anywhere. what's "phaser way" capture touch events? need hacky create invisible sprite covering entire canvas? should bypass phaser , attach dom event handlers? seems i'd been misunderstanding role of phaser's input manager. i'd been trying use game.input.touch hook events needed using higher level input.ondown event: // click / touch jump game.input.ondown.add(this.jump, this);

Curly Braces Notation in PHP -

i reading source of opencart , ran such expression below. explain me: $quote = $this->{'model_shipping_' . $result['code']}->getquote($shipping_address); in statement, there weird code part is $this->{'model_shipping_' . $result['code']} has {} , wonder is? looks object me not sure. curly braces used denote string or variable interpolation in php. allows create 'variable functions', can allow call function without explicitly knowing is. using this, can create property on object array: $property_name = 'foo'; $object->{$property_name} = 'bar'; // same $object->foo = 'bar'; or can call 1 of set of methods, if have sort of rest api class: $allowed_methods = ('get', 'post', 'put', 'delete'); $method = strtolower($_server['request_method']); // eg, 'post' if (in_array($method, $allowed_methods)) { return $this->{$method}(); //

c - How would I free a pointer malloc'd in a separate function? -

i have global variable called exam of type struct exam: typedef struct { question* phead; }exam; exam exam; in function malloc space pointer phead: int initexam() { exam.phead = malloc(sizeof(question*)); exam.phead = null; return 1; } in separate function try free memory: void cleanup() { unsigned int = 0; question* currentquestion = exam.phead; while (currentquestion != null) { // other code } exam.phead = null; } i have tried following inside function: free(exam.phead); my issue not seem free memory allocated malloc. cleanup() free memory allocated exam.phead , cannot change function signatures or move free() calls function. there i'm doing wrong? i'm new c programming. thanks! you have memory leak, right off: int initexam() { exam.phead = malloc(sizeof(question*));//assign address of allocated memory exam.phead = null;//reassign member, null-pointer return 1; } the exam.phead memb

javascript - How to successfully 'grunt build' a yeoman project -

i used yeoman scaffold angular webapp. created webapp runs fine! i trying put in production. register task build, unfortunately, haven't manage find appropriate resources explain in detail how done. so far manage after running grunt build have webapp included , minified css , html files can't scripts included. question: what's role of build block in index.html file? index.html file of yeoman generator comes vendor.js etc. keep ? i appreciate if sum steps must taken in order build yeoman app. in case posting gruntfile , index.html, gruntfile: 'use strict'; module.exports = function (grunt) { // load grunt tasks automatically require('load-grunt-tasks')(grunt); // time how long tasks take. can when optimizing build times require('time-grunt')(grunt); // configurable paths application var appconfig = { app: require('./bower.json').apppath || 'app', dist: 'dist' }; // define configuration tasks grun

How to implement transparent layer to highlight UI elements in Android -

is there library or tutorial how implement call application tutorial feature. when user open activity first time - activity doesn't stops layer shown above custom ui , elements (that being highlighted) activity still visible. if words seem unclear, @ first screenshots here: can see on first screens here http://www.android-app-patterns.com/apps/app/209 the library found https://github.com/amlcurran/showcaseview doesn't allow arbitrary ui, afaik. i work this: create fragment in activity. create style fragment (transparent,picture and...). create sharedpreference method , save status true when user first time open app ,and show fragment. set in oncreate : if (status!=true){ - show fragment -}

extjs - The whole app shifts towards left when Internet Explorer is not expanded to its whole width and length -

i have reduced length , width of ie browser window. app loads first time. have form opens on click of button on homepage. in form, if leave field invalid , click on save, code written such if there field invalid, focus on invalid field. so, ie10 browser window small, when leave field in form invalid , click on save, whole app shifts towards left inlcuding form , fields inside form. have no clue why happening. using following code focus on invalid field, child.getel().dom.scrollintoview(); i aware there bug scrollintoview when using ie browser. can suggest me alternative scrollintoview()? in advance! used foloowing instead of scrollintoview(), 1) field.getel().focus() focus on invalid field 2) panel.body.el.scrollto('top',0,true) scroll form top every time open it

php - Cannot create database with terminal doctrine:database:create -

i cannot succeed in creating database symfony throught terminal (i use mac , mamp) the line in terminal macbook-pro-de-xxx:symfony xxx$ php app/console doctrine:database:create the answer got in terminal warning: pdo::__construct(): mysql server has gone away in /applications/mamp/htdocs/symfony/vendor/doctrine/dbal/lib/doctrine/dbal/driver/pdoconnection.php on line 40 warning: pdo::__construct(): error while reading greeting packet. pid=52773 in /applications/mamp/htdocs/symfony/vendor/doctrine/dbal/lib/doctrine/dbal/driver/pdoconnection.php on line 40 not create database connection named `symfony` sqlstate[hy000] [2006] mysql server has gone away here other information might me find probleme come from the parameters.yml file in symfony/app/config # file auto-generated during composer install parameters: database_driver: pdo_mysql database_host: localhost:8888 database_port: null database_name: symfony database_user: root database_password: root mailer_transport:

python - Include alembic as part of a custom installer script, to create or upgrade database? -

i sending users python script install our product. part of installation, want able create set of database tables well. it seems alembic perfect job; because each upgrade of our product, have alembic upgrade database. in order make simple our users, there way to: include alembic part of our distribution, without forcing end user run pip install it? call alembic python script, can in python (without having create bat or sh file)? this has run cross-platform, platform-dependent steps of installation (e.g, running "make") less desireable.

mysql - PHP login form not working properly -

i trying create simple log in form, every time click on submit button goes other page, if log in info not correct. here code, can me problem? thanks! login.php <?php session_start(); if(isset($_session['username'])) { echo '<script type="text/javascript"> window.location="index2.php";</script>'; } if(isset($_post['submit'])) { include('connection.php'); $user = mysql_real_escape_string($_post['username']); $pass = md5($_post['password']); if($user && $pass) { $sql="select * korisnici username = '" . $user . "' , password = '" . $pass . "'"; if (!$q=mysql_query($sql)) { echo "<p>error</p>" . mysql_query(); die(); } if (mysql_num_rows($q)==0) { echo '<script type="text/javascript">alert("username password incorrect!"); window.location="login.php";</script>'; } else {

Tooltip fiddle not working for me -

http://jsfiddle.net/irvindominin/jlkcs/5/ i can't figure out why fiddle example isn't working. can me out might wrong in code? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.0/jquery-ui.js" type="text/javascript"></script> <script>$(function () { $(document).tooltip({ content: function () { return $(this).prop('title'); }, show: null, close: function (event, ui) { ui.tooltip.hover( function () { $(this).stop(true).fadeto(400, 1); }, function () { $(t

c - What is the size of HANDLE? -

for exercise, @ startupinfo structure. can see last 3 elements has type handle . so want know size handle has. know size of handle ? the windows handle type isn't opaque type. windows defines couple of properties can depend on. main 1 answer your question: of type void * . windows data types entry on msdn: handle a handle object. this type declared in winnt.h follows: typedef pvoid handle; later on in table can see pvoid defined void * . so handle has same size void * . or in other words, it's 32 bits when using 32-bit compiler , 64 bits when using 64-bit compiler. shouldn't need hard code either of these values in code, instead use sizeof(handle) . the other property of windows handle type obscure, , barely documented: kernel handles the bottom 2 bits zero . shouldn't need depend on in code, , can see never want to. mention completeness , emphasize how microsoft has defined handle more internal implementation detail

Change content of HTML page from another page -

i programming while , have question. can make html page change things & settings affect other html page? user interface? need php? of course these need uploaded on internet! is possible? can make html page change things & settings affect other html page? yes, can. like user interface? sure, why not? does need php? i wouldn't needs php, 1 way, possibly. there many ways that. is possible? totally! anyway, i'm answering question, being of low quality, risking downvoted, it's possible want. have search , try something. then, if stuck @ point, can post more specific question here on so, , glad help!!

linux - JBoss user permissions -

i've upgraded jboss eap 6.2.0ga 6.3.0ga, , run problem after installing activemq embedded module. same configuration working on windows computer, believe sort of centos permissions issue. info [org.apache.activemq.store.sharedfilelocker] (starting activemq broker) database activemq-data/kahadb/lock locked... waiting 10 seconds database unlocked. reason: java.io.ioexception: failed create directory 'activemq-data/kahadb' note has no problem writing logs or anything. it's damn activemq related permission. the issue occurs if run service. i.e. service jboss-as start if run bin/standalone.sh & works fine. i've given jboss.jboss user ownership on related jboss now, , chmod 755 everything. (there's lot of confusing info jboss:jboss or jboss.jboss refer user in jboss group. neither works.) chown -fr jboss.jboss /usr/share/jboss-eap-6.3/ chown jboss.jboss /usr/share/jboss-as chown jboss.jboss /etc/init.d/jboss-as chown jboss.jboss /e