2018-10-22         Hermosa

How should I spec this

The following spec works but I know it shouldn't be like this. I am having a hard time getting my head around rspec, in particular mocks and stubs. This is the model codeclass RecipeFermentable < ActiveRecord::Base belongs_to :recipe belongs_to :product def set_attributes() attrs = product.product_attributes self.ppg = attrs.find_by_name(:ppg.to_s).value self.ecb = attrs.find_by_name(:ecb.to_s).value endendAnd this is the spec I have written it "should set the attributes from the product" do @product_attribute1 = mock_model(ProductAttribute, :name =>...

 ruby-on-rails                     1 answers                     61 view
 2018-10-22         Hermosa

Web page : Display image from byte array

I have an image byte[], this byte[] is coming from LDAP [Oracle Open LDAP Authentication Provider] and I need to show this image into the page. How can I do this?Can I use javax.faces.context.ResponseWriter to write the byte[] or I should extract an instance of java.io.OutputStream from the javax.faces.context.FacesContext and write the byte[] into page. If any one of these methods is possible, then I can might be able to create a custom JSF tag, to display the image, and try to execute the image creation in encodeBegin(FacesContext context, UIComponent component) method of...

 arrays                     1 answers                     45 view
 2018-10-22         Hermosa

Number of instances or the content of the instances more important (machine learning)?

Say in the document classification domain, if I'm having a dataset of 1000 instances but the instances (documents) are rather of small content; and I'm having another dataset of say 200 instances but each individual instance with richer content. If IDF is out of my concern, will the number of instances really matter in training? Do classification algorithms sort of take that into account?Thanks.sam You could pose this as a general machine learning problem. The simplest problem that can help you understand how the size of training data matters is curve fitting. The uncert...

 machine-learning                     1 answers                     25 view
 2018-10-22         Hermosa

$+ in makefile

What does $+ in a GNU makefile mean?Also, please give me some good lookup manual for writing makefiles. From the make manual: $^    The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives). A target has only one prerequisite on each other file it depends on, no matter how many times each file is listed as a prerequisite. So if you list a prerequisite more than once for a target, the value of $^ contains just one copy of the name. This list does not contain ...

 makefile                     2 answers                     53 view
 2018-10-22         Hermosa

expected 422 got 200 Cucumber with rails

Hi i am working on a ROR project with ruby-2.5.1 and rails 5. I am using cucumber in my rails app to test api i am new with cucumber. when i am trying to define feature for invalid data i am getting the error expected 422 got 200.my feature file:Feature: Registration Endpoint Scenario: User registration Given an application with application_id "1" When the client make a valid POST /registartions request with application_id: "1" Then response should have status 200 Scenario: using blank application id When the client make a POST /registartions request with blan...

 ruby-on-rails                     1 answers                     50 view
 2018-10-22         Hermosa

Using f-string with format depending on a condition

How can I use f-string with logic to format an int as a float? I would like if ppl is True to format num to 2 decimal places, and if ppl is False to rformat it as whatever it is.Something like string = f'i am {num:.2f if ppl else num}' but this does not work. The below code demonstrates the behaviour that I want to achieve with a simpler f-string if possible:ppl = Truenum = 3string = f'I am {num:.2f}' if ppl else f'I am {num}'print(string)#if ppl False#=> i am 3#if ppl True#=> i am 3.00 You can nest expressions to evaluate inside expressions in an f-string. This me...

 python                     2 answers                     29 view
 2018-10-22         Hermosa

How to enter file content to Text widget in Tkinter?

