Posts

Showing posts from 2011

angularjs - Get the html element form $scope, that ng-repeat created from $scope? -

is possible html element (for styling) $scope object? i'm using ng-repeat on $scope.array , know $scope.array[0] corresponds first element in html created ng-repeat , possible html element itself through $scope in javascript? you can attach controller each element , inject $element access each element way. like: html: <li ng-repeat="item in items" ng-controller="itemcontroller"></li> javascript: module.controller('itemcontroller', ['$scope', '$element', function($scope, $element) { // use $element here }]); however, if want change styling of each element, should consider using ng-class on each item, , specifying class $scope of each item. if want dom manipulation, it's recommended within directive.

php - Complex MySQL query, how to select all ingredients and get the quantity needed for orders -

i have query want list out ingredients on hand, , amount of ingredients needed orders outstanding. query works fine if ingredient being used in order, if has not been used in order yet not show ingredient in query. is there way structure query shows ingredients , quantity on hand, amount needed outstanding orders? suggestions appreciated. in advance. (*0.00220462 converts grams pounds) select products.units, (orders_items.quantity - orders_items.quantity_baked) num_loaved_needed, inventory.title, inventory.id, round(inventory.quantity * 0.00220462,2) pounds, round(sum( (dough_recipes.grams / doughs.yield) * products.weight * (orders_items.quantity - orders_items.quantity_baked) * 0.00220462 ),2) amount_needed_for_all_current_orders orders_items left join products on products.id = orders_items.product_id left join doughs on doughs.id = products.dough_id left join dough_recipes on dough_recipes.dough_i

scala - scalatra not displaying views that match routes correctly -

i'm getting started scalatra , jade, views match route come wrapped in <pre></pre> tags. project setup so: //scalatraservlet.scala def get("/index") { jade("index") } //web-inf/templates/views/index.jade h1 indexing. //web-inf/templates/views/no_route.jade h1 works correctly! if hit localhost:8080/index on browser, shows whole html structure inside <pre></pre> tags, if hit localhost:8080/test , doesn't have route defined in scalatra, renders correctly. doing wrong? there caveat working routes , jade? have tried adding contenttype before calling jade(...) ? def get("/index") { contenttype="text/html" jade("index") }

sql server 2008 - Can i display column name when copying to excel? SP -

short morning question.. when copy results stored procedure excel or whatever terrific column names (50+columns). is easy way that? edit: have both navicat premium , ssms.. in ssms, in results grid, select whatever cells want copy (presumably in case), right-click , select "copy headers" (or press ctrl + shift + c ).

mongodb limit operation retrieve newest docs -

mongodb find return docs ascending order of "_id", when apply limit(n) on find(), return oldest n docs (assume doc1's _id > doc2's _id imply doc1 newer doc2, example, objectid ). want let return newest n docs do: col.find().sort({"_id":-1}).limit(n) is inefficient? mongodb sort docs in 'col'? the _id field "primary key" , therefore has index there not "sort" on whole collection, traverses primary index in reverse order in case. provided happy enough reflect "newest" documents, , in normal circumstances there no reason believe otherwise, return want in efficient manner. if indeed want sort else such timestamp or other field create index on field , sort have above. general cases should use index , return in "descending order" or specified in direction of sort or default index db.collection.ensureindex({ "created": 1 }) or default "descending" : db.collection.en

Application level monitoring in Tomcat using Zabbix/Nagios -

