Posts

Showing posts from February, 2013

unix - How can I compare 3 files together (to see what is unique in one file)? -

i have 3 files file1.txt, file2.txt, file3.txt , of same format. i want select records file1.txt not present in file2.txt, file3.txt based on col2, col3. please advise me how ? i have checked post described on comparing 2 files common records , understood can done using awk. thank you. awk '(x=argind==3)&&!a[$2,$3];!x{a[$2,$3]++}' file{3,2,1}

sql - Addition of two columns in sub query not giving correct result set -

select a, b dcl a='123' , b> ( select sum(a) + (select sum(a) d a= 1506453) aslp a.a= '0527416666') the output getting a=123 b= 23 as per condition have written in sub query should not above record. let me make wild guess here: 1 of columns ecpclaim_total_claim_charge ecpservicelinepayment_payment_amount ecpservicelinepaymentcobadjustment_amount is defined data type float or real means you're comparing inexact floating point numbers. explain why 60.06 > 51.05 + 9.01 can evaluate false of course shouldn't if numbers precise. the remedy either change data type exact numeric type or coerce values precise type comparison. sample sql fiddle demonstrating problem , possible fix.

Getting an error inserting a timestamp using JDBC and PostgreSQL -

i new postgresql. trying insert data table using jdbc. one of column values inserted of following type. 2014-04-04t19:56:42.784z (please note t , z in string). i first used timestamp datatype corresponding column. however, getting following error : org.postgresql.util.psqlexception: error: syntax error @ or near "t19" i changed character(40) thinking might format wrong. however, still getting same error. later, when removed t , z string, error stopped. please note thought colon problem. however, not case through testing. java code snippet string line = 1,2014-04-04t19:56:42.784z,456,0 string[] tempstr = strline.split(","); string sql = "insert table (a , timeofsess , b , c )" + "values("+tempstr[0]+","+tempstr[1]+","+tempstr[2]+","+tempstr[3]+")"; stmt.executeupdate(sql); please note using timeofsess character(40) . analysis not important store time time. ch

jboss6.x - JBoss EAP 6.x - PolicyContext.getContext remains null -

i'm using jboss eap 6.4 enterprise app , i'm little stuck when attempt retrieve active subject. of course, user need authenticate, goes through following code snippet logincontext logincontext = new logincontext("contextname", callbackhandler); logincontext.login(); return logincontext.getsubject(); that works fine (and subject filled in), problem lies when try retrieve subject @ later point in execution ... final subject subject = (subject)policycontext.getcontext("javax.security.auth.subject.container"); ... subject remains null! what missing?? any appreciated. solved! thanks following article on how introduce security manager on jboss eap 6.4 . the problem security manager had configured in jboss. need open standalone.conf (or standalone.conf.bat), uncomment , add following: rem # uncomment run security manager enabled set "secmgr=true" rem # using == when setting -djava.security.policy specifies security manag

R - corrplot correlation matrix division -

Image
here make example 12x12 correlation matrix: df <- data.frame(x1=rnorm(20),x2=rnorm(20),x3=rnorm(20),x4=rnorm(20),x5=rnorm(20),x6=rnorm(20),x7=rnorm(20),x8=rnorm(20),x9=rnorm(20),x10=rnorm(20),x11=rnorm(20),x12=rnorm(20)) cormatx <- cor(df) corrplot(cormatx, method="color") i wondering how 1 output divided in 4 separate 6x6 matrixes? here image of how output should divided. hope makes sense. like this? par(mfrow = c(2,2)) corrplot(cormatx[1:6,1:6], method="color") corrplot(cormatx[1:6,7:12], method="color") corrplot(cormatx[7:12,1:6], method="color") corrplot(cormatx[7:12,7:12], method="color")

javascript - Watermark to appear on canvas after submit -

