Posts

Showing posts from September, 2014

c# - How to get hidden value from Form when i try to get value on controller value zero always -

@html.hiddenfor(x =>x.streamid, model.streamid) @html.labelfor(m => m.streamid) <select id="streamlist" name="list" onchange="ddlstream();"> @for (int = 0; < @model.dtforstream.rows.count; i++) { <option value="@model.dtforstream.rows[i][0]">@model.dtforstream.rows[i][1].tostring()</option> } </select> <p><input type="submit" value="create" /></p> function ddlstream() { var k = $("#streamlist").val(); $("#sid").val(k); alert(k); } could try this? $("#streamid").val(int.parse($("#streamlist option:selected").val()));

java - Spring Request mapping with different parameters and one same parameter -

i have spring code there request follows : @requestmapping(method = requestmethod.get, value = { enterpriseliterals.root_url_simple + "storedepartments/search.json", enterpriseliterals.root_url_simple + "storedepartments/search" },params = { "!dealerstoreid" }) public map<string, list<? extends abstractdepartment>> getdepartments( @requestparam(value = "enterpriseid", required = true) string enterpriseid,@requestparam(value = "responsefields", required = false) string responsefields) and request : @requestmapping(method = requestmethod.get, value = { enterpriseliterals.root_url_simple + "storedepartments/search", enterpriseliterals.root_url_simple + "storedepartments/search.json" },params = {"!enterpriseid"}) @responsebody public map<string, list<abstractdepartment>> getdepartmentlistbasedonstoreanddepttype(@requestparam(value = &

simple form - rails submit_tags to different actions -

<%= simple_form_for@equipment, :url => equipments_path, :method => :post |f| %> .... <% if @equipment.id.present? %> <div class="actions"> //todo submit_tag action update </div> <% else %> <div class="actions"> <%= submit_tag "adicionar equipamento" %> </div> <% end %> <% end %> in example have 2 buttons,if object exists have first button , when not exists have second button. second button send request controller equipments#create. how can send request equipments#update in first button ? <%= simple_form_for @equipment |f| %> <div class="actions"> <%= submit_tag(@equipment.persisted? ? "create equipment" : "update equipment") %> </div> <% end %> this short way it. usually use i18n translate these labels. (see: i18n model-specific rails submit button )

javascript - Content Security Policy (CSP) block eval method call -

i using niceditor , in method call eval blocked csp when comment csp code it's working fine. error: call eval() blocked csp nicedit.js:779:36 my csp code scriptsrc: ["'self'", "'unsafe-inline'"] i read here https://developer.chrome.com/extensions/contentsecuritypolicy thanks in advance if need use niceditor contains eval (which not idea in first place), can add following directive: 'unsafe-eval' i really, really , recommend use different editor doesn't rely on eval though. security risk in cases. if need alternative, have @ prosemirror example.

java - not able to open link on index page -

on index page userid , password have given link forgotten password jsp page not able open . on clicking link stays on index page. my authenticationfilter is- package bean; import java.io.ioexception; import javax.servlet.filter; import javax.servlet.filterchain; import javax.servlet.filterconfig; import javax.servlet.servletcontext; import javax.servlet.servletexception; import javax.servlet.servletrequest; import javax.servlet.servletresponse; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpsession; public class authenticationfilter implements filter {private servletcontext context; @override public void init(filterconfig fconfig) throws servletexception { this.context = fconfig.getservletcontext(); this.context.log("authenticationfilter initialized"); } @override public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception,

ios - UITableView with SearchView makes new cells overlap old ones on search -

iam implementing searchview filter data in uitableview. iam able search successfully, issue when uitableview data gets filtered, old cells still exist , filtered ones overlap them giving me messy output. have cleared table source suggested answers on so, still not resolved problem. here iam trying do: filtercontroller void searchfiler_textchanged(object sender, uisearchbartextchangedeventargs e) { if (!string.isnullorempty(e.searchtext)) { pptable.source = null; appdelegate.filteredlist = null; pptable.reloaddata(); filteredmodellist = filter(dupes, e.searchtext); madapter = new peopleplacessource(filteredmodellist, ""); pptable.source = madapter; pptable.reloaddata(); } else { pptable.source = null; madapter = new peopleplacessource(dupes, ""); searchfiler.textchanged += searchfiler_textchanged; madapter.tablerowselected += madapter_tablerows

javascript - Pass object properties by reference with Polymer -

i have polymer <parent-element> contains large js object. within <parent-element> , have n <child-element> both consume large js object. if pass large js object <child-element> property create "deep" copy. // in <parent-element> <div> <child-element id="child1" largeobject="{{largeobject}}"></child-element> <child-element id="child2" largeobject="{{largeobject}}"></child-element> //... </div> which best practice pass element reference? just attach <child-element> programmatically? // in <parent-element> ready: function(){ this.$.child1.largeobject = this.largeobject; } thanks! all happening reference syntax: // in <parent-element> <div> <child-element id="child1" largeobject="{{largeobject}}"></child-element> <child-element id="child2" largeobject="{{larg

javascript - Removing the # from angularJS routing make application stop working -

i tried remove # angular application. i have followed steps in different forum. angularjs routing, remove # url i have set below configuration. $locationprovider.html5mode({ enabled: true, requirebase: false }); <head> <base href="/"> ... </head> the application working expected if give http://localhost/ if try refresh or give complete url http://localhost/mypage/test.html not working routing , giving me 404. working # http://localhost/#/mypage/test.html working fine. i using chrome 51 idea happening?

Facebook app canvas html? -

i have mobile app , created fake facebook app (with heroku), have permissions use graph. i don't need real facebook app , i'm looking way display html website in facebook app, possible ? in facebook developer -> facebook canvas, can set secure canvasurl, don't have https url. any ideas ? for resume : need facebook app have permissions in graph, want display html website.

mysql - How can i insert real time of an event into database using php mysqli? -

i'm trying add datetime check record changes. i'm using datetime datatype in table. `date_added` datetime default '0000-00-00 00:00:00', i use following php built-in function using datetime column in query date("y-m-d h:i:s"); problem function date("y-m-d h:i:s"); giving me 2 different date , time when check in same time on server. localhost result date("y-m-d h:i:s"); == 2016-07-12 13:10:04 server result date("y-m-d h:i:s"); == 2016-07-12 05:08:07 so when use timeago function on date_added column giving me wrong time, mean server time. example add record function return me record added 8 hours ago totally wrong. know how can add real time of event database can show using timeago() function. is there way without change server timezone, because if change timezone showing correct time in same region others? think face same issue. i wanted develop facebook datetime functionality. can 1 guide me ho

css - Javascript animation fade out before video end -

i attempting play video have div fade out 0 opacity @ sixty seconds before completion. issue i'm having in removing of animation on div allows video fade in @ beginning in effect switches off div, (the video). want achieve fadeout @ 60 seconds. hope achieve remove id animation without affecting video playback, add timecode fade out video / (div) 60 seconds before end. may not have not explained see jsfiddle. var callonce = true; function aperture(){ if ((media.duration - media.currenttime) < 60) if (callonce) { sync(); callonce = false; } } function sync(){ "use strict"; var media = document.getelementbyid("media"); media.classlist.add("timecode"); media.classlist.remove("animation"); } setinterval(aperture, 100); jsfiddle: https://jsfiddle.net/oytqq0jb/ your time detection code correct, way you're handling animation wrong. here show sync()

php - Getting similar posts by title? -

i looking @ trying posts contain name , code have half working. pulls through standard posts not sure how show custom post types well. here code in functions.php add_filter( 'posts_where', 'wpse18703_posts_where', 10, 2 ); function wpse18703_posts_where( $where, &$wp_query ) { global $wpdb; if ( $wpse18703_title = $wp_query->get( 'wpse18703_title' ) ) { $where .= ' , ' . $wpdb->posts . '.post_title \'' . esc_sql( $wpdb->esc_like( $wpse18703_title ) ) . '%\''; } return $where; } here code uses function find posts of name. <div class="main-content large-8 medium-8 small-12 columns"> <h2><?php the_title(); ?> news , features</h2> <?php $title = $wp_query->post->post_title; $query = new wp_query( array( 'wpse18703_title' => "$title", 'posts_per_page

matplotlib - Make a spectrogram of existing data in python -

i have data i'd represent spectrogram or heat-map in python 2.7. @ moment, have array of 3 columns (time, channel number , flux), , thousands of rows represent each data point. how able plot data points if want time on x axis, channel number on y axis, , magnitude of flux represented colour? i've looked through fair few questions on here, plus other resources online, , haven't been able apply of answers own situation. ideally i'd want like this , frequency replaced channel , using own data rather generating something.

c++ - AES 256 bit encryption in pdf file -

i working on pdf security , trying encrypt user , owner password using aes 256-bit encryption algo. i have generated these keys (using crypto library) when these keys written in pdf encryption dictionary not seem work. ( acrobat not open file) i have explored itextsharp encryption of pdf file. want decrypt file how idea how itextsharp has done it. unfortunately did not find tool so. file encrypted using itextsharp correctly opened in adobe acrobat . while encrypting keys have use saslprep (ietf rfc 4013) profile of stringprep (ietf rfc 3454). thing want add lib icu can generate saslprep (ietf rfc 4013) profile easily.

ruby on rails - Why is my database info not showing up on Heroku? -

as can see here in rails console have 4 blogs in heroku console have 0. pushed current progress heroku. i'm using postgresql. missing obvious getting information db heroku or have problem elsewhere? $ rails console running via spring preloader in process 28133 loading development environment (rails 4.2.0) irb(main):001:0> blog.all.count (0.4ms) select count(*) "blogs" => 4 $ heroku run console running console on ⬢ morning-lowlands-91946... up, run.4970 loading production environment (rails 4.2.0) irb(main):001:0> blog.all.count (1.2ms) select count(*) "blogs" (1.2ms) select count(*) "blogs" => 0 i missing obvious. yes. heroku based on git. git not track database changes.

C#- Selenium Webdriver, Not able to select radiobutton as a label is displayed over it -

i new selenium webdriver , using c# write script. have field gender having male , female option, these options radio buttons displayed labels. i tried million ways have selected: driver.findelement(by.cssselector("[value='female']")).click(); driver.findelement(by.xpath("//input[contains(@value,'male']")).click(); driver.findelement(by.cssselector("input[type='radio'][value='male']")).click(); driver.findelement (by.xpath ("//input[@value='female']")).click (); but none worked above. html gender fields looks this: <li class="radiobutton-yesno ui-buttonset"> <span class="label"> gender <span class="help-icon" data-title="your gender factor in determining cost."> </span> </span> <input type="radio" id="genderno_1" name="gender_1" value="male&qu

Facebook API webhook - Get informations about shared posts -

i'm working facebook api webhook . currently, can make api call , data relating likes , comments done on post. for example when comment post, receive, facebook api webhook these informations : ( [entry] => array ( [0] => stdclass object ( [changes] => array ( [0] => stdclass object ( [field] => feed [value] => stdclass object ( [parent_id] => ... [sender_name] => ... [comment_id] => ... [sender_id] => .. [item] => comment [verb] => add [created_time] =>

ruby on rails - Reload namespaced constant in initializer -

ran interesting scenario today i'm unsure how resolve. given rails app initializer: file: config/initializers/integrations.rb integrations::configs = { "key" => "value" }.freeze if go bundle exec rails console , ask constant works expected: integrations::configs => {"key"=> "value"} then if use reload! in console, lose constant: [2] pry(main)> reload! reloading... => true [3] pry(main)> integrations::configs nameerror: uninitialized constant integrations::configs (pry):3:in `<main>' if remove namespace , have configs constant works , reloads expected. i've read through of reload! documentation find , can tell isn't expected. my question being, how can correctly use namespaced constant in initializer while still being able use reload! ?

sql - MySQL function IFNULL not working with GROUP BY -

i've got standard table list of users , i've got column lastactivity unix timestamp (which shows when have logged in) , column timestamp unix timestamp shows when have registered. i've build sql query shows how many users active within 24 hours (86400 seconds) , grouped results weeks counter counts how many users have registered each week: select ifnull(count(*),0) `counter`, (week(`timestamp`)) `week` `clients` (cast(unix_timestamp() signed) - cast(`lastactivity` signed)) <= 86400 group week(`timestamp`); the issue function ifnull(count(*),0) not working intended. sql query won't display week if there null / 0 on counter ifnull() mysql function. because of how group by works. example kind of result: counter | week 2 | 11 1 | 13 9 | 14 6 | 17 but show each week this: counter | week 2 | 11 0 | 12 1 | 13 9 | 14 0 | 15 0 | 16 6 | 17 anyone have idea ho

Get the single value from mongodb Collection using java code -

i want single value mongodb collection. currently getting document finditerable. customobject obj = db .getcollection("collection",customobject.class) .find(and(eq("field1", new bigdecimal(10409)),eq("field2", new bigdecimal(1)))); but , dont want result in object or list.like in oracle use query single object : select name employee_table id=10 , dept_id=23; this query gives single name of employee on basis of filter conditions, , output in string type object. same want mongodb , don't want use bean populate data. want single string object result. you may use find method on collection, passing query , fields retrieve: basicdbobject fields = new basicdbobject(); fields.put("name", true); basicdbobject query = new basicdbobject(); query.put("id", 13); query.put("dept_id", 23); dbcursor find = mongotemplate.getcollection("example").find(query, select); list<dbobje

rubygems - dbd-ODBC ruby gem require cannot require -

i have script in ruby, it's simple checking requires work. i've got problem 1 gem: dbd/odbc. when run script error message. version of ruby 2.3. here script: begin require "dbi" require 'dbd/odbc' puts 'this run.' rescue loaderror => e puts "this not run #{e.backtrace.inspect}" end here output error: this not run ["c:/ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/ker nel_require.rb:55:in require'", "c:/ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygem s/core_ext/kernel_require.rb:55:in require'", "c:/ruby23-x64/lib/ruby/gems/2.3. 0/gems/dbd-odbc-0.2.5/lib/dbd/odbc.rb:34:in <top (required)>'", "c:/ruby23-x64/ lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133:in require'", "c:/ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:133: in rescue in require'", "c:/ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core

javascript - Where is redux store saved? -

i looking how secure redux application can be, storing values in redux store i.e. user token etc.. , tried see if else gain access them via xss attack example, checked sessionstorage, localstorage, cookies , not there, not inside app.js file (my bundle file), hence question. from part of documentation ( http://redux.js.org/docs/faq.html#performance-state-memory ) deduce it's stored in memory, not persistent.

jquery - Replace main menu's first and second items A element with SPAN -

my solution below working: $('#main-menu > ul > li:nth-child(1) a, #main-menu > ul > li:nth-child(2) a').replacewith(function() { return '<span>' + $(this).text() + '</span>' }); it replaces <a> <span> replaces submenus elements also. don't want that. here's example jsfiddle you need add > before <a> using way #main-menu > ul > li:nth-child(1) a means <a> in <li> . adding > restrict 2 first child only. $('#main-menu > ul > li:nth-child(1) > a,#main-menu > ul > li:nth-child(2) > a').replacewith(function() { return '<span>' + $(this).text() + '</span>' }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="main-menu"> <ul> <li><a href="#">item1</a></li> <li>

scala - Stack overflow error when loading a large table from mongodb to spark -

all, have table 1tb in mongodb. tried load in spark using mongo connector keep getting stack overflow after 18 minutes executing. java.lang.stackoverflowerror: @ scala.collection.traversablelike$$anonfun$filter$1.apply(traversablelike.scala:264) @ scala.collection.maplike$mappedvalues$$anonfun$foreach$3.apply(maplike.scala:245) @ scala.collection.maplike$mappedvalues$$anonfun$foreach$3.apply(maplike.scala:245) @ scala.collection.traversablelike$withfilter$$anonfun$foreach$1.apply(traversablelike.scala:772) .... @ scala.collection.maplike$mappedvalues$$anonfun$foreach$3.apply(maplike.scala:245) @ scala.collection.maplike$mappedvalues$$anonfun$foreach$3.apply(maplike.scala:245) @ scala.collection.traversablelike$withfilter$$anonfun$foreach$1.apply(traversablelike.scala:772) 16/06/29 08:42:22 info yarnallocator: driver requested total number of 54692 executor(s). 16/06/29 08:42:22 info yarnallocator: request 46501 executor containers, each 4 cores , 5068 mb memory including 460 m

ruby - ElasticSearch SearchKick multiple aggs with options in same query -

in searchkick documentation there 2 ways/styles of requesting aggs mentioned. for simple (multiple) agg requests: products = product.search "chuck taylor", aggs: [:product_type, :gender, :brand] and agg requests options: product.search "wingtips", aggs: {size: {where: {color: "brandy"}}} my question - how go declaring multiple aggs options? we've tried various combinations of 2 without success... for example - doesn't work... products = product.search "chuck taylor", aggs: [:product_type, {size: {where: {color: "brandy"}}}] is ruby formatting problem? or limitation in gem? thanks guys! for looking answer: you can do: products = product.search "chuck taylor", aggs: {product_type: {}, size: {where: {color: "brandy"}}} https://github.com/ankane/searchkick/issues/689

angularjs - Trying to add ng-app name does not give expected output in Application -

Image
i trying add ng-app tag in sample angularjs application. whenever try add name ng-app="myapplication" , web page stops working. supposed print name entered in entry box after hello shown below. the sample code : <!doctype html> <html lang="en" > <head> <meta charset="utf-8"> <title>first app</title> <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body ng-app="myapplication"> <h1>sample ajs</h1> <div > <p>enter name : <input type="text" ng-model="name"></p> <p>hello <span ng-bind = "name"></span> !</p> </div> </body> </html> if replace ng-app="myapplication" ng-app="" , gives expected output. i tried using ng-app <div ng-app="myappl

fortran - forrtl: severe(151) allocatable array already allocated -

i have used code given in answer netcdf fortran array allocation @ run time run time error when run code forrtl : severe(151) allocatable array allocated when recompile -g , -traceback error traced line allocate(lats(latlen)) can memory modified @ runtime? using fortran , compiler ifort . here code integer retval,reason,i,in_ndim,ierr integer ncid, lat_dimid,lat_varid, latlen integer lon_varid,lonlen character*(*) lat_name, lon_name parameter (lat_name='lat', lon_name='lon') real lats[allocatable](:) real lons[allocatable](:) call system('ls hgt_*.nc > hgtfiles.txt') open(10,file='hgtfiles.txt',action="read") varname = "hgt" read(10,*,iostat=reason) in_cfn if (reason/=0) exit print *,in_cfn retval = nf_open(in_cfn,nf_nowrite,ncid) if (retval .ne. nf_noerr) call handle_err(retval) retval = nf_inq_dimid(ncid,lat_name,lat_dimid) if (retval .ne. nf_noerr

javascript - remove first element from array and return the the array minus the first element -

var myarray = ["item 1", "item 2", "item 3", "item 4"]; //removes first element of array, , returns element. alert(myarray.shift()); //alerts "item 1" //removes last element of array, , returns element. alert(myarray.pop()); //alerts "item 4" how remove first array return array minus first element in example should "item 2", "item 3", "item 4" when remove first element this should remove first element, , can return remaining: var myarray = ["item 1", "item 2", "item 3", "item 4"]; myarray.shift(); alert(myarray); as others have suggested, use slice(1); var myarray = ["item 1", "item 2", "item 3", "item 4"]; alert(myarray.slice(1));

is it possible to split screen in vim/vi with terminal -

is there way split screen inside vi/vim 1 screen terminal? p.s solutions of installing new text editors , such wont me there's no way without plugin. here couple of ways similar functionality. use tmux, or terminal window manager. in response p.s., tmux not text editor. allows split terminal screen, still using vim text editing. you can run terminal commands , view output inside vim. run command, preface exclamation point. example, if run :!ls within vim, see list of files in current directory. other commands such :!pwd or :!git add * work. if want read output of command current vim buffer can use read command. example, if run :read !ls vim enter list of files in current directory current buffer @ cursor position.

node.js - Mongoose not returning full dataset -

i have model set so: var post = mongoose.schema({ "_uid": string, "post_title": string, "post_content": string, "post_date": date, "user": string, "slug": string, "attached_media": [[ { "format": string, "type": string, "small": string, "medium": string, "large": string } ]], "likes_count": number, "likes": [ {.... the key part of attached_media array, whenever use .find({}) command mongoose none of array elements return data inside them. data inside them when use mongo command shell see arrays populated. my find method: post.statics.getall = function getall(next){ this.find({}) .sort({'post_date':'desc'}) .exec(function(err, doc){ if(err) console.log(err) next(null, doc)

Batch Script to check Windows 7 Activation -

i trying batch script check activation status of workstations of lan, far have following code saves .txt status of activation. @echo off cscript /nologo c:\windows\system32\slmgr.vbs /xpr > activatedstatus.txt | findstr /i /c:" expire "> nul 2>&1 if [%errorlevel%]==[0] (echo not permanently activated.) else (echo permanently activated) exit /b an output activatedstatus.txt looks this: windows(r) 7, professional edition: machine permanently activated. what want create .txt if workstation not activated can't work if statements. by both attempting both redirect , pipe on same command line, you're redirecting, nothing being feed findstr . so, you'll either need pipe data along: cscript /nologo c:\windows\system32\slmgr.vbs /xpr | findstr /i /c:" expire "> nul 2>&1 or, if want create text file, need create first, pipe it's data findstr : cscript /nologo c:\windows\system32\slmgr.vbs /xpr > activatedsta

mysql - Update row using equation with 2 rows? PHP Mysqli -

i need update row doing subtractions e.g t1.n1=t1.n1-t2.n2 i tried this update table1, table2 set table1.field1 = table2.field1 table1.id = table2.id , triggers i have no idea how ? in advance

c# - Reading Selected multiple text files using openfiledialogue in win form app -

i have condition want reading selected multiples text file through openfiledialogue in win form application i solved want do openfiledialog1.filter = "*.txt"; openfiledialog1.title = "select text file"; openfiledialog1.multiselect = true; dialogresult dr = this.openfiledialog1.showdialog(); if (dr == system.windows.forms.dialogresult.ok) { list<string> link_list = new list<string>(); foreach (string file in openfiledialog1.filenames) { string[] = system.io.file.readalllines(file); (int = 0; < a.length; i++) { link_list.add(a[i].tostring()); } } alllinks = link_list.toarray(); } thanks

ios - Can't insert object in the array, that I want add to User Defaults -

i have initialization of array var defaults = nsuserdefaults.standarduserdefaults() var initobject: [cpaymentinfo]? = defaults.objectforkey("paymentdata") as? [cpaymentinfo] if initobject == nil { initobject = [cpaymentinfo]() defaults.setvalue(initobject, forkey: "paymentdata") } defaults.synchronize() and have controller, contains 2 text labels , 2 buttons: save , cancel (both calling segue) if sender as? uibarbuttonitem == savebutton { var defaults = nsuserdefaults.standarduserdefaults() var payments: [cpaymentinfo]? = defaults.objectforkey("paymentdata") as? [cpaymentinfo] var newpaymentitem: cpaymentinfo? if discriptionfield.hastext() { newpaymentitem = cpaymentinfo(value: (valuefield.text nsstring).doublevalue, discription: discriptionfield.text) } else { newpaymentitem = cpaymentinfo(value: (valuefield.text nsstring).doublevalue)

How to save server response which is in xml format into String variable in android? -

this question has answer here: quickest way convert xml json in java [closed] 6 answers i have app in have send string request server , server sending me response in xml format.how can read response ans save in string variable , convert json. server reponding reponse like:- <response> <st-code>0</st-code> <st-desc>transaction successful</st-desc> <st-no>xxxxxx</st-no> <st-tno>111111</st-tno> <st-optno>xxxxxxxxx</st-optno> download following library java-json add library /libs of project now import required libraries import org.json.jsonexception; import org.json.jsonobject; import org.json.xml; now use following code convert xml string json samplexml = "";//xml string convert json jsonobject jsonobj = null; try { jsonobj = xml.tojsonobject(samplexml); } catch (j

php - set config params from database in yii 1 -

i have created crud global configuration parameters. want apply parameters value main config params (main.php). have found way add value of these parameters .inc file , perform read/write operation. can me how can achieve this? beginner in yii. i have created table structure : global_config : field | value pagesize | 20 admin_email| admin@example.com main.php file below : . . { 'params' = array( 'pagesize' => 10, 'admin_email' => 'admin@example.com', ); } . . i using config file show above, want change dynamically should value database. so can make changes in config file front-end side. don't need perform open/write action on main.php in yii1 can use params can set in main.php 'params'=>array( 'your_param'=>'your_value ', ... yii::app()->params['your_param']; and can set value simple array poplulating value form database $param['yuor_param

.net - Substring - argument out of range exception - startIndex parameter -

assume have following string in textbox1: fpo100200%10&ford* now, have 2 more textboxes gets data substrings of textbox1. have following code: public class form1 private function textmoves(mytext string, indexchar string) dim index integer = mytext.indexof(indexchar) return index end function private sub splittext() dim text string = textbox1.text textbox2.text = text.substring(0, textmoves(text, "%")) textbox3.text = text.substring(textmoves(text, "%"), textmoves(text, "&")) end sub private sub button1_click(sender object, e eventargs) handles button1.click splittext() end sub end class im trying in texbox2 substring fpo100200, in texbox3 substring 10. as added line textbox3, threw me argument out of range error. can tell me im doing wrong? alot! le: also, how can make textboxes populate data when text changed in textbox1, automatically, without pressing button? second parameter length, not end pos

ruby on rails - display braintree errors on fail -

hi trying braintree account display errors when creating transaction doesn't appear working - flash.each |key, value| %div{:class => "alert alert-#{key}"}= value def update result = braintree::transaction.sale( :amount => params[:amount_to_add].to_f, # :order_id => "order id", :customer_id => customer.customer_cim_id, :tax_amount => (params[:amount_to_add].to_f / 11).round(2), :options => { :submit_for_settlement => true } ) if result.success? logger.info "added #{params[:amount_to_add].to_f} #{customer.first_name} #{customer.last_name} (#{customer.customer_cim_id})" customer.store_credit.add_credit(params[:amount_to_add].to_f) redirect_to myaccount_store_credit_path # , :notice => "successfully updated store credit." else result.errors.each |error| puts error.message customer

ios - Uicollectionview weird gap -

Image
i have collection view custom flow layout , wonder why have space (right side): it may hard notice here, though, may see gray gap between right side , cell. here how override standard collection view flow layout remove horizontals gaps: @implementation calendarflowlayout - (nsarray *) layoutattributesforelementsinrect:(cgrect)rect { nsarray *answer = [super layoutattributesforelementsinrect:rect]; nslog(@"layout blck passed"); for(int = 1; < [answer count]; ++i) { uicollectionviewlayoutattributes *currentlayoutattributes = answer[i]; uicollectionviewlayoutattributes *prevlayoutattributes = answer[i - 1]; nsinteger maximumspacing = 0; nsinteger origin = cgrectgetmaxx(prevlayoutattributes.frame); if(origin + maximumspacing + currentlayoutattributes.frame.size.width < self.collectionviewcontentsize.width) { cgrect frame = currentlayoutattributes.frame; frame.origin.x = origin + maximu

node.js - Node JS Set Up in Visual Studio Team Services (was VS Online) -

i have app in vs (pure html). in pre-build script, cd $(projectdir) @powershell set-executionpolicy -executionpolicy unrestricted; @powershell iex ((new-object net.webclient).downloadstring('https://chocolatey.org/install.ps1')) @powershell set-executionpolicy -executionpolicy unrestricted; @powershell choco install nodejs call npm install call grunt taskscripts its fail, while execute node install. help me resolve this. thanks. if using vnext build, can add npm task in build definition install node: https://msdn.microsoft.com/en-us/library/vs/alm/build/steps/package/npm-install

inheritance - polymorphism vs inheritence as the pillars of oop -

as stated here https://standardofnorms.wordpress.com/2012/09/02/4-pillars-of-object-oriented-programming/ and correct answer in many job interviews - general correct answer question: "what 4 pillars of oop?" is: abstraction encapsulation inheritance polymorphism what fail understand how inheritance not contained in polymorphism? in other words, how can polymorphism used without use of inheritance? the way know of using polymorphism is class a{ virtual void foo(){cout<<"a";} void bar(){cout<<"a";} }; class b : public a{ virtual foo(){cout<<"b";} }; a* ab = new b(); ab->foo();//prints b, using polymorphism ab->bar();//prints a, using inheritance a* = new a(); a->foo();//prints a->bar();//prints a, as see it, polymorphism brings inheritance. please explain why distinct - or why can't inheritance discarded key pillar of own. use polymorphism or not. what fail under

javascript - jQuery Ajax Post.settings vs Get.settings -

i'm trying build mini plug-in.therefore, want minimize code , make stable as be. problem clear observe on code, see below ( detailed explanation below snippet segment): $(document).ajaxsend(function (event, xhr, settings) { alert("settings data : " + settings.data + " , " + "settings url : " + settings.url ); }); $("#topleftbutton").click(function () { var arr = { "loadingbar": '#topleftload' } $.ajax({ type: "get", url: "testb.xml", data: json.stringify(arr), datatype: "xml", success: function (xml) {

python - Decompressing a text file -

so have compressed text need decompress able recreate text. the compression : import zlib, base64 text = raw_input("enter sentence: ")#asks user input text text = text.split()#splits sentence uniquewords = [] #creates empty array word in text: #loop following if word not in uniquewords: #if word not in uniquewords uniquewords.append(word) #it adds word empty array positions = [uniquewords.index(word) word in text] #finds positions of each uniqueword positions2 = [x+1 x in positions] #adds 1 each position print ("the uniquewords , positions of words are: ") #prints uniquewords , positions print uniquewords print positions2 file = open('task3file.txt', 'w') file.write('\n'.join(uniquewords))#adds uniquewords file file.write('\n') file.write('\n'.join([str(p) p in positions2])) file.close() file = open('compressedtext.txt', 'w') text = ', '.join(text) compression = base64.b6

git - How do I update my local from Bitbucket -

Image
i using bitbucket our first few projects , unsure of how latest changes server. using team foundation server have been easy : i have repo on local , has made changes on main branch , pushed them server. how sync changes pc? made changes last night , made changes today , want sync changes made today local version. when use sync button suggested below brings me , when click "fetch" button nothing happens

Restcomm Media Player fail to paly file on S3 with error 312 -

Image
i have file on aws s3 public: https://s3-eu-west-1.amazonaws.com/voxist-greetings/33631222504/33651291239_95113eed-386b-4264-a4cf-46182faae125coucou1.wav now when rvd try play get: info [org.mobicents.servlet.restcomm.interpreter.voiceinterpreter] (restcomm-akka.actor.default-dispatcher-8586) mediagroupresponse, succeeded: false jain.protocol.ip.mgcp.jainipmgcpexception: ivr request failed following error code 312 i don't know why... same file used work name. thanks hint on how debug this. the problem seems happen on media server side. more specifically, seems file cannot opened reason. relevant code line can found here . can please take tcpdump , share it, can see mgcp play request? hope helps. update: here example: the 200 ok indicates mgcp transaction completed successfully. need dissect notification (ntfy) sent media server restcomm, observedevents parameter. if @ picture, see event triggered operationfailed (of) returncode (rc) equal 312,

python - history file -

i have project i'm making text browser , need help i have history file every url , time, put in history file like: www.youtube.com 2016-06-29 13:47:15.986000 www.youtube.com 2016-06-29 13:47:22.416000 www.youtube.com 2016-06-29 13:47:31.962000 www.youtube.com 2016-06-29 13:47:40.713000 www.youtube.com 2016-06-29 13:47:49.193000 i need make remove func gets url, , removes lines (the lines separated "\n") this code of history file: def update_history(url): thistime = str(datetime.datetime.now()) urlat = url + " " + thistime history = open("somthing.txt" , "w") history.write(urlat) history.write("\n") please my, it's tomorrow! if trying delete lines file, try this: import os def removeurl(url): url_file = "url.txt" filein = open(url_file, 'r') fileout = open("temp.txt", 'w') line in filein: if

c# - Richtextbox prepend new text with color -

i have used richtextbox display logs in winforms. language used c#. the software used inserting data of bank branches , after start of new branch want display text new color. i have seen link color different parts of richtextbox string , implemeted successfully. my problem want prepend new line instead of append. new line displayed on top. i able changing code box.text=datetime.now.tostring("dd-mm-yyyy-hh-mm-ss") + ": " + text + box.text but color changing entire text. this procedure used append box.selectionstart = box.textlength; box.selectionlength = 0; box.selectioncolor = color; box.appendtext(datetime.now.tostring("dd-mm-yyyy-hh-mm-ss") + ": " + text); box.selectioncolor = box.forecolor; this have done: box.text=datetime.now.tostring("dd-mm-yyyy-hh-mm-ss") + ": " + text + box.text; box.selectionstart = 0; box.selectionlengt

scala - Is it possible to use cake pattern based DI for components provided by Play framework? -

i have seen couple of posts related di using cake pattern. one of them being http://jonasboner.com/real-world-scala-dependency-injection-di/ shared 1 of colleagues. but if need use wsclient play 2.5, can hold of without resorting guice? yes, scala allows solely based on language constructs, without using external di frameworks such guice. illustrate this, consider following example (this example borrows heavily jonas bonér blog-post linked in question): package di.example import play.api.libs.ws.wsclient trait wsclientcomponent { val wsclient: wsclient } notificationservice service wsclient injected. package di.example trait notificationservicecomponent {this: wsclientcomponent => val notificationservice: notificationservice class notificationservice{ def getnotifications = wsclient.url("some-url") } } next, componentregistry "module" object wire our dependencies together. package di.example import play.api.libs.ws

java - CMUSphinx merge multiple dictionary into single one? -

im working on cmusphinx speech text, need train/add words dictionary, used lmtool , uploaded corpus file , used .dict , .lm file , used these parameters pocketsphinx , worked. im wondering how add these files default files. i.e want add new words .dict , .lm files /edu/cmu/sphinx/models/en-us/cmudict-en-us.dict , /edu/cmu/sphinx/models/en-us/en-us.lm.bin im not sure, if feasible , im wondering how combine dictionaries single one. found link not sure how achieve same. when use transcriberdemo.java wav file has different words , output prints different. how improve accuracy ? dictionary , language model extension covered in following part of tutorial http://cmusphinx.sourceforge.net/wiki/tutoriallmadvanced

java - Pigeonhole principle in Algorithm problems -

i reading editorial problem on codefoces still not able understand beacuse using pigeonhole principle , not getting how apply pigeonhole priniciple on problem here's problem editorial: in problem use septimal number system. important limitation. let's count how many digits showed on watch display , call cnt. if cnt more 7, answer 0 (because of pigeonhole principle). if cnt not greater 7, can bruteforces cases. here' problem statement http://codeforces.com/contest/686/problem/c robbers, attacked gerda's cab, successful in covering kingdom police. make goal of catching them harder, use own watches. first, know kingdom police bad @ math, robbers use positional numeral system base 7. second, divide 1 day in n hours, , each hour in m minutes. personal watches of each robber divided in 2 parts: first of them has smallest possible number of places necessary display integer 0 n - 1, while second has smallest possible number of places necessary display integer 0 m 

c# - Request / Respond web service -

i'm new web services use little help. i have project web service request data me , respond web service giving data. i've created response web service can see below: person.cs using system.collections.generic; using system.linq; using system.web; namespace testwebservices { public class person { public string idno { get; set; } public string firstname { get; set; } public string lastname { get; set; } } } [webmethod] [webmethod(description = "return applicants")] publicperson[] retapplicants(string idno) { string connstring = configurationmanager.connectionstrings["conn"].connectionstring; sqlconnection connection = new sqlconnection(connstring); sqlcommand command = new sqlcommand("selectapplicant", connection); command.commandtype = system.data.commandtype.storedprocedure; command.parameters.add("@idno", sqldbtype.varchar).value

google app engine - Using Stackdriver debug for non-Java JVM languages -

the stackdriver debug interface complains when have non-java file in source (such groovy file). the way debugger works matches filename , line number sourcefile , linenumber attributes included in class file, i'm not sure why support non-java source files disabled. did have luck "tricking" interface accepting non-java files (e.g. renaming them), or have information whether google planning add support? this limitation hardcoded in stackdriver debugger java agent. see https://github.com/googlecloudplatform/cloud-debug-java/blob/master/src/agent/internals/src/main/java/com/google/devtools/cdbg/debuglets/java/classpathlookup.java#l186 the reason limitation agent built java. understands java conditions , expressions (and doesn't understand other languages expressions). agent can modified handle other jvm languages relatively few changes. however, file:lines match info in class files , expressions parser modified match target lanuage.

Find all the stored Procedures that use a cursor in SQL Server using Query -

is possible list out stored procedures uses cursor in sql server using sql query. please advise me. select * sys.sql_modules definition '%cursor %' if looking open cursors ,you can use query: select creation_time, cursor_id, name, c.session_id, login_name sys.dm_exec_cursors(0) c join sys.dm_exec_sessions s on c.session_id = s.session_id

css - Responsive images using img vs background -

i've been working on adding animated hover effect , have worked out solution using img , background image can viewed here . background image better read using img better screen readers , search engines per article . the issue i'm having when testing responsiveness img solution looks warped when compressed col-xs-6 while background solution doesn't. img css using: .hovereffect img { width: 150%; height: 100%; } now i've tried using height:auto pic doesn't fill full height, want do. there anyway maintain img proportions when scales down?

html - Efficiency when loading JavaScript -

i keep efficiency , performance first priority... so have question in mind...which 1 load faster. case 1: a 1000 line code in single file placed @ bottom of body tag. case 2: the same 1000 line code divided separate files like. file 1 - 200 lines. file 2 - 200 lines. file 3 - 200 lines. file 4 - 200 lines. file 5 - 200 lines. case 1 more faster. on every new file, browser request server it's additional time (about 200ms). if using 1 single file, it's more efficient, because browser 1 request server. more information speeding web sites in this article .

access vba - Global Variable Lookup -

hopefully, i'll make question precise , understandable possible - you'll tell me if don't ! in advance. firstly, little background , i've found work, on small change cannot work. rather use whole code, i've used snippets should give enough information understand have initiated things correctly first. i use menu system (a turbo-charged version of original ms one) has additional fields store information needed make changes depending upon wording user wants use, may name field product, whereas user may want call goods or items or stuff or whatever desires! store user preferences in separate table (we'll call tblwords). when menu populated (remember operates in similar fashion standard switchboard) data fields: itemtext, command & argument menu displays text itemtext, use. but, have added new field called caption in switchboard table because vba code not allow formatting labels want them. so, when vba code reads itemtext label, recordset, , encounters