i pretty comfortable nagios , newbie in zabbix. have tomcat in have deployed 3 war files. able monitor tomcat such using nagios not able monitor individual status of 3 applications. possible individually monitor applications using nagios/zabbix ? information regarding either of them amazing, in nagios since used it. lot. since connecting tomcat (or whatever application server) using jmx, i'd recommend monitor status of application using jmx too. in zabbix you'd have create item every metric want monitor. in application have register mbean. public void registernotikumimbean(string app){ mbeanserver mbeanserver = managementfactory.getplatformmbeanserver(); hashtable<string, string> tb = new hashtable<string, string>(); tb.put("type", "yourcustomtype"); tb.put("subtype", "yourcustomid"); objectname on = null; try { on = new objectname("your.pa.cka.ge", tb);

PHP - symfony2 - Getting error when checking whether Session is set or not -

problem - want check whether session set or not in '__construct' of 'controller', getting following error - fatalerrorexception: compile error: cannot use isset() on result of function call (you can use "null !== func()" instead) the following code snippet in '__construct' - function __construct() { $request = request::createfromglobals(); $session = $request->getsession(); if(!isset($session->get('id'))){ $this->redirect('userauthbundle:auth:login.html.twig'); } } if use '!= null' instead of '!isset' giving me error following - fatalerrorexception: error: call member function get() on non-object is there other alternative way can implemented. thanks in advance. manual says : warning isset() works variables passing else result in parse error. checking if constants set use defined() function.

c# - Trouble with AWAIT / ASYNC and WebApi with FOREACH -

i have multiple async methods return same type different oauth based rest api calls. if call 1 directly, can data back: //call specific provider public async task<list<contacts>> get() { return await providers.specificprovider.getcontacts(); } however, if try loop through multiple accounts, object returning before await finishes: //call providers public async task<list<contacts>> get() { return await providers.getcontactsfromallproviders(); } public async task<list<contacts>> getcontactsfromallproviders() { var returnlist = new list<contacts>(); //providers inherits list<>, can enumerated trigger //all objects in collection foreach (var provider in providers) { var con = await provider.getcontacts(); returnlist.add(con); } return returnlist; } i'm new async , missing simple the code have provided call web service each provider 1 one in serial fashion. not s

security - Setting HTTP headers in a Play! framework web application -

Image
where can set security http headers in play! framework web application project? want set headers x-content-type-options nosniff , x-frame-options deny . i have tried set these headers in nginx.conf file, not working zap tool zap tool giving alert these headers missing after setting file. link: https://github.com/playframework/playframework/pull/2524 i have tried solution in documentation on configuring security headers class securityheadersfilter not present in package said. i using play! 2.2.1 , java used controllers. probably best place nginx if you're using reverse proxy play app. instead of adding headers in nginx configuration's http section (as per your comment ) try adding in server block. server { listen 80; server_name *.something.com; location /stuff { alias ../; add_header x-frame-options deny; add_header x-xss-protection "1; mode=block";

regex - How to detect a Url is BookMark Format -

help i want open url in new window ,bookmarkformt url open in current webbrowser i have simple way detect bookmark format url file:///d:/administrator/desktop/123.htm#222 which contain .htm# or .htm# this correct bookmark format url // bookmark name 222 file:///d:/administrator/desktop/123.htm#222 // bookmark name ##abc file:///d:/administrator/desktop/123.htm###abc // bookmark name //.htm##.htm#abc#.html##// file:///d:/administrator/desktop/123.htm#//.htm##.htm#abc#.html##// how detect url bookmark format? regularexpressions can solve this,i can not write corrent regex? this solution, need dectect url bookmark format string htmfilename = @"d:\administrator\desktop\123.htm"; private void form1_load(object sender, eventargs e) { webbrowser1.statustextchanged += new eventhandler(webbrowser1_statustextchanged); webbrowser1.navigate(htmfilename); navigated = true; } private void webbrowser1_stat

html5 - Media Query-Apple Ipad & Phone -

please advise on how apply media query(at size media query should applied) landscape size apple ipad , iphone screen size.please advise work on every phone , tablet landscape view. use following way : step : 1 add following meta tag in head tag <meta name="viewport" content="width=device-width, initial-scale=1.0"> step : 2 add media query accordingly device type : http://stephen.io/mediaqueries/ here ref http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design

Rails 4 better way to change :url/:id params -

i trying figure out hours couldn't find answer fo in rails 4! better way change :id params else? trying do resources :articles, param: :article_title but not working! receive message "couldn 't find article without id"... thanks! are trying make urls more "/articles/my-article-title" instead of "/articles/456"? there number of ways this, cleanest way use friendly_id gem .

Error in servlet mapping and/or Tomcat server local host not running -

i need help.the code shows error.i think web.xml file wrong. created servlet system uses quartz cron scheduler create job. in case, job wake user after user-defined no. of hours.the code pretty straightforward , part error free. except servlet mapping part. have faced difficulty when comes mapping , have tried level best rectify errors seems there problem says " server tomcat v7.0 server @ localhost failed start. " here code- 1. html file <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>enter after how many hours you'd woken up-</title> </head> <body> <form name="form" action="alarmsystem" method="post"> hours :<input type="text" name="hr"><br> minutes:<input

ajax - How to approach a long time process in PHP? -

i working on php product application, deployed on several client servers (say 500+). client's requirement is, when new feature released in product, need push changes ( files & db ) clients server using ftp/sftp. bit concerned transferring files using ftp 500+ server @ time. not sure how handle kind of situation. have came ideas, like when user (product admin) click update, send ajax request, update first 10 servers, , returns remaining count of servers. ajax response, send again next 10, , on. or create cron, runs every 1 mins, check whether update active, , update first 10 active servers. once complete transfer server, changes status server 0. i want know, there other method these kind of tasks ? add whole code code repository mechanism git , push on present files created repository. go 1 server , write cron auto pull repository severs , upload cron every server. in future if add new feature pull whole repository , add feature. push code again repos

android - UI Rezising Lags when Keyboard gone -

Image
i'm developing following layout. when keybaord displayed, ui resized available space (state 'a'). when keybaord hides, ui again resizes fill entire screen (state 'b'). there visible lag in ui when going state 'a' state 'b'. there way avoid lag or provide smooth resize. update: i'm using android:windowsoftinputmode="adjustresize" in manifest activity. given screenshot sample. actual layout contains more complex layout may causing lag on resize, 1 describes issue. there way implement animated resize ui keyboard hide? highly apreciated. in manifest file under activity tag add: android:windowsoftinputmode="adjustpan" will solve problem!!

python - Django - page not found 404 -

i'm trying create site using django . have index view working, want create simple custom view , map unable to. i'm getting 404 error. the app inside project called emails. here files: base/urls.py from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^emails/$', include('emails.urls')), ) emails/urls.py from django.conf.urls import patterns, include, url emails import views urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'^custom/$', views.custom, name='custom'), ) emails/views.py from django.http import httpresponse def index(request): return httpresponse("hello world, you're @ index.") def custom(request): return httpresponse("this custom view.") here 404 : using urlconf defined in c

postgresql - What is the difference between keeping column on left of = in sql -

i reading else sql , code this there view called user_v column path array select * user_v 'user_type'=path[2] can't use path[2] = 'user_type' this precaution taken programmers in languages assignment , comparison can confused, such c or php, following statement looks innocent: if ( $foo = 1 ) but assigning 1 $foo , , if evaluate true (in php, @ least, 1 true). meant if ( $foo == 1 ) . if reverse arguments, error becomes obvious sooner: if ( 1 = $foo ) # syntax error if ( 1 == $foo ) # desired behaviour this known "yoda coding", , in the coding standards of wordpress, example . see also: why put constant before variable in comparison? in sql, there less chance of such muddle, since although = can mean either assignment or comparison, there situations typo select wrong meaning. however, if coding standards every other language used project mandate it, make sense reinforce habit using in sql, since can't think

php - What is the rationale behind "It is not safe to rely on the system's timezone settings"? -

in python can do import datetime print datetime.datetime.now().strftime('%y-%m-%d') # prints `2014-06-27`. similarly, in node.js: console.log(new date().todatestring()); // fri jun 27 2014 when try same in php: <?php print date('y-m-d'); ?> i'm getting this warning: date(): not safe rely on system's timezone settings. required use date.timezone setting or date_default_timezone_set() function. in case used of methods , still getting warning, misspelled timezone identifier. selected timezone 'utc' now, please set date.timezone select timezone. in .... what rationale behind message? why don't python or node bother? "unsafe" using system timezone? since there many posts regarding error, please read carefully : i'm not asking how fix (pretty obviously), i'm wondering why i'm getting message in first place. php traditionally used web development, 1 plausible reason consumers of web servi

Simplest method for applying NFC trigger to basic timer application (Android) -

i have basic countdown app counts down 10 secs when button clicked. simplest method have timer start when contact made specific nfc tag? (ntag203) i've read several nfc tutorials , 1 i've been able work has been simple tag reader. if wanted have specific nfc tag trigger simple timer app button would, how go doing so? best try read id or interpret plain text identifier? thanks (using android studio) nfc app main activity (code taken tutorial: http://shaikhhamadali.blogspot.com/2013/10/near-field-communication-nfc-android.html package com.example.nfctest2.nfctest2app; import java.io.unsupportedencodingexception; import java.util.arrays; import android.app.activity; import android.app.pendingintent; import android.content.intent; import android.content.intentfilter; import android.content.intentfilter.malformedmimetypeexception; import android.nfc.ndefmessage; import android.nfc.ndefrecord; import android.nfc.nfcadapter;

json - Changing an immutable object F# -

i think title of wrong can't create title reflects, in abstract, want achieve. i writing function calls service , retrieves data json string. function parses string json type provider . under conditions want amend properties on json object , return string of amended object. if response call {"property1" : "value1","property2" : "value2", "property3": "value3" } i want change property3 new value , return json string. if jsonprovider mutable exercise like: type jsonresponse = jsonprovider<""" {"property1" : "value1", "property2" : "value2", "property3": "value3" } """> let jsonresponse = jsonresponse.parse(response) jsonresponse.property3 <- "new value" jsonresponse.tostring() however, not work property cannot set. trying ascertain best

wordpress - How to redirect a HTTP site to HTTPS site using 301 redirect instead of 302 -

i have woocommerce website using https. https if being redirected using 302 redirect , need change 301 redirect. have "force ssl (https) on checkout pages (an ssl certificate required)." option checked in woo commerce settings , htaccess file below what's best way change 302 301 redirect? # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress # forcing https rewriteengine on rewritecond %{server_port} 80 rewriterule ^(.*)$ https://www.aransweatersdirect.com/$1 [r,l] keep .htaccess this: # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{server_port} 80 [or] rewritecond %{https} off rewriterule ^ https://%{http_host}%{request_uri} [r=301,ne,l] rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewriteco

objective c - How to set alarm on selected weekdays(MonDay,Sunday) in ios. (Localnotification) -

Image
hi friends doing alarm application in had requierment repeat alarm selected days(monday, tuesday,--). once select monday alarm fire on every monday. how buddy suggest me. advance thanks. when notification fire running 7 week days. nsdate *localdate = [nsdate date]; nsdateformatter *dateformatter1 = [[[nsdateformatter alloc]init]autorelease]; dateformatter1.dateformat = @"eeee mmmm d, yyyy"; nsstring *datestring = [dateformatter1 stringfromdate: localdate]; nslog(@"date:%@",datestring); (int i=0; i<8; i++) { // how day add int adddayscount = i; // creating , configuring date formatter instance nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"eeee mmmm d, yyyy"]; // retrieve nsdate instance stringified date presentation nsdate *datefromstring = [dateformatter datefromstring:datestring]; // nslog(@"dateformmater:%@",datefromstring);

html5 - Why no data-* elements? -

this question satisfy curiosity: growth , acceptance of larger javascript frameworks last, say, 5 years, has become increasingly common have attributes on elements add custom behavior known html elements. reason html5 introduces data-* attributes, every tool, including browser parsing dom actively ignores while rendering key js framework enrich html full-fledged application platform. with angular directives (for example), app builders enrich html whole adding ability create custom elements. thing however, editing tools, visual studio, break, since actively check if html elements add exist. now, question not visual studio (i know how disable html validation), why did creators of html5 standard never considered include data-* elements well? or maybe did, , idea discarded somehow. know? the data- prefix part of html5 draft these attributes semantic html; example, attaching database id html element html parsers can use data. in case of angular, custom attributes not car

java - Sqlite_master not updating -

i have function should return true if table exists in file (test.db). time working fine deleted .db file test rest of code able generate database scratch. however, instead of function returning false, continues return true though table not exist. the code: public static boolean tableexists(string table){ boolean tableexists = true; try{ sql = "select * sqlite_master name ='"+table+"' , type='table'; "; stmt.executeupdate(sql); }catch(exception e){ tableexists = false; } return tableexists; } this function not check whether query returns data or not. (and executeupdate not make sense select statements.) you have try read query returns: public static boolean tableexists(string table) { sql = "select 1 sqlite_master name ='"+table+"' , type='table'"; resultset rs = stmt.executequery(sql); return rs.first(); }

android - Null Pointer Exception while trying to use the settext function -

i have 2 navigation tabs , each navigation tab contains listview. each listview made of several components including textview trying edit. i'm trying settext text view in class defines each fragment null pointer exception. the following code excerpts: view pager <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/titletasklist" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v4.view.viewpager> each fragment: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <listview android:id="@android:id/list" android:layout_width="fill_parent" android:layout

c# - How to extract one file from Zipped file -

the scenario data file located in remote machine, file zip file , size big. want extract target file according file name, don't want download whole file remote machine. method identify target file , download part of data remote file? btw, development language c#. there no way local code unzip remote file without downloading it. if want minimize amount of data transferred, need service running on remote machine doing extraction part , transferring desired file.

width - Why does inline-block element expand more than its content? -

Image
take here: http://dabblet.com/gist/8d85e0e30b4d46e14654 . why span element expand if 2 words on same line? there way prevent , have wrap minimum width possible given content size? edit: using 'white-space:nowrap;` doesn't fix issue. i'm trying make span fit text, not text fit span. that's why parent div has fixed width. here's screenshot. thank you. try this: link span { display:inline-block; background:#333333; color:#ffffff; white-space: nowrap; overflow: hidden; } div { width:80px; }

javascript - Multiple charts (stacked bar and line), line is not centered -

Image
i have created stacked bar + line chart. problem line-items not centered on stacked bar: is there way center on stacked bar? this code: <head> <script src="/lib/js/dhtmlxsuite/dhtmlxgrid/codebase/dhtmlxcommon.js"></script> <script src="/lib/js/dhtmlxsuite/dhtmlxchart/codebase/dhtmlxchart.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="/lib/js/dhtmlxsuite/dhtmlxchart/codebase/dhtmlxchart_debug.css"> </head> <body> <script> var chart; window.onload = function() { chart = new dhtmlxchart({ view:"stackedbar", container:"chart1", value:"#ftenat#", width:50, xaxis:{template:"01/0#maand#/#jaar#"}, yaxis:{start:27000,step:500,end:37000}, color:

angularjs - Angular js Passport example is not working -

i trying follow example: source : https://github.com/daftmonk/angular-passport demo website: http://angular-passport.herokuapp.com/ i copied , pasted app , server same. routes work (in server side , client side too) when tried log in or sign 404 error server. here server-side routes part. i checked app.get('/robots.txt') works. and routes part login (that gave me 404 error): app.post('/auth/session', session.login); but tried: app.post('/auth/session', function(req,res){ console.log('here session requested'); res.sendfile('robots.txt'); }); this code checking whether server respond well. but still got 404 error. how can fix works? ir how can test post routings console.log or, else? try using postman chrome extension debugging restful api s https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en

ios - How to delete a polygon on map -

i implemented map using apple's native f/w , have implemented functionality add polygons on map. now, want have "close" button @ edge of each polygon , when click on button, need delete polygon (one polygon @ time). have tried creating button on polygon edge, unable make action on clicking button. have tried annotations well. in case, unable create close button on polygons; able have close button (annotation) on last polygon created when click on button, polygon created first getting deleted. kindly suggest me solution have close button on each polygon, , delete polygon(one one) on clicking button.

c# - Cannot assign <null> to an implicitly-typed local variable -

i want to select field data table dt_branches_global in such way that, if radiobutton_qp checked data table contain string field otherwise data table contain int field. doing. getting error while initializing variable var. var allbranch_ids = null; if (radiobutton_qp.checked == true) allbranch_ids = dt_branches_global.asenumerable().select(x => x.field<string>("businesssectorid")).toarray(); else allbranch_ids = dt_branches_global.asenumerable().select(x => x.field<int>("businesssectorid")).toarray(); the compiler still typed needs figure out type. impossible compiler infer type of assign null. later on try assign 2 different types. array of ints , array of strings. try like: string[] allbranch_ids = null; if (radiobutton_qp.checked == true) allbranch_ids = dt_branches_global.asenumerable().select(x => x.field<string>("businesssectorid")).toarray(); else allbranch_ids = dt_branches_global.asenumer

sql - Apportioning data into new columns -

morning, i quite new sql server 2008 wondering if me. i have: select c.code, d.date, d.date_previous, cast(d.date-date_previous int) days, d.units, d.cost table1 d inner join table2 p on d.id = p.id inner join table3 c on p.c_id = c.id date_previous > '31/12/2012' this bringing 1 row per invoice received after 31/12/2012. aim following columns: code jan data feb data mar data etc... one unique code per line (so i'm assuming row partitioning required) where bill has period of 3 months with, example, 300 units, i'd separated out across 3 months (100 in each) i'm aware i'd need use pivot function , temp tables i'm not advanced yet.

How to search twitter.com/search and parse the data in android -

i have been dealing twitter application in android. used oauth authentication , did search given keyword. the problem rate limit . can't perform many searches. well after exhaust search came across link: using search api it says that: as users, best thing perform search twitter.com/search then found application in google play twitter search doesn't use authentication , performs unlimited searches. i doubt twitter search developer has used logic. would possible make search directly twitter.com/search ? if yes, libraries/methods/ways should follow? would possible make search directly twitter.com/search ? technically yes, should avoided if @ possible. have parse html , both slow , error prone process. what libraries/methods/ways should follow? you should stick official api. realise rate limit kind of in way, confident can mitigate problem reducing overall amount of calls api , more efficiently using each call. have remember

visual studio 2013 - Set supported orientation for Windows Phone 8 project -

i have wp8 project originated template "directx app (windows phone 8.0)". how set supported orientation (i want make landscape-only)? have found file named "wmappmanifest.xml" in project folder, has no "orientation" option. for performance reasons, option of automatic rotation not available on windows phone 8 , we’re stuck having manually take care of everything: rotating stuff before draw them, , processing input values fit them new orientation. there several things need in order support other orientations besides default portrait one. you can find more reference here handling orientation in windows phone 8 game

Using javascript square bracket notation to re-arrange values in object -

i've got object: servicesselected: { spw: { sku: "xyz" } } i need make this: servicesselected: { xyz: { sku: "xyz" } } what i've done far: myvar = servicesselected.spw.sku //stores "xyz" myvar this can't it. following doesn't work. can't use regular dot notation because doesn't support inserting variables, right? newobject = ["servicesselected"][myvar]sku[myvar] try this: var newobject = new object(); newobject["servicesselected"][myvar]["sku"] = myvar; javascript supports object attribute querying double square brackets, dynamic generation of attributes. in case, can query newobject.servicesselected[myvar].sku .

javascript - Cascading Dropdown Validation is failing in MVC Razor -

Image
problem statement: i have created cascading dropdown country , state using jquery , json,everything working fine.i'm able bind data country , data state on change event of country.only problem i'm facing cascading validation country , state. on opening view iff click create button without selecting/entering values controls showing validation message all.if select country , click create, not showing validation message state if no value selected state. what i'm doing wrong?? think i'm doing wrong in script part of view !!! please see attached images more details: image 1 : when click create button showing validations controls. image 2 : after selecting country drop-down if click create button,validation state not appearing why?? view code: <div class="form-horizontal"> <hr /> @html.validationsummary(true) <div class="form-group"> @html.labelfor(model => model.citymodel.

interpreter - How can one parse a function of unknown type in Haskell? -

i'm haskell novice, , i'm trying write parser evaluates set of simple haskell expressions. however, i'm running difficulty functions when don't know in advance type are. suppose, example, know string want parse evaluates integer. here few possibilities string might be. "succ 4" "head [5,6,7]" "sum [1,3,1]" "length [a,b,c,d,e]" "pred $ sum $ take 3 $ iterate succ 1" naively i'd last example process this. parse out function pred , deduce fact has type (enum a) => -> a , string represents integer rest of string (after dollar) still represents integer. parse out function sum , deduce i'm trying evaluate list of integers. parse out function take , deduce i'm looking integer , list of integers. parse out 3 , deduce rest of string should list of integers. parse out iterate , deduce i'm looking function of type int -> int , integer. parse out succ , 1 . perform evaluation

datagridview - Kendo UI - how to get values of all columns headers (name,index,is hidden, etc..) -

i ask, how can values of columns headers (name,index,is hidden, etc..) datagrid? i add possibility save custom user view predefined order of colums, visibility, etc.. could grid instance (and if yes,how)? or other suggest how save , restore custom data grid view? thanks help. you can column information columns field. see here more info. basically, can columns grid doing this: var grid = $('#grid').data('kendogrid'); var columns = grid.columns; this gives array of columns, providing index. objects contain properties of column including field , title , hidden , other data. as example, title of first column: var title = columns[0].title; regarding saving view, have save column array , set column option when initialize grid again.

java - Use spring beans from Serializable objects -

i need execute task on remote machine. task dummy runnable or callable , serializable transferred remote host, deserialized , executed there. need use spring beans task execute on remote machine. what elegant way 'serialize' bean name when task serialized on client machine , 'deserialize' real bean while deserialization on remote machine? other solutions? if have access applicationcontext can ask create instance you, e.g. enable autowiring: appcontext.getautowirecapablebeanfactory().createbean( beanclass, abstractbeandefinition.autowire_by_type, true) a more elegant way annotate class @configurable, described here .

sorting - Sort of Nested Maps, JAVA, innerMap not change keys from OuterMap -

i trying sort nestedmaps map<integer,map<string,integer>> integer,string,integer: firstkey id, innerkey name, innervalue phone. doing this: set<entry<integer,map<string,integer>>> set = add.entryset(); list<entry<integer,map<string,integer>>> list = new arraylist<>(set); set<entry<string,integer>> set2 = add2.entryset(); list<entry<string,integer>> list2 = new arraylist<>(set2); collections.reverse(list); collections.reverse(list2); and looping see results, if have first 3 inputs id, name , phone: , have result: id 3 - phone 2, name i2; id 2 - phone 1, name i; id 1 - phone 5, name p; next sorting should have name, , depending on id-should change, doesnt work. and how have sort name result this: id 2 - phone 1, name i; id 3 - phone 2, name i2; id 1 - phone 5, name p; first of all, if don't use wrapper

svn - Import environment variables from text file on network using Jenkins -

i have unix master , windows slave. have 10 subversion repositories, tags automatically created process outside of jenkins. these tags multiple repositories make 1 complete dataset application. when these tags created, single text file on cifs share created contains urls of these tags 10 repositories. name of text file , cifs path static. i need suck in contents of file can tell job tags use compile dataset. have ability adjust syntax of text file, able tell job example: repository1=https://svn/repo1/tags/newtag repository2=https://svn/repo2/tags/newtag i know possible; new jenkins, , have windows background. you need envinject plugin . take property-style file (your file fits that), , inject environment variables jenkins. there many places can configured: globally node globally job before scm checkout as build step i assume need them before scm checkout, use set clean environment example plugin page. suggest keep both checked: "keep jenkins

python - Fitting a Poisson distribution to data in statsmodels -

i trying fit poisson distribution data using statsmodels confused results getting , how use library. my real data series of numbers think should able describe having poisson distribution plus outliers robust fit data. however testing purposes, create dataset using scipy.stats.poisson samp = scipy.stats.poisson.rvs(4,size=200) so fit using statsmodels think need have constant 'endog' res = sm.poisson(samp,np.ones_like(samp)).fit() print res.summary() poisson regression results ============================================================================== dep. variable: y no. observations: 200 model: poisson df residuals: 199 method: mle df model: 0 date: fri, 27 jun 2014 pseudo r-squ.: 0.000 time: 14:28:29 log-likelihood: -

java - RSS Parser returns 403 -

i'm new java , given assignment xml parsing. have done dom , on sax. that's why i'm using sax parser parsing rss feed. working on files when try parse online rss feed, returns error 403. haven't tried parsing same site on dom because laptop slow takes me 5 minutes open file. thanks help. public class newshandler extends defaulthandler { private string url = "http://tomasinoweb.org/feed/rss"; private boolean indescription = false; private string[] descs = new string[11]; int = 0; public void processfeed() { try { saxparserfactory factory = saxparserfactory.newinstance(); saxparser parser = factory.newsaxparser(); xmlreader reader = parser.getxmlreader(); reader.setcontenthandler(this); inputstream inputstream = new url(url).openstream(); reader.parse(new inputsource(inputstream)); } catch (exception e) { e.pr

plot - How to use tri2grid matlab? -

i have problem tri2grid. have set of coordinate points on triangle , value of interest @ points (3 vectors). create grid using tri2grid command inside triangle , see solution (a matrix) on grid points. did following got in solution matrix (fgrid) nan values. read nan values occur when grid points outside original mesh create grid on same triangle of mesh, not understand why got nan values.anyone can help?? xt=[zgauss(:,1)]; yt=[zgauss(:,2)]; tri = delaunay(xt,yt); xgrids = linspace(min(xt),max(xt),100); ygrids = linspace(min(yt),max(yt),100); [xgrid,ygrid]=meshgrid(xgrids,ygrids); fgrid = tri2grid([xt,yt]',tri',f_on_gauss,xgrid,ygrid); you have nan values because rectangular grid defined on maximum x , y range of triangle contain points outside triangle. draw triangle on piece of paper, try drawing rectangle covers triangle, , you'll see issue quickly. to see actual grid lies can plot out: plot(xt,yt,'g.'); % triangle points hold on plot(xgrid

osx - Show all windows OS X keyboard shortcut for mavericks -

Image
is there keyboard shortcut osx mavericks show windows, minimized or hidden ones application? i hate having use mouse click on chrome icon open other chrome windows. the keyboard shortcut show windows application ctrl + down switch between these windows using arrow keys. to change keys used shortcut whatever want, go system preferences-> keyboard-> shortcuts-> mission control-> application windows .

difference between ((c=getchar())!=EOF) and ((c=getchar())!='~'),'~' can be any character -

as '~' encountered, after not printed , control comes out while loop while((c = getchar()) != '~') { putchar(c); printf(" "); } input: asdf~jkl output: s d f //control out of while loop as '^z' encountered, after not printed control doesn't come out of while loop while((c = getchar()) != eof) { putchar(c); printf(" "); } input: asdf^zjkl output s d f -> //control still inside while loop please explain why happening? eof encountered, while loop must exit, not happening. is necessary (ctrl+z) must first character on new line terminate while loop? has working of getchar() , eof (ctr+z) it's way console input editor works in windows/dos command prompt. input done line line, why can go , forth editing characters until press enter, , @ point contents of line sent program , new line started. whoever wrote editor in dos decided typing ^z @ beginning of line way tell editor you're done providi

PHP math with long decimals -

i'm trying math large decimals. works fine: <?php $math = 99 + 0.0001; echo $math; ?> output: 99.0001 however, when try add decimals more 12 decimal places, not receive expected output: <?php $math = 99 + 0.0000000000001; echo $math; ?> output: 99 how can make if add decimal has more 12 decimal places, result still have exact answer without rounding? example: <?php $math = 99 + 0.0000000000001; echo $math; ?> output: 99.0000000000001 quick google search yielded this . floating point numbers have limited precision. although depends on system, php typically uses ieee 754 double precision format, give maximum relative error due rounding in order of 1.11e-16. the page linked has lots of helpful info regarding floating point numbers in php links libraries can work arbitrary precision floating point numbers. useful depending on needs. edit: also, mark baker said in comment, may need specify precision of number want print in pri

css - CSS3 Transition Fill Mode -

is there way / trick have transition keeping state animation-fill-mode? <style> #firstdiv { width: 100px; height: 100px; background: red; animation: firstdivframe 2s; animation-play-state: paused; animation-fill-mode: forwards; } #firstdiv:hover { animation-play-state: running } @keyframes firstdivframe { { background: red; } { background: yellow; } } #seconddiv { width: 100px; height: 100px; background: red; transition: background 2s; } #seconddiv:hover { background: yellow; } </style> <div id="firstdiv"></div> <br /> <div id="seconddiv"></div> jsbin based on above code, want seconddiv behave firstdiv without using javascript code. firstdiv keep state when mouse stops hovering or animation ends, while seconddiv go original state. no not possible use t

Which one i should use to do 64-bit pointer math for Delphi,, NativeUInt or NativeInt -

since there 64-bit delphi compiler, should use 64-bit pointers. so wondering difference if use nativeint or nativeuint. example, should use pointer(nativeuint(pointer(buffer)) + longword(datawrote))^, or pointer(nativeint(pointer(buffer)) + longword(datawrote))^, does matter? better style? the simplest thing cast pointer pbyte . can perform arithmetic on that: pbyte(buffer) + offset that expression of type pbyte , may need cast other pointer type. as general rule, pointers not integers , should resist temptation convert cast them integers. best let pointers pointers. can perform pointer arithmetic on pansichar , pwidechar , pbyte , , other pointer types can use {$pointermath on} enable pointer arithmetic.

pure html5 vs jquery mobile/angularjs -

we developing cross platform mobile application using pure html5/javascript/css. using bootstrap responsive ui. , using cordova packaging app android , ios. heard can reduce development effort , can code more structured if using jquerymobile or angularjs along html5/javascript/css. can tell me how these frameworks can me in development? you tons of results , answers why should , why shouldn't. recommend 1 framework, , go against it. search google you'll see them. afaik biggest reason using framework jqm / angularjs give application native , feel. html5 design create website, frameworks make them mobile applications. ajax page navigation model, responsiveness, similar design browsers, mvc, less code writing, dom manipulation these reasons why need frameworks. on other hand there quirks too. see these links clear view. choosing right html5 technologies web , mobile application. 10 reasons why should use angularjs five reasons use jquery mobile

sql server - Grouping Multiple Counts on Pivot Table by Year -

i have started learning sql. i've written following: declare @datefrom date = '01-jan-2014', @dateto date = '31-dec-2014' select totalcalls, uniquecalls, totalemails, uniqueemails, agentscontacted, instructed ( select *, (select year(eventdate)) year, (select count(*) events join dbo.contacttype on eventcontacttype=contacttypeid contacttypename = 'call' , eventdate >= @datefrom , eventdate <= @dateto) totalcalls, (select count(distinct eventagentid) events join dbo.contacttype on eventcontacttype=contacttypeid contacttypename = 'call' , eventdate >= @datefrom , eventdate <= @dateto) uniquecalls, (select count(*) events join dbo.contacttype on eventcontacttype=contacttypeid contacttypename = 'email' , eventdate >= @datefrom , eventdate <= @dateto) totalemails, (select count(distinct ev