i have html canvas, choose color , size circle , when onclick, circle appears. want watermark text "hello" seen before paint circles , disappear when start drawing , canvas goes being white. has submit button that removes circles, , want watermark appear when button clicked. i'm sorry bad english, hope you'll understand question. please see jsfiddle . javascript function initiatecanvascircle() { var context = document.getelementbyid('mycanvas').getcontext('2d'), input = document.getelementbyid( 'mycolor' ), size = document.getelementbyid( 'mysize' ), watermark = document.getelementbyid( 'mywatermark' ); context.canvas.addeventlistener('mousemove', function(event) { var mousex = event.clientx - context.canvas.offsetleft; var mousey = event.clienty - context.canvas.offsettop; }); context.canvas.addeventlistener('click', function(event) { var mousex = event.clientx - context.canv

entity framework - EF very slow from a view in certain circumstances: prevent EF to mimic `option(recompile)` -

Image
i use ef6 in winform project i use query view populate datagridview. with no condition populate takes 3s (2500 rows). with specific condition, involving ...where exists(select...) populate takes 13s (212 rows) (same perf in linqpad). i read : (1) ef query against database view slow (2) ef linq tolist slow that quite similar cases. in both cases (with , without condition), sql query runs in less 1s in ssms (this makes me think sql query complexity not involved) my local sql server microsoft sql server 2012 (sp1) - 11.0.3153.0 (x64) jul 22 2014 15:26:36 copyright (c) microsoft corporation express edition (64-bit) on windows nt 6.1 <x64> (build 7601: service pack 1) i got better performance (less 5s) on distant sql enterprise server. does mean ef application querying view not adapted express edition ? where else can understand why ? ===== ===== ef: ssms: there factor 10 performance. there must find ! ===== ===== i managed degrade

rails 4.2 assets loading -

i'm playing rails 4.2 application , seems loads of stylesheets each , every page. is true? how better loading each page relevant stylesheets? on 1 hand, know they'll minified when going production, , reduce total size , cache 1 css whole website. on other hand, page might have thin pages need no more few css lines rendered correctly tones of files no reason. require me super strict , safe when choosing class names in order have no collisions , unwanted overrides. what js assets? acts same way? (i guess answer image assets "hell no!") yes, in development you'll see lot of files (all of them) , in production compiled , minified single file. once file has been downloaded client cached , wont need make further requests load other stylesheet files on concurrent request (unless caching , turbolinks has been disabled). downside file size larger , make initial load time longer. one problem point out scoping. in experience it's way better apply

How to manage volume using FFMPEG -

is there way set/modify/change/update volume of audio when playing using ffmpeg library. in advance. you can use ffmpeg's volume filter. you'll want search around figure out how ffmpeg filters working in application, it's worth effort. you can manually multiplying pcm data in decoded audio data (avframe->data[0]) volume multiplier (>1.0 increase volume, <1.0 decrease volume), you'd need know format of decoded data.

Extract only values betwen strings/ braces in bash -

original text : 2013-08-29 08:51:24 777 ipms 0123456 [prce=101.078804, size=1540000, even=15476.6] hi, can somone me in extracing below original text 2013-08-29 "08:51:24,777" ipms 0123456 101.078804 1540000 15476.6 you can try one: cat file.txt | tr '\[prce=siz,vn]' \ ' ' | awk -f" " '{$4="ipms"; print}' copy , give try.

java - How to display textview dynamic value for localization of android -

hello friends want integrate multiple languages in application made multiple values folder different languages. question how can display dynamic textview value comes web api string value. how can display language per choice application. below have mentioned code. please me. thanks! main.java textview textview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.fragment_main); textview=(textview)findviewbyid(r.id.textview1); textview.settext("my custom text comes web api"); } you can use dynamic value in textview localization in resource folder. can localize text country code , language code. like: res/values-en/string.xml res/values-hi/string.xml res/values-in-gu/string.xml read more

ruby on rails - NoMethodError: undefined method `get' for #<Class:0xc3ba52c> -

i have project totally api 1 returning json response. have affiliation table associated other information. information in tables being fetched through rake task. issue is, project running fine not when run rake task gives error in .get method such nomethoderror: undefined method `get' #<class:0xc3ba52c> /home/munam/.rvm/gems/ruby-2.1.4/gems/activerecord-4.1.6/lib/active_record/dynamic_matchers.rb:26:in `method_missing' here have used : @affiliation = affiliation.get('my_key') if change @affiliation = affiliation.find_by_key('my_key') it works fine. unfortunately not have access rights change in it. not understand why has method stopped working @ sudden. i read on here: http://api.rubyonrails.org/v3.2.1/classes/activeresource/custommethods.html#method-c-get can not make work other way: need integration work properly. thankful if helps.

how to create SQL Command using macros for Access Web Database? -

i'm newbie in access. entrusts me project , found many obstacles since i'm not familiar access, access web database. question how create sql command using macros? know vba not compatible access web database, need find way put insert command. there other way instead of using macros? answer , appreciated. thank you.

python - Beautifulsoup, unable to compare strings -

i'm trying write web spider gather me links , text. have table i'm working , second cell of each row has number in it, want number, if it's 1 need grab links , text in cell 2&4. everything works fine except can't seem able compare numbers cell list of numbers have. i number using cells[1].get_text() (i create list of cells each row), works fine , type() returns 'class 'str'', make sure convert numbers list string. but when try compare them returns 'false' import bs4 file = open(r"some html file", 'rb') rng_lst = [str(x) x in range(5, 43)] soup = bs4.beautifulsoup(file) table = soup.findall('table')[0] row in table.findall('tr'): cells = row.findall('td') if len(cells) >= 6: check = cells[1].get_text() n in rng_lst: if n == check: # stuff i've tried can think of , 'false', using == or 'is' doesn't work, if

android - Adding a few TextViews on RelativeLayout -

i'm trying programmatically add many textview relativelayout unable when textview reach end of display right next textview inflate in new line. relativelayout: <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/tag_cloud" android:padding="10dp"> </relativelayout> code: if (categoriescursor.movetofirst()){ { textview tagelement = (textview) getlayoutinflater().inflate(r.layout.tag, null); tagelement.settext(categoriescursor.getstring(2)); linearlayout.layoutparams llp = new linearlayout.layoutparams(linearlayout.layoutparams.wrap_content, linearlayout.layoutparams.wrap_content); llp.setmargins(0, 0, pixels, pixels); // llp.setmargins(left, top, right, bottom); tagelement.setlayoutparams(llp);

ruby on rails - Capistrano all of sudden stopped working -

i deploying rails 4.1 code using capistron 2. everything working fine did changes in schedule.rb file whenever i.e. set :output, {:error => 'error.log', :standard => 'cron.log'} to set :output, {:error => 'log/error.log', :standard => 'log/cron.log'} and deployed code , worked fine first time. now when deployed again, firstly faced error during deployment. bundler: command not found: whenever i installed whenever gem separately on production:- gem install whenever -v 0.9.4 now on deploy again, still broken , error is:- executing "cp -- /home/myusername/project/production/shared/assets/manifest-74e7866cd14bb57f565f7e816b8116fd.json /home/myusername/project/production/releases/database.yml/assets_manifest.json failed access ‘/home/myusername/project/production/releases/database.yml/assets_manifest.json [whenever:update_crontab] rolling the 1 thing confused why moving manifest file releases/database.yml/assets_

android studio 1.2 logcat window animation slow -

i've updated android studio 1.2 , have added stupid animation opening , closing logcat tab. adb gets clear every open , close( have checked tools-> androdi -> enable adb integration) very slow opening , closing of tab , gets stuck @ point. there way stop animations? check background process of pc check pc memory & cpu http://tools.android.com/tech-docs/configuration

android - how to display images inside html in mail (gmail app or others) -

i having stuff when displaying content in mail on android device. here case: need send invitation other users app. invitation's content can changed in future, decide make html content server side , send client side (android , ios), client side receive , send invitation other users via email inside device (until gmail). ok on ios device. mean invitation's content displayed html file (include image, color, margin,...). have problem on android device - can not displayed html content. instead of that, display text (no image, no color) . here code intent emailintent = new intent(intent.action_sendto, uri.fromparts("mailto",sender, null)); emailintent.putextra(android.content.intent.extra_subject, subject); emailintent.putextra(intent.extra_text, html.fromhtml(content)); //content: html format context.startactivity(intent.createchooser(emailintent, "send email...")); can give me ideas on case? if impossible on android platform. p

Microstrategy - Bar Chart in a Document does not show all the series -

i have bar chart in document. each bar value of attribute, sadly chart shows @ 5 columns. i cannot find option, in web or desktop, showing 1 bar every value in attribute. how can it? run report produces graph. go graph > graph options > options > general. in second section, scrolling, increase maximum number of series.

JPA Critera Query In Spring -

public product findproductbyid(string id , string subcategoryid) { return em.find(product.class, id); } in method pass 2 parameter. how retrieve record form product table id , subcategoryid? actually retrieve record based on id apply subcategoryid (with , condition) error occour. please send link explain how it's work? thanks. public list findproductidsubcategoryidcategoryid(string categoryid, string subcategoryid,string id) { criteriabuilder cb = em.getcriteriabuilder(); criteriaquery criteria = cb.createquery(product.class); root product = criteria.from(product.class); cb.equal(product.get("subcategoryid"),subcategoryid); predicate csi = cb.and(cb.equal(product.get("categoryid"), categoryid), cb.equal(product.get("subcategoryid"), subcategoryid), cb.equal(product.get("id"), id)); criteria.select(product).where(csi); return em.createquery(cr

angularjs - Angular dynamically assigning object does not bind -

i trying dynamically assign object property value not change. when try $scope[key] = $scope.model[val]; where $scope.model[val] object contains title property {{title}} not show but if set $scope[key] = {"title":"abc"}; works can please me make 1st case work. thanks try following code $scope.key = json.parse($scope.model[val]);

printing - Connect Android device to WiFi printer to take print programatically -

i want print pdf document android phone using wifi printer. far of search 4.4 can able use android printer manager application need support 4.0. please give me suggestion possible connect our device wifi printer or send our document printing. hope, best answer or suggestion side possible. i had used this in 1 of projects so go through , hope idea.it supports bluetooth, wi-fi (infrastructure mode), usb. , supported formats pdf: pdf image: bmp, jpg, png print data: prn

c# - Dynamically update the web config for webservice -

i have few web services have configured in web application. in have set webservices dynamic. can see webservices in web.config file. for example: <applicationsettings> <webinterface.properties.settings> <setting name="webinterface_customercard_customercard_service" serializeas="string"> <value>http://localhost:7047/dynamicsnav/ws/supratechnic%20(m)%20sdn%20bhd/page/customercard</value> </setting> </webinterface.properties.settings> </applicationsettings> in login page need change these webservices dynamically @ runtime , save in web.config @ time of login. how can change in code behind? web.config not right place change because shared among users. application can used several users @ same time change affect many of them instead of one. in secure environment, application not able write web.config anyway , - @panagiotiskanavos points out - writing recycle app pool rig

python - Override the encoding of a single-file generated from a Django template (not an HTML file) in order to {% ssi %} include parts in latin1? -

i have single template needs encoded in latin1 (to stored in file has transmitted legacy system), whereas other templates should render html pages in utf-8 . template includes, trough {% ssi %} tags, dynamic documents come legacy system , encoded in latin1 . if try include documents following error ( here complete traceback ): unicodedecodeerror: 'utf-8' codec can't decode byte 0xe9 in position 6426: invalid continuation byte because of é char in legacy included file. what i've tried far: i'm aware of file_charset setting change encoding, changes html , sql encodings , not viable solution. i've checked django docs seems cannot set either template or context encoding on per-file basis, assumed ' utf-8 ' or whatever file_charset is. searched google & ideas. no luck. i may convert encoding later, eventually, error raises inside template.render() i've have solve on template loading, think do proper way exists? my config

Can I have recursive function call inside parallel streams in java -

i have function model data. if parameter "entity" contains child, enclosed in child names. there 2 types of child type-a & type-b. each type function called recursively. recursive function call exits when child not have more child names. public void modelmydata(entity entity) { if (entity.getchildnames()[0] != null) { arrays.stream(entity.getchildnames()) .collect(collectors.tolist()) .parallelstream() .foreach(childtype -> { entity.getchild(childtype).parallelstream() .foreach(child -> { modelmydata(child); }); ; }); } system.out.println("insert " + entity.getchildattributevalue()); } the program works fine me. use of parallel stream said bad in java programming. visit http://zeroturnaround.com/rebellabs

Using Sublime Text 2 with Python 3 under Windows 8.1 -

i developing plugin sublime text 2 using python. default, sublime text 2 uses python 2, i'd switch python 3. there hints on how (also here on stackoverflow), none of them seem work me. maybe because using windows , there should different here? my python.sublime-build file looks follows: { "path" : "c:/python34", "cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*file \"(...*?)\", line ([0-9]*)", "selector": "source.python" } it not working that. when use following code in plugin: print('python version: ' + sys.version) i result python version: 2.6.5 (r265:79096, mar 19 2010, 18:02:59) [msc v.1500 64 bit (amd64)] now need change? in line cmd , should python3 instead of python ? or python.exe ? put path python3 windows path environment variable (and not 1 python2), still output python 2.6.5 . any more ideas on that? you confus

java - Why this error - Cannot get a connection, pool error Timeout waiting for idle object -

i having webapp on production, runs fine 7-8 days website down , logs reproduce error: java.sql.sqlexception: cannot connection, pool error timeout waiting idle object and operations database starts failing. have read across several other questions , blog not able find definite solution. using connection pool, , not sure problem is. is because of code have written or pool configuration? providing code here 1 of method gets data database , pool configuration. please have , let me know if doing wrong. public cartitem getcustomercartitem(int customerid, int productid, int productofcityid) { connection con = connectionpool.getinstance().getconnection(); preparedstatement st = null; resultset rs = null; cartitem ci = null; cityproduct cityproduct = productservice.getcityproduct(productid, productofcityid); if (cityproduct == null) { return null; } string query = "select ci.* customer_cart_item_mapping cim inner join cart_item ci on

maven - Downloding dependencies from password protected Nexus repository using a local proxy -

i'm using intellij , i'm working jar libraries sitting behind password protected nexus repository. need inspect sources, intellij fails find them because (it seems) doesn't support password protected repos (at least, failed when attempted add using build tools -> maven -> repositories, not asking password). if there workaround? after research learned run local nexus instance on machine set in way proxies corporate nexus... seems overkill. there simple proxy can install? alternatively: if code simple http server forward requests adding http auth headers, work? some clarifications: the projects i'm working using scala/sbt. i've tried adding ivy plugin idea, no success. the password protected repository set in m2/settings.xml (password encrypted using settings-security.xml). maven can use without problems. i've instructed intellij use same settings.xml configuration, didn't work. seems code tries automatically download sources tries nexus re

java - Exception when using @Scheduled spring annotation (Cannot find class [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]) -

i have created scheduled job using @scheduled annotation. looks this: package example.tools.rr; public class requestprocessorjob { private requestservice requestservice; ... @scheduled(fixedrate = 10000) public void process() { ... } public requestservice getrequestservice() { return requestservice; } public void setrequestservice(requestservice requestservice) { this.requestservice = requestservice; } } i've put inside bundle a, can use class in other bundles. imported inside bundle b. b's blueprint.xml looks this: <?xml version="1.0" encoding="utf-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:cm="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium" xmlns:ctx="http://www.springframework.org/schema/context" xmlns:beans="http://www.springframework.org/s

html - Trapezoid div in CSS -

Image
i want sections content in trapezoid div don't know how start or best way achieve goal: i had come across solution there isn't info me understand css3 transform trapezoid html <div class="section"> <p>content here</p> </div> here way create trapzoid div. uses ::before , ::after pseudo elements .example { margin: 20px 0px; position: relative; display: inline-block; width: 200px; height: 200px; background-color: gray; color: white; font-size: 2rem; } .example::before { content: ""; position: absolute; top: -20px; border-top: 20px solid transparent; border-left: 0px solid transparent; border-right: 200px solid gray; border-bottom: 0px solid gray; } .example::after { content: ""; position: absolute; bottom: -20px; border-bottom: 20px solid transparent; border-left: 0px solid transparent; border-right: 200px solid gray; border-

Is a paper-action-dialog supposed to automatically center and scroll with dart-polymer? -

i trying launch modal dialog using paperactiondialog in dart , dialog never centers , doesn't scroll if content longer window. supposed automatically? polymer-only examples come across seem to. have style somehow? here's code i'm using: paperactiondialog m = new paperactiondialog(); m.setattribute("role", "dialog"); m.setattribute("backdrop", "true"); m.autoclosedisabled=true; paperbutton closebutton = new paperbutton(); closebutton.text="close"; closebutton.raised = true; closebutton.setattribute("primary", "true"); closebutton.setattribute("dismissive", "true"); m.children.add(closebutton); m.heading="history"; m.open();

asp.net mvc - How to use Repository and Unit of Work Patterns with ADO.NET? -

i building asp.net mvc 5 application. i read repository , unit of work (uow) patterns here . these examples use entity framework adds high-level of abstraction itself. i using ado.net , not ef. want know: whether repository , uow patterns makes sense ado.net? how repositories , uow ado.net? samples? can add separate class library repository or make part of dal? i've written blog post teaches on how write driver independent code , how implement uow/repository pattern plain ado.net. it's bit long include in answer, idbtransaction represent unit of work (or contained in one) , every repository take transaction or uow in it's constructor. to create command using idbtransaction using (var cmd = transaction.connection.createcommand()) { cmd.transaction = transaction; //do crud operation here. }

android - Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.IllegalArgumentException: Operation is invalid after previous operation -

i have parse integrated in app push notifications. getting lot of crashes on many devices related parse. haven't sent push notifications yet. , using parse sdk 1.8.1. here stack trace - android.app.activitythread.handlereceiver activitythread.java, line 2554 2 android.app.activitythread.access$1700 activitythread.java, line 163 3 android.app.activitythread$h.handlemessage activitythread.java, line 1333 4 android.os.handler.dispatchmessage handler.java, line 102 5 android.os.looper.loop looper.java, line 157 6 android.app.activitythread.main activitythread.java, line 5335 7 java.lang.reflect.method.invokenative 8 java.lang.reflect.method.invoke method.java, line 515 9 com.android.internal.os.zygoteinit$methodandargscaller.run zygoteinit.java, line 1265 10 com.android.internal.os.zygoteinit.main zygoteinit.java, line 1081 11 dalvik.system.nativestart.main caused by: java.lang.illegalargumentexception: operation invalid after previous operation. 1

ruby - Remove duplicated records based on pair of columns? -

i have table folowwing columns: id app_id tag_id created_at updated_at the pair app_id , tag_id should uniq. how remove oldest duplicated records based on updated_at column determine "oldest" , pair (app_id, tag_id) determine "duplicated"? activerecord::base.connection.execute <<-sql delete my_table id in ( select t1.id my_table t1 inner join ( select app_id, tag_id, min(updated_at) oldest my_table group app_id, tag_id ) t2 on t1.app_id = t2.app_id , t1.tag_id = t2.tag_id , t1.updated_at = t2.oldest ) sql replace my_table actual table name.

oracle - "Update Terminated" on /nva01 transaction -

Image
while running sap-sd benchmarking process on 3 tier sap setup, number of transactions fired automated users. following steps executed, 6 /nva01 (create sales order) [enter] 7 order type or sales organization 0001 distribution channel 01 division 01 [enter] 8 sold-to party sdd00000 po number perf500 req.deliv.date 22.12.2009 deliver.plant 0001 material order quantity sd000000 1 sd000001 1 sd000002 1 sd000003 1 sd000004 1 [f11] (save) 9 [f3] (back) (this dialogstep needed 4 dialogsteps va01 defined sd benchmarks) whenever [f11] pressed after entering information saves when [f3} pressed, shows error “unable update” then manually tried execute same steps 6 /nva01 (create sales order) [enter] 7 order type or sales organization 0001 distribution channel

objective c - Error while running my first IOS app on Xcode -

i created new ios project single view app , tried running no codes added, there appears blank black window in ios simulator, , generates below error: "the operation couldn't completed. (mach error -308 -(ipc/mig)server died)" have @ question: swift playground , simulator error (ipc/mig) server died, unable boot ios simulator hopefully too.

ember.js - how use model in emberJS pod structure? -

Image
i use pods structure in ember. want create dataservice , dropdown component. way best? structure based on ember-cli. these did before: this pods structure: code in dropdown/route.js: import ember 'ember'; export default ember.route.extend({ model: function() { var store = this.store; return $.ajax({ url: 'http://.../api/category/categories', //my api url type: 'get' }).then(function(items) { items.foreach(function(item, index, enumerable) { store.push('model',{ id:item.id, name: item.title, value: item.id.tostring() }); }); }); } }); codes in dropdown/model.js: import ember 'ember-data'; export default ember.model.extend({ name: ember.attr('string'), value: ember.attr('string') }); in dropdown page , have error: error: no model found 'model&

php - Cannot access subpage url of subdomain -

i did rewrite rule wildcard subdomain access allow me access countries of list page follows: rewritecond %{http_host} ^(.+)\.mydomain\.net$ rewritecond %{http_host} !^www\.mydomain\.net$ rewritecond %{request_uri} !^.*\.(jpe?g|png|gif|bmp)$ [nc] rewriterule (.*) pages/list.php?country=%1 [l] this working fine. now. rewrite rule access page on domain keep getting referred list page. rewriterule ^ad/([a-za-z0-9-]+)?$ pages/details.php?alias=$1 [nc,l] my end result access eg: http://us.mydomain.net/ad/alias keeps referring me list page. updated rewrite rules(as of 14 may) rewriteengine on <ifmodule mod_headers.c> header set access-control-allow-origin "*" </ifmodule> rewriterule ^cat/([a-za-z0-9-]+)/?$ ?category=$1 [l,qsa,nc] rewritecond %{request_filename} !-f rewritecond %{http_host} ^(.+)\.ibiz

Can I Create config files with namespaces in Yii2 or do I just create a model from my settings table? -

this question using config files configuration or rather saving configurations on settings table on database. configurations change include usernames , passwords apis using. have thought of saving sensitive information config file , other settings database. possible me create config file in @app\config folder , declare global variable $cfg[] can call controllers , views? question withing same question is, security risk use database configuration settings api username , password? if using advanced templates can use param.php or local-param.phpcper management of global parameters can used place want. if these parameters common both frontend backend appropriate indicate in \ common. for storing passwords in database, or conservation in configuration file param purely personal choice. i'm running through files param comfortable. fact of creating database table model, controller, , crud easy yii2 using automatic generator gii. on years found tables of database configura

node.js - how do I access my module in express? -

i install bootstrap with npm install bootstrap --save in express project, bootstrap installed in node_modules , how can access js , css in jade file? node_modules meant use server modules. npm server package management system. you should use client package management system bower client side modules i.e. bootstrap. once set bower , you'll able reference bower_components in html files.

What are the ways to get the data from XML file using C#? -

i want data xml file using c# , need assign data dto. here need consider performance when getting data xml file. used xml deserialization data xml file taking lot of time data large xml files. please suggest me solution considering performance using c#. if xml file huge can use xmlreader . can linq xml option. example: <branch> <node> <mynode> <subnode code=\"0\"> message </subnode> </mynode> </node> </branch> using linq xml var doc = xdocument.parse(xml); var subnode = x in doc.descendants("subnode") select new { code = x.attribute("code").value, msg = x.value.trim() }; foreach (var e in subnode) { }

javascript - Unable to add transition in d3 -

i want add transition effect on vertical bar designed in d3. new d3,i have tried adding transition() method didn't quiet work. code follows- svg.selectall(".bar") .data(data) .enter().append("g") .attr("class", "bar") .append("rect") .attr("rx", barradius) .attr("fill", function(d,i) { var drilledvalue; try { drilledvalue = json.parse(parent.$("#drills").val())[colids[0]]; } catch (e) { } if (typeof drilledvalue !== 'undefined' && drilledvalue.length > 0 && drilledvalue.indexof(d[columns[0]]) !== -1) { return drillshade; } if(typeof chartdata[div]["transpose"] === "undefined" || chartdata[div]["tra

php - Bd consulting wordpress to show the_excerpt(); -

i have following query extract bd wordpress $sql = "select * wp_posts post_content '%".$keywords."%' , post_status = 'publish' , post_type = 'post'"; i store information in array $arr[] = array('id' => $obj->id, 'title' => $obj->post_title); but can extract "the_excerpt();" or the_tags(); query this? i need use ajax live search display results on screen for ajax in wordpress here solution. http://wptheming.com/2013/07/simple-ajax-example/ and data stored in posts, pages, , other custom post types here solution. https://codex.wordpress.org/function_reference/query_posts if find information useful give vote. thanks.

c++ - How do you correctly initialize a struct with a member that is a const pointer to a const value? -

currently i'm doing this: struct foo { const int *const a, *const b, *const c; foo(int a, int b, int c) : a(_a), b(_b), c(_c) { *_a = a; *_b = b; *_c = c; } private: int _a[1], _b[1], _c[1]; }; but there way without putting in second set of pointers ( _a, _b, _c )? but there way without putting in second set of pointers ( _a , _b , _c )? sure. can use: foo(int a, int b, int c) : a(new int(a)), b(new int(b)), c(new int(c)) {} keep in mind the rule of three , implement copy constructor, copy assignment operator , destructor appropriately foo .

Decimal points in python -

i have floating point values, these values dynamically generated: float_a = 12.200 float_b = 14.0 float_c = 14.01880 i want remove decimal point them. expected result "12200" "140" "1401880" i must careful these not fixed-point values , don't have control on how many decimal places input go to. more examples comments: 1.10 1.110 2.0 2.1340 expected result: "110" "1110" "20" "21340" this question seems permutation of question has been answered: the concept of leading zeros display concept, not numerical one. can put infinite number of leading zeros on number without changing value. since it's not numeric concept, it's not stored number. you have decide how many zeros want when convert number string. keep number separately if want. source: python force python keep leading zeros of int variables it looks way asking if initial "float"

javascript - Unable to add the value from dropdown list to end of url -

i'm having trouble trying add value part of dropdown list end of url each value different dropdown list. <!doctype html> <html> <head> <title>task 8</title> </head> <body> <script type="text/javascript"> change(val) { document.staff1.action="http://tl28serv/task7.php?staffid=" + val; } </script> <form id="staffname" action="http://tl28serv/task7.php?staffid=" method="post"> <select id="staff1"> <option value="12">perce trainor</option> <option value="15">chuck norris</option> <option value="23">jane zumba</option> </select> <br/> <input type="submit" name="submit"> </form> </body> </html> you missing function keyword. need call

javascript - How to recognize a previous user/spammer without cookies? -

i admin on chatting website , lot of abusers everyday, disrupting regular chat flow. keep banning ips , keep changing them ip-changer software , proxies. additionally, enter using "private browsing sessions" (this our deduction, because cookie-marking them doesn't work). is there means recognize presence before start nefarious activities? we have javascript (no ajax though) , php5 @ our disposal. have read in detail "browser fingerprinting". sounds promising, incorporates lot of values obtained solely through ajax (screen res, installed fonts etc). i stick standard php5 as possible, , non-ajax javascript may employed if necessary. userbase: 90% windows-based nearly 80% windows 7 on portable devices 10% on xp 10% on windows 8 10% mac os. obviously should implement user registration if isn't there already, email address confirmation or oauth validation. pure php, far can see, there little else can do. can try putting data localst

Why does Haskell point free version of function result in ambiguous type error? -

it turns out in ghc 7.10, compiles fine: mysum xs = foldr (+) 0 xs but this: mysum = foldr (+) 0 results in following error: no instance (foldable t0) arising use of ‘foldr’ type variable ‘t0’ ambiguous relevant bindings include mysum :: t0 integer -> integer (bound @ src/main.hs:37:1) note: there several potential instances: instance foldable (either a) -- defined in ‘data.foldable’ instance foldable data.functor.identity.identity -- defined in ‘data.functor.identity’ instance foldable data.proxy.proxy -- defined in ‘data.foldable’ ...plus 5 others in expression: foldr (+) 0 in equation ‘mysum’: mysum = foldr (+) 0 why happen, , insight that's achieved understanding difference? also, can give function type (that's still generic) make error go away? as usual cases making well-typed function point-free results in type errors unfulfilled typeclass constraints, ultimate cause of monomorphism restriction , enabled default. you can solv

AngularJS client side function? -

i have 2 ng-models form input fields. later in form, display total numeric value of 2 models: {{field1--field2}} this adds 2 fields. i'd capture result , use in couple of other places. best way in angular without using js file? this misuse (or underuse) of angular. angular platform mvvm-style apps, , without backing js - define model , viewmodel - next useless. nevertheless, define variable on scope within view, so: <input ng-model="field1" ng-change="sum = field1 -- field2"> <input ng-model="field2" ng-change="sum = field1 -- field2"> {{sum}} demo

html5 - createObjectURL size limit on Cloud9 server -

i working on using createobjecturl create file blob in cloud9 workspace. function savefile(blob, filename) { var url = window.url || window.webkiturl; var link = document.createelement('a'); console.log("blob saved, , size "+blob.size); link.href = url.createobjecturl(blob); link.download = filename; link.click(); } the console logs blob size correctly. however, found interesting issue. chrome can save file less 4mb throws file not found file on 4mb. , error logs below blob:https%3a//?????-??????.c9.io/688e940f-c94c-4050-a081-466569c8de57 i wondering if has cloud9 server limit? dont know if understand createobjecturl method correctly, think done on client side, , should have nothing server? maybe wrong?

python - How to use nested if inside jinja2 filter -

i writing template file virtual host , dns inside file should change per environment host-name.below problem trying solve: server { listen 80; charset utf-8; server_name "{{ 'a.com if ansible_hostname='p.com' 'b.com' if ansible_hostname= 'd.com' 'z.com' if ansible hostname 'k.com' else 'default.com' }}"; rewrite ^(.*) https://$server_name$1 permanent; } how can achieve thing in template ie: {{ 'a.com' if ansible_hostname='p.com' 'b.com' if ansible_hostname= 'd.com' 'z.com' if ansible hostname 'k.com' else 'default.com' }}" ` i new jinja 2 , have no idea how this. single if else statement working how can use multiple if else statement defining value of variable in file. so after research work able crack down issue.we can {% if ansible_hostname == 'a.com' %} {% set server = 'b.com' %} {% elif ansible_hostna

javascript - jQuery collapsable element implementation -

i'm new jquery , wanted find out if implementation of jquery collapse: $(function () { var collapse = { "body" : $(".collapse-body"), "container" : $(".collapse-container"), "trigger" : $(".trigger"), "show" : $(".is-collapse"), "speed" : 300 }; function iscollapse() { return $(collapse.body).hasclass("is-collapse"); } function iscollapsesingle() { return $(collapse.container).hasclass("collapse-single"); } function collapseshow() { if (iscollapse()) { collapse.show.show(); } }$(document).ready(function(){collapseshow()}); // $(collapse.trigger).click(function (id) { id.preventdefault(); var atv = $(this).attr("href"); $(atv).slidetoggle(collapse.speed); if (iscollapsesingle()) { $(colla

Build DropDown List With JavaScript via XML file -

i have xml structure: <sport id="1" name="soccer"> <category id="257" name="countryname"> <tournament id="11275" uniqueid="722" name="tournament name" uniquetournamentname="tournament name"> <team id="5447831" name="team name" superid="38529" /> </tournament> </category> </sport> and saved soccer.xml, want build dropdown list show soccer -countryname --tournament ---team thanks helps since don't know if have multiple categories, tournament , teams inside 1 sports, assume don't. simple code access in vanilla js xmldoc=loadxmldoc("soccer.xml"); // document name var sports=xmldoc.getelementsbytagname("sports"); (i=0;i<sports.length;i++) { // iterate throught each sports document.write(sports[i].nodename+"<br>"+

javascript - jQuery hover, onhover show another element and move the mouse back -

when on hover red box, grey box show up. if mouse stay on grey box, grey box stays opened. when move mouse grey box red box, want have grey box still opened. grey box closes when mouse not hovered on red or grey box. http://jsfiddle.net/0slhl0xf/ the problem that, when move mouse grey box red box, can't grey stayed show. can please help? please not change structure, understand have box2 wrapped box1 easier, <div id="box1"> <div id="box2"></div> </div> but isn't wanted try. thanks i think can use var timeout; var $box1 = $('#box1'); var $box2 = $('#box2'); $box1.hover(function() { cleartimeout(timeout); $box2.show(); }, function() { timeout = settimeout(function() { $box2.hide(); }, 1000); }); $box2.hover(function() { cleartimeout(timeout); }, function() { timeout = settimeout(function() { $box2.hide(); }, 1000); }); #box1 { width: 40px;

c# - String format numbers to millions, thousands with rounding -

i'm trying format price display, , want display number million (m) or thousands (k) suffix, ever display @ 3 values, rounded down. i found this question close want, doesn't handle rounding (specifically, rounding down) likewise, with question have no control on rounding. sample input/expected output: 1 = 1 10 = 10 100 = 100 1000 = 1k 100000 = 100k 125000 = 125k 125900 = 125k 1000000 = 1m 1250000 = 1.25m 1258000 = 1.25m 10000000 = 10m 10500000 = 10.5m 100000000 = 100m 100100000 = 100m i ever want display 3 values. i can't see how can use "," custom specifier , specify rounding. my initial thinking suggests need use combination of above, math.floor , .tostring() formatting magic, i'm not sure start. can me out? thanks in advance. this should help, combined 1 of formatting techniques in other questions you've linked to. internal long maxthreesignificantdigits(long x) { int = (int)math.log10(x); = math.max(0, -