Even though the questions seems to me to be too basic to not being able to find a solution otherwise but I could not figure out where or what the problem is.As the question indicates, I would like to be able to open a directory, select a file and enter the content of that file into a Text Widget where I want to edit it. Just like any application which has an 'Open' button.import tkinter as tkfrom tkinter import filedialogdef open(): filename = filedialog.askopenfilename(initialdir="C:/", title="Select File", ...

 python-3.x                     1 answers                     55 view
 2018-10-22         Hermosa

Javascript Date Object gives different timezones for differently formatted date strings

Does anyone know why the Javascript Date object changes the timezone based on how your string is formatted and if there is a way to avoid it?For example, on the West coast (Firefox uses PST for some reason, Chrome uses PDT),new Date("08/30/2018") -> Date 2018-08-30T08:00:00.000Zwhilenew Date("2018-08-30") -> Date 2018-08-30T00:00:00.000ZIt took me a while to debug this issue, and I would rather not have to add extra code, if possible, for changing the timezone or reformatting the input string. I don't have an answer from the spec, but I can guess. @charlietfl is o...

 javascript                     2 answers                     46 view
 2018-10-22         Hermosa

Ideas for Implementing multiple views for the same data

I am using CodeIgniter, but the question applies to any MVC framework. I have a custom CMS which allows for the management of 5 different websites. Users log in and switch between these sites. They can add content to each of the areas of the sites. The CMS and data that can be entered is the same for each site. The public facing sites all look completely different and represent different brands even though they contain the same data as all the others. So how would you go about implementing these views? Are there any design patterns I should be looking at? The only way I can...

 php                     2 answers                     7 view
 2018-10-22         Hermosa

Workaround for drawing bug when Overlaying a <div> over an <iframe> in Safari?

I'm getting a very weird drawing bug in Safari, and i would like to see if there's any workaround I could take...I'm currently displaying a <div> (absolutely positioned, high z-index) on top of an IFrame that displays contents from other sites. Just for context, the <div> is a toolbar we show over other sites.This works well in all browsers, but in Safari, when the IFrame is showing some sites, and the user scrolls the page in the IFrame, the drawing of the toolbar gets all screwed up.Here is a very minimalistic POC that reproduces the problem:<html><he...

 iframe                     1 answers                     23 view
 2018-10-22         Hermosa

Database connection to xampp using C#

Im using xampp as my sql database server. Im trying to connect to it but it's not working.I'm new with C# this my code below namespace InventoryManagement{ public partial class Form1 : Form { public string dbconnect = "Server=;User=root@localhost;password=;database=inventory;"; } private void button3_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(); connect.ConnectionString = dbconnect; connect.Open(); if (connect.State == ConnectionState.Open) { ...

 c#                     1 answers                     26 view
 2018-10-22         Hermosa

SQL Server Reporting Services HTML Error 500.24

I have been using SQL Server Reporting Services on many servers but on this particular one when I try to open the url to create subscriptions I get the following error: HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline modeAny advise would be greatly appreciated, please advise if more information is required One option would be to simply switch your Managed Pipeline mode from Integrated to Classic in IIS. The steps would be as follows.Start the Internet Information Services (IIS) Manager fr...

 sql-server                     2 answers                     96 view
 2018-10-22         Hermosa

Google Cloud PubSub/Datastore Error 13 & 14: "GOAWAY received" and "TCP Read/Write Fail"

Sorry for the long title. Having some issues randomly pop up (every handful of hours, but not on a regular schedule, could be anywhere from 3 hours to 8) when streaming data from Cloud PubSub into Cloud Datastore using Cloud Functions.Source is a Node.js 6 script that receives an HTTP Post with info, writes to PubSub topic, then publishes topic to Cloud Datastore.It is a modified version of this:https://github.com/CiscoSE/serverless-cmxErrors:This first one happens sometimes with TCP Write instead of Read, but it's the same error.ERROR: { Error: 14 UNAVAILABLE: TCP Read fai...

 node.js                     1 answers                     84 view
 2018-10-22         Hermosa

Frama-c fails to prove fact about pointer comparison

Consider the following C code:#include <assert.h>//@ requires p < q;void f(char *p, char *q){ assert(p <= q-1);}//@ requires a < b;void g(int a, int b){ assert(a <= b-1);}Using alt-ergo, frama-c successfully proves that the assertion in g() holds but fail to prove the same with f(). Why? Formally, pointers and integers are two very different things. In particular, C semantics states that pointer comparison is well defined only for pointers that points in the same allocated block (or one offset past the end of said allocated block) . This is reflec...

 frama-c                     1 answers                     83 view
 2018-10-22         Hermosa

React Native: ignore files in a CodePush update

My use case is that I have an env file and its contents are replaced each time I build the app through Appcenter with environment variables. I fear that when I update the file locally (for example add another variable), the file would be overwritten in next CodePush release (so basically the build from Appcenter after the vars are replaced will have different contents of this file in comparison with what CodePush will see). Is this the correct assumption? If it is, is there a way to exclude certain files from a CodePush update? Thanks. I'm using react-native-config, and ...

 react-native                     1 answers                     96 view
 2018-10-22         Hermosa

Integrate Single Page application into WordPress

I have lots of basic single page applications which have html, css, js files I would like to publish them on wordpress. I can add them like external website but when I used this, I have to add all static parts (header, menu, footer etc) to the app.html file. And I have to do this for each application. This is not sustainable and good solution for sure. This is why I am looking for some way to add this page after menu in wp like other pages. I would like to give you folder hierarchy to concrete the problem. || - apps || - || - app1 || - || - || - app1.html || - || ...

 javascript                     2 answers                     106 view

Page 1 of 145  |  Show More Pages:  Top Prev Next Last