Posts

Showing posts from September, 2013

mysql - N+1 query with rails polymorphic association -

i have 2 models. album class album < activerecord::base has_one :post, as: :post_module, dependent: :destroy end post (which has title attribute) class post < activerecord::base belongs_to :post_module, polymorphic: true end and here template <% @albums.each |album| %> <tr> <td> <%= link_to album.post.title, edit_admin_album_path(album) %>&nbsp;<br/> </td> </tr> <% end %> i tried use :includes , :references avoid n + 1 query. def index @albums = album.includes(:post).references(:post).to_a end but seems n + 1 query still occurs. what's wrong this? sql (0.2ms) select `albums`.`id` t0_r0, `albums`.`product_num` t0_r1, `albums`.`created_at` t0_r2, `albums`.`updated_at` t0_r3, `posts`.`id` t1_r0, `posts`.`title` t1_r1, `posts`.`date` t1_r2, `posts`.`post_module_id` t1_r3, `posts`.`post_module_type` t1_r4, `posts`.`created_at` t1_r5, `posts`.`updated_at` t1_r6 `albums` lef...

jquery - Error: view.hlp(...) is not a function in jsrender -

i using jsrender map templates in grid. calling method inside jsrender if condition below, @section scripts{ $.views.helpers({ ismobile: function () { return ("@ismobiledevice" == "false" && (window.innerwidth < 1200)); } }); } <script type="text/x-jsrender"> {{if ~ismobile()}} <li class="show">show</li> {{/if}} </script> but getting error: view.hlp(...) not function. whats wrong here ? it's difficult when post razor code. need show code loaded browser, not server code, since question client-side jsrender. it seems ismobile helper not function. perhaps helper definition code not getting loaded in browser before running template rendering code - or there issue/bug in server code ismobile helper registered in browser, not function.

xcode - Why is my iOS build removed from the iTunes Connect Build section after processing? -

Image
i have uploaded 3 builds version 2.3 when upload new build in itunes connect build section shows time in first image. after time, refresh page , remove build in second image. now should do? while upload build, may see upload process indicator may start beginning times. may due sort failure in uploading. there times success message, build upload not successful. in may try upload build again.

how to hide particular column when insert new record in kendo grid -

hey hi try insert new record using kendo grid. it's work fine. want set hide , show. when new hide second column. on row not other all. here code:- <!doctype html> <html> <head> <link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.common.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2012.3.1315/styles/kendo.default.min.css" rel="stylesheet" type="text/css" /> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script src="http://cdn.kendostatic.com/2012.3.1315/js/kendo.all.min.js"></script> <script> $(document).ready(function () { var users = [{ userid: 1, username: "robin", isadmin: true } , { userid: 2, username: "hood", isadmin: false }]; var t = $("#grid").kendogrid({ datasource: { da...

javascript - Alert message when there is duplicate email -

i need show alert message when there duplicate email address. here code: $.validator.addmethod("contactpersonen-email", function(value, element) { var parentform = $(element).closest('form'); var timerepeated = 0; if (value != '') { $(parentform.find(':text')).each(function () { if ($(this).val() === value) { timerepeated++; } }); } return timerepeated === 1 || timerepeated === 0; alert('duplicate'); }, "email adres bestaat al"); but doesn't work. find out problem , make working? $.validator.addmethod("contactpersonen-email", function(value, element) { var parentform = $(element).closest('form'); var timerepeated = 0; if (value != '') { $(parentform.find(':text')).each(function () { if ($(this).val() === value) { timerepeated++; } })...

android - RealmObject is not valid, so it cannot be copied -

why code triggering a java.lang.illegalargumentexception: realmobject not valid, cannot copied error? realm.begintransaction(); realm.delete(booking.class); final booking booking = realm.copyfromrealm( new booking( editfragment.getdestination(), editfragment.getdate())); realm.committransaction(); however, if change exception not thrown: realm.delete(booking.class); final booking booking = realm.createobject( booking.class, uuid.randomuuid().tostring()); booking.setdestination(editfragment.getdestination()); booking.setdate(editfragment.getdate()); what difference? the booking class defined as: public class booking extends realmobject { @required @primarykey private string id; @required private string destination; @required private date date; private int status; private boolean isnotified; public booking() { this.id = uuid.randomuuid().tostring(); this.status = status_unavailab...

html - On mouse hover list did not display -

i have following html dynamically generated. goal display dropdown list links in tag #level2, when mouse on corresponding parent li tag. <div id="level1" style="position: relative; display: inline-block;"> <li id="0" style="height: 30px; min-width: 190px; list-style: outside none none; border: 1px solid rgb(125, 153, 202); text-align: left; padding: 5%; margin-left: 10px; margin-right: 2%; border-radius: 1px; font-size: 12px; font-weight: bold; color: rgb(255, 255, 255); background-color: rgb(96, 96, 96);"> o operating system ▸</li> <div id="level2" style="display: none; position: absolute; min-width: 160px;"> <a href="#" style="display: block; padding: 12px 16px; color: blue;">introduction </a> <a href="#" style="display: block; padding: 12px 16px; color: blue;">synchronization</a> <...

prolog - unexpected error "! segmentation violation" -

recently , when try compile project , unexpected error has appeared , error : % execution aborted % source_info | ?- ! segmentation violation is there explanation happens! this looks bug in sicstus prolog (unless prolog code loads own c code). reinstalling not help. please send relevant information (exact sicstus version , os version) , preferably way reproduce problem, sicstus support email address. also, try in latest version, i.e. 4.3.2. a reproducer works without using spider easiest work with. (i 1 of sicstus developers)

android - How do I obtain data from Firebase database without an event being triggered? -

i'm creating app school project , have issues getting data firebase database. have data stored in database need retrieve. however, in guide seem find information on how data when event triggered. want data retrieved automatically e.g. when open homescreen of app or when scroll down window update homescreen. it possible there explanation in guide, if so, have not been able grasp it. thorough description of solution appreciated! regards, andreas due asynchronous nature of firebase possible way retrieve data. when make request firebase, data isn't instantly available. when data becomes available, firebase trigger event , pass data. unfortunately there no way around this. people deal showing sort of activity indicator until data has been retrieved. i hope answers question!

Find last occurence of a string using findstr on windows command line -

i have text file string occurs multiple lines. want line last occurrence of string. find occurrences using below command want last occurrence in single line command. findstr /c:"apple ball cat" book.txt can guide me if possible? for command command line: (for /f "delims=" %g in ('findstr /c:"apple ball cat" book.txt') @set "lastoccur=%g")&set lastoccur from batch script: @echo off set "lastoccur=" /f "delims=" %%g in ('findstr /c:"apple ball cat" book.txt') set "lastoccur=%%g" set lastoccur echo "%lastoccur%" in echo command (possible, supposed) cmd -poisonous characters escaped using double quotes .

java - ANTLR mismatched input expecting ID -

i still working on same haskell based grammar in case saw previous post. of errors gone have problem. my grammar follows know large , tedious thing read need final i'm sorry , appreciate @ all: (a lot of logic missing these rules required) grammar t; options { language=java; backtrack=true; } tokens{ num = 'num'; list = 'list'; = 'even'; odd = 'odd'; twice = 'twice'; head = 'head'; tail = 'tail'; length = 'length'; max = 'max'; rev = 'reverse'; inc = 'incall'; sort = 'sort'; keep = 'keep'; drop = 'drop'; poly = 'poly'; } @header { import java.util.hashtable; import java.util.arraylist; } @members { hashtable <string, integer> intmemory= new hashtable<string, integer>(); hashtable <string, arraylist> listmemory= new hashtable <string, arraylist>(); } prog: stat+ ; stat: numdecl ';' //declares variable co...

How can I tell Visual Studio 2010 to create classes in selected folder, not in root? -

Image
typical scenario. want add class in project in specific folder: i enter parameters: and class appears here: and located in project root on disk. src folder on image same 1 one on first screenshot: when asked colleague how deals it, told me uses qtcreator create empty classes. come on, there other way running 2 ides, right? don't use class wizard create class file. right click on folder want add class file.click on add new item. type in class name. class file should created in intended folder.

c# - Eliminate Special Characters in GnuPG Encryption -

is there way eliminate special characters when encrypting gnupg . got below issue. when encrypt text gpg including special characters + . encrypt command --encrypt --armor --recipient so when encrypted text passed via query string , when try decrypt. getting below error. error gpg: no valid openpgp data found.gpg: decrypt_message failed: unknown system error so, there way configure gpg not include special characters? no, there isn't. openpgp specifies 2 encodings, ascii armoring use , binary format. ascii armoring has been developed mail transfer allows basic, 7-bit ascii characters without further encoding. url encoding requires additional limitations or encoding. if cannot change data (and gnupg/openpgp can't), you'll have add encoding enforced transfer protocol chose. luckily, c# has such url encoding , decoding methods built-in. i'd propose try url-encoding binary data if transmission size critical, might save significant portion...

dynamics crm - How to get the CRM 2011 form based security role report? -

i looking way crm 2011 form based security role report instead of manually going each form of entity , find security roles. there must have been way either using 3rd party tool or sql server? entityid | formid | formtype | securityroleid finally, written script security roles not provided dynamics crm 2011 out of box. the trick have applied in solution parsing formxml security role ids of each form because couldn't find table crm maintaining association of form , role ids. composed full answer @ github location: entity's form based security roles

python - Set environment variable in one script and use this variable in another script -

i trying set environment variable using python. , variable used in script. code is: #!/usr/bin/env python import os os.environ['var'] = '/current_working_directory' after executing above python script,i execute second script uses same variable 'var', not working. when export var='/current_working_directory , run second script, works fine. tried putenv() also. this depends on how second python script get's called. if have shell, , shell first runs first python script, second, won't work. reason first python script inherits environment shell. modifying os.environ[] or calling putenv() modify inherited environment --- 1 second python script, not 1 shell script. if shell script runs second python script, again inherit environment shell ... , because shell script unmodified, cannot see modification first python script did. one way achive goal using helper file: #!/bin/bash rm -f envfile ./first_pythonscript test -f envfile ...

how to get user country name from user ip address in php -

how country name user ip address i have ip addresses of user country name of user base on user ip address how possible in php ? function get_client_ip() { $ipaddress = ''; if (getenv('http_client_ip')) $ipaddress = getenv('http_client_ip'); else if(getenv('http_x_forwarded_for')) $ipaddress = getenv('http_x_forwarded_for'); else if(getenv('http_x_forwarded')) $ipaddress = getenv('http_x_forwarded'); else if(getenv('http_forwarded_for')) $ipaddress = getenv('http_forwarded_for'); else if(getenv('http_forwarded')) $ipaddress = getenv('http_forwarded'); else if(getenv('remote_addr')) $ipaddress = getenv('remote_addr'); else $ipaddress = 'unknown'; return $ipaddress; } try this function ip_details($ipaddress) { $json = file_get_contents("http://ipinfo.io/{...

database - Mysql Unique record 2 columns -

i making application inserts users mysql database. i know can make column value unique, want combination of 2 columns in record unique. for example: id firstname lastname creationdate ----------------------------------------- 1 john doe (today) what want achieve can enter record : 2, john, deo, (today) but cannot enter: 2, john, doe, (today) what sql statement can use make combination of multiple columns unique? use below query alter table persons add constraint pk_personid primary key (firstname,lastname) http://www.w3schools.com/sql/sql_primarykey.asp

python - Why `from . import views` can solve circle import in Flask? -

this question has answer here: python circular importing? 4 answers i learn larger applications .in document, says: "all view functions (the ones route() decorator on top) have imported in init .py file. not object itself, module in. " don't know why should when this: from . import views ,it succeed.though from views import * can work well. organize these file this: myapplication/ runner.py myflask/ __init__.py views.py templates/ static/ ... runner.py: from testflask import app app.run() myflask/__init__.py: from flask import flask app = flask(__name__) . import views # why can work???? myflask/views.py: from . import app @app.route('/') def index(): return 'hello world!' and run it: $ cd myapplication $ python runner.py it's ok run flask app. want know why from . import views can ...

console application - How to convert an input string to uppercase in c# -

string choice = string.toupper(console.readline()); i want input string , convert upper case. however, there's error states : cannot convert 'string' system.globalization.cultureinfo' that appears when hover on console.readline() . why doesn't work , , fixes there? , there way ? string.toupper instance method, means have use "on" string: string input = console.readline(); string choice = input.toupper(); otherwise using the overload takes cultureinfo object. since string not convertible system.globalization.cultureinfo compiler error. it's misleading anyway, can't use instance method without instance, yields error: string.toupper(cultureinfo.currentculture); // string want upper-case??! an object reference required non-static field, method, or property 'string.toupper(cultureinfo) a method can used without instance of type if static .

java - Cannot call the API using Swagger-UI's jar file -

i generated classes using http://swagger.io/ , got zip files contains classes , models. when compile jar file , add project jar lib gives me error: 05-09 17:22:37.894 4589-4589/? e/reporthandler: fatal exception: main java.lang.noclassdeffounderror: failed resolution of: lorg/apache/http/consts; @ io.swagger.client.apiinvoker.<clinit>(apiinvoker.java:66) @ io.swagger.client.api.userauthenticationapi.<init>(userauthenticationapi.java:22) @ com.selfdrvn.selfdrvn.activities.loginactivity$1.onclick(loginactivity.java:99) @ android.view.view.performclick(view.java:4780) @ android.view.view$performclick.run(view.java:19866) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5254) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygot...

Register mobile / Android endpoint with Amazon SNS mobile push service -

i want use amazon sns mobile push notifications in combination gcm push notifications android devices. i have gcm on app , running, receives registration id google , can receive notification if send notification device via https://android.googleapis.com/gcm/send manually add device's registration id mobile endpoints in aws / sns project. the next step device registering endpoint sns service. this, documentation suggests: to register tokens devices install apps in future you can use 1 of following 2 options: use amazon cognito service : mobile app need credentials create endpoints associated amazon sns platform application. recommend use temporary credentials expire after period of time. scenarios, recommend use amazon cognito create temporary security credentials. more information, see creating temporary security credentials mobile apps using identity providers. if notified when app registers amazon sns, can register receive amazo...

matlab - Huge array because of bad algorithm? -

i trying implement segmentation algorithm , create spatial kernel image depends on distance predefined image points (stored in s) or more accurate need minimum distance of pixel in image predefined points s. % sample s s = [4 4]; % have 2k entries % point coordinates of every matrix position [cols, rows] = meshgrid(1:width, 1:height); ptcoords = cat(3, rows, cols); % here problem. array gets **huge** spatdist = zeros(height, width, sumspts); % distance current s j = 1:sumspts currs = s(j, :); scoords = cat(3, repmat(currs(1), height, width), repmat(currs(2), height, width)); rowdiff = ptcoords(:,:,1) - scoords(:,:,1); coldiff = ptcoords(:,:,2) - scoords(:,:,2); spatdist(:,:,j) = sqrt(rowdiff.^2 + coldiff.^2); end % save smallest dist per group minspatdist = zeros(height, width, nsgroups); spatkernel = zeros(height, width, sumspts); spatprob = zeros(height, width, nsgroups); = 1:nsgroups; % indices of current s currindices = 1:nspts(i); if(...

How-to select dynamic nodes in Polymer? -

i trying set mouse events element stamped out dom-repeat. event should trigger style change different element in dom-repeat template, color change icon in box on box hover. as automatic node finding not available dynamic nodes, docs should use $$ selector. however, $$ returns first node in local dom matches selector, , want hover effect boxes stamped out dom-repeat. as $$ selects element's property, leaves me thinking need set dynamic attribute icon dom-repeat, can select every repeated icon instance in mouse event change functions. the repeater gives me index, how set dynamic property it, instead of dynamic value? what missing? this should want: var nodes = polymer.dom(this.root).queryselectorall(...) if modify dom might need use polymer.dom(...) api individual nodes modifying. polymer.dom(nodes[i])...

json - python pretty print dictionary with multiline text in a value? -

here dict \n in values: d = {'trace': '\n\n##### thread stack trace #####\n file "/usr/lib/python2.7/threading.py", line 525, in __bootstrap\n self.__bootstrap_inner()\n file "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner\n self.run()\n file "/usr/lib/python2.7/threading.py", line 505, in run\n self.__target(*self.__args, **self.__kwargs)\n file "/usr/local/test_virtualenv/local/lib/python2.7/site-packages/test/plugin.py", line 303, in run_forever\n self.process()\n file "/usr/local/test_virtualenv/local/lib/python2.7/site-packages/test/common.py", line 170, in execute\n return func(*args, **kwargs)\n file "/usr/local/test_virtualenv/local/lib/python2.7/site-packages/test_plugin/system/schedule.py", line 153, in process\n self.sleep(delta_ts)\n file "/usr/local/test_virtualenv/local/lib/python2.7/site-packages/test/plugin.py", line 292, in sleep\n self...

Custom Google Maps API Key -

story : our company using google maps api past couple of years. had old api key using. today key got expired or deleted unknown entity , our applications cannot load maps anymore. have tried project manager through account have company haven't found old api key created. cannot update our apps new key cannot push updates (legacy software). tldr question: can contact google in way , ask them reenable key or grant our company account access key? google doesn't seem have "developer support" phone number can call in. appreciated.

javascript - How to upload a file using protractor tool when button is defined as ng-flow type of control -

Image
the browse button created using ng-flow library, , input=tagname , type=file button set programmatically, , not seen anywhere in html view of page. not able find element @ runtime, can use sendkeys command set path of file.

Spark SQL: How to consume json data from a REST service as DataFrame -

i need read json data web service thats providing rest interfaces query data spark sql code analysis. able read json stored in blob store , use it. i wondering best way read data rest service , use other dataframe . btw using spark 1.6 of linux cluster on hd insight if helps. appreciate if can share code snippets same still new spark environment. on spark 1.6: if on python, use requests library information , create rdd it. there must similar library scala (relevant thread ). do: json_str = '{"executorcores": 2, "kind": "pyspark", "drivermemory": 1000}' rdd = sc.parallelize([json_str]) json_df = sqlcontext.jsonrdd(rdd) json_df code scala: val anotherpeoplerdd = sc.parallelize( """{"name":"yin","address":{"city":"columbus","state":"ohio"}}""" :: nil) val anotherpeople = sqlcontext.read.json(anotherpeoplerdd) thi...

javascript - Function call not working -

i have bellow code, (function(exports) { "use strict"; var common = function() { this.loading = function(type){ this.type(); this.show = function(){ alert('show'); } this.hide = function(){ alert('hide'); } } exports.common = common; exports.common = new common(); }(window)); i trying access show() , hide() , common.loading('show'); common.loading('hide'); but throws error, typeerror: this.type not function you passing string, won't magically become function when reaches method :) you trying access method property of this , replace this.type(); by this[type]();

nasm - Assembly translating ASCII character to HEX value -

i modifying code suppose translate ascii characters hexadecimal values. first version working without problems, newer function have problems. this new function translates ascii values hexadecimal values: ;carry flag cleared if successed, if not set ;input number should in al ;output number should in ah .translate: xor ah,ah mov bx, hexascii .loop: mov dl,[bx] cmp dl,al je .end inc bx inc ah cmp ah,0x10 je .err jmp .loop .end: clc ret .err: stc ret ; ... code hexascii db '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' however function seems not work - when sending output function int 13 , bochs returning error - read/write/verify parameter out of range . numbers use 00 head , 00 cylinder , , 01 sector , gue...

Where shall I put my self-written Python packages? -

is there canonical location put self-written packages? own search yielded blog post where put version-independent pure python packages , so question canonical location under linux , while working on windows. my use case able import own packages during ipython session site-package, no matter in working directory started session. in matlab, corresponding folder example c:/users/ojdo/documents/matlab . import mypackage mp mp.awesomefunction() ... thanks two additional links, found not intended answer question, solution more , - ironically - explained in first search result, obfuscated version-(in)dependent site-package lingo. answer original question i wanted know if there canonical (as in "default") location self-written packages. , exists: >>> import site >>> site.user_site 'c:\\users\\ojdo\\appdata\\roaming\\python\\python27\\site-packages' the docs on user scheme package installation state folder - if exists - automatica...

java - Solr Composite Unique key from existing fields in schema -

i have index named locationindex in solr fields follows: <fields> <field name="solr_id" type="string" stored="true" required="true" indexed="true"/> <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/> // , more fields </fields> <uniquekey>solr_id</uniquekey> but want change schema unique key must composite of 2 present fields solr_id , solr_ver ... follows: <fields> <field name="solr_id" type="string" stored="true" required="true" indexed="true"/> <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/> <field name="composite-id" type="string" stored="true" requ...

magento - International Targeting | Language > 'de-de' - no return tags (Google webmaster) -

i have been using hreflang tag on magento store. have 4 stores (having different language): german uk french us after implementing hreflang tag on pages of magento store still "international targeting" on google "webmaster" still showing "1,270 hreflang tags errors" errors. this site ( https://www.trunki.com/de ) german store. i think there issue related crawl. updated these urls on 05-may-2016 errors not recoverable. or know how crawl international targeting in google webmaster? any appreciated. thanks if errors "no return tag" means 1 of pages not pointing main page, example english page -> french page the french page should return url english using hreflang french page -> english page i check website, homepages pointing each other, maybe have errors in internal pages (categories/items) or search results pages.

java - No mapping found for HTTP request with URI [/webstore] -

i have problem when i'm trying run spring app on tomcat server. i'm getting error 404 in browser , in console: 2016-05-09 12:26:03,188 info org.hibernate.tool.hbm2ddl.schemaexport - hhh000230: schema export complete 2016-05-09 12:26:05,082 info org.springframework.web.servlet.dispatcherservlet - frameworkservlet 'dispatcherservlet': initialization completed in 5685 ms 2016-05-09 12:26:05,121 warn org.springframework.web.servlet.pagenotfound - no mapping found http request uri [/webstore/] in dispatcherservlet name 'dispatcherservlet' this web.xml file: <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <filter> <filter-name>encoding-filter</filter-name> <filter-...

less - gulp-changed with gulp-concat not working -

i want compile .less files have changed in order speed debug/coding workflow. here gulp task: gulp.src('core/**/*.less') .pipe(changed('core')) .pipe(less().on('error', handleerror)) .pipe(autoprefixer('last 2 version')) .pipe(remember()) .pipe(concat('main.min.css')) .pipe(gulp.dest('core')) .on('end', resolve) .on('error', reject); i used gulp-changed , because didn't work @ first, tried use gulp-remember well, no effect. watch works, compiles super fast, has no effect @ all. if remove changed('core') , remember() works, it's slower (around 16 seconds). gulp-changed poor fit use case, since meant compare input files output files on disk. say have input file core/foo/bar.less pipe through changed('dist') . output file dist/foo/bar.less . if input file newer output file, passed through. otherwise filtered out. that means using changed('core') ...

php - How to view get image back from MySQL database -

i have uploaded image in database. datatype blob. want view image in browser. have written following code not generating image. kindly check it. thanks <?php include 'connect.php'; //$id= $_get['product_id']; $query_images = "select image product_images product_id=121"; if (!$query_images_result = mysql_query($query_images)) { echo mysql_error(); } else { $fetch_images = mysql_fetch_array($query_images_result); $print_images = $fetch_images['image']; header('content-type:image/jpeg'); echo $print_images; } ?> file 2 <body> <img src='single_product_image_show.php' alt="image" /> </body> maybe this? might wanna use base64 encoding build in image fyi: not tested. $sql = "select `image` `product_images` `product_id`=121 limit 1"; $query_images_result = mysql_query($sql); if (!...

ruby on rails - What is a systematic approach to debug intermittently failing specs? -

i have 4 tests in capybara/rspec suite keep failing (a real problem ci deployment). the worst thing, these tests failing intermittently, , when entire suite run, making difficult debug. they ajax requests, either submitting remote form or clicking remote link, followed expect(page).to have_content 'my flash message' . these tests fail intermittently within same test cycle. example, have several models behave similarly, iterating through them test. e.g., ['country', 'state', 'city'].each |object| let(:target) { create object.to_sym } 'runs frustrating test' end end sometimes country fails, state, passes. i have tried adding wait: 30 expect statement. have tried adding sleep 30 before expect statement. i'm still getting intermittent passes. there quite bit of information out there describing finicky ajax tests, have not found how debug , fix these kinds of problems. i'm grateful advise or pointers others, befor...

machine learning - Can a model be created on Spark batch and use it in Spark streaming? -

can create model in spark batch , use on spark streaming real-time processing? i have seen various examples on apache spark site both training , prediction built on same type of processing (linear regression). can create model in spark batch , use on spark streaming real-time processing? ofcourse, yes. in spark community call offline training online predictions. many training algorithms in spark allow save model on file system hdfs/s3. same model can loaded streaming application. call predict method of model predictions. see section streaming + mllib in this link . for example, if want train decisiontree offline , predictions online... in batch application - val model = decisiontree.trainclassifier(trainingdata, numclasses, categoricalfeaturesinfo,impurity, maxdepth, maxbins) model.save(sc, "target/tmp/mydecisiontreeclassificationmodel") in streaming application - val samemodel = decisiontreemodel.load(sc, "target/tmp/mydecisi...

InfoPath 2013 Publishing Error -

i trying publish form sharepoint form library. when trying publish form can add columns, when publishing following error: "infopath cannot save following form: http://url.sharepoint.com/sites/test access denied. before opening files in location, must first add web site trusted sites list, brows web site, , select option login automatically." i have created form adds content list when try form library save document fails. i site collection administrator not permissions based. given error message, please perform following steps below: authenticate office 365 ticking “keep me signed in” on login page. 2, add sharepoint sites trusted sites @ internet explorer > tools > internet options > security > trusted sites > add. this should work fine.let me know if works!!!!

Expanding a GDB variable for use in a loop (with dprintf)? -

i trace execution of function, printing out each line has executed - in gdb , use dprintf this. since it's big function (from line 113 line 200 in myfile.cpp), came following loop set dprintf type breakpoints on each line of function: set $n=113 while ($n<200) dprintf myfile.cpp:$n, " myfile:testf %d\n", $n set $n=$n+1 end this works, when comes setting dprintf style breakpoints: (gdb) info br num type disp enb address 1 dprintf keep y 0x080a7272 in namespace::myfile::testfunc(int&) @ /path/to/myfile.cpp:113 printf " myfile:testf %d\n", $n 2 dprintf keep y 0x080a727d in namespace::myfile::testfunc(int&) @ /path/to/myfile.cpp:114 printf " myfile:testf %d\n", $n ... ... however, if doesn't work respective dprintf format string, gdb variable $n not expanded number string, w...

javascript - Passing data into the render Backbone.js -

is possible pass questions variable view render? ive attempted calling this.render inside success on fetch got error, presumably it's because this. not @ correct scope. app.appview = backbone.view.extend({ initialize: function(){ var inputs = new app.form(); inputs.fetch({ success: function() { var questions = inputs.get(0).tojson().questions; app.validate = new validate(questions); app.validate.questions(); }, // end success() error: function(err){ console.log("couldn't service " + err); } }); // end input.fetch() this.render(); }, // end initialize render: function(){ el: $('#finder') var template = _.template( $("#form_template").html(), {} ); this.$el.html(template); } the success callback called different this object view instance....

mysql - Automate Putty To Do Daily Task -

i new putty , need guys repeatedly connect linux server using putty everyday connect 1 more linux sever within previous linux server contains database, login mysql , take database up i want automate process creating bat file on windows 7, able login putty , mysql, console disappears after that login putty username password ssh server , login username password login mysql take db using mysql dump copy db backup file desktop thanks in advance when goal making backup, not need automate putty. can make unix script call mysql , make backup. when script works, can add crontab (unix scheduler), run every day. need more testing before crontab works well: environment in interactiv session different. edit: did not answer last part: , 4. copy db backup file desktop there different ways transporting backup. can have mounted drive, shared directory, or use transport protocol rsync or scp . can not tell fits best in situation.

geolocation - using the haversine formula in javascript with variables -

hi have been struggling using have sine formula distance between users current location , objects in array, have found great answer question when try use variables instead of actual coordinates formula dosent work, 1 know going wrong this question got me point, thank talkol answer using haversine formula in javascript this i've got far navigator.geolocation.getcurrentposition (function (posa) { var lat = posa.coords.latitude.tofixed(6); var lng = posa.coords.longitude.tofixed(6); }); function getcurrent() { var lat1 = lat; var lon1 = lng; var lat2 = 42.741; var lon2 = -71.3161; number.prototype.torad = function() { return * math.pi / 180; } var r = 6371; // km //has problem .torad() method below. var x1 = lat2-lat1; var dlat = x1.torad(); var x2 = lon2-lon1; var dlon = x2.torad(); var = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(lat1.torad()) * math.cos(lat2.torad()) * math.sin(dlon/2) * math.sin(dlon/2); ...

jquery - Table row hide/collapse -

in given example hide/collapse play well, when click on "l-c" link(bg-yellow) of "this parent 1" show 1 hidden tr "this 1st child" when there 2 hidden layer bellow "this parent 1", need when click on "l-c" both hidden layer open @ time, check html structure removing ".hidden" class css. html : <table> <tr> <td class="details-control"><a>l-o</a></td> <td>this parent 1</td> </tr> <tr class = "hidden"> <td></td> <td>this 1st child</td> </tr> <tr class = "hidden"> <td></td> <td>this 2nd child</td> </tr> <tr> <td class="details-control"><a>l-o</a></td> <td>this parent 2</td> </tr> <tr class = "hidden"...

Show only the enabled dates on bootstrap datepicker -

i have 2 twitter bootstrap datepickers (from , to). have disabled every date on 'from' datepicker except today , set startdate on 'to' datepicker '+1m'. have 2 questions here: the 'from' datepicker uses update method choosing today default date, set startdate , enddate '0', default date no longer appearing in input field. after select 'today' in calendar, appearing in input field. how solve problem? i want 'to' datepicker have startdate of '+1m'. now, when open it, see current month dates in month disabled. when go next month, allowed dates visible. how make sure month see 1 selectable dates? thanks in advance :) you can add min , max input type=date: <input name="date" type="date" min="2016-05-17" max="2017-05-17"> to control start , end dates dependant on current date use: var today = new date().toisostring().split('t')[0]; document.getelem...

javascript - Cannot set property in an object in angular js -

this question has answer here: javascript - cannot set property of undefined 4 answers $scope.objectdata = {}; $scope.objectdata[key]["digits"] = set.first+','+set.second+','+set.third+','+set.fourth; here key numerical value.the error typeerror: cannot set property 'digits' of undefined you need set value of $scope.objectdata[key] object before can add more keys it. $scope.objectdata[key] = {}; $scope.objectdata[key]['digits'] = 'foo';