2018-10-22         Bella

Ruby on Rails: is it okay to use old school database access without migrations?

I'm switching to RoR from ASP.NET MVC. Yeah, migrations are cool, but I do not need to use different databases in my web applications. Postgresql will do just fine. So is it okay if I use PGAdmin to create and administer my databases and schema and avoid all these fancy migrate, rake etc?UpdateThanks everyone! Now I better understand what migrations are, and why I should use them. I don't think that's what migration means.Migrations in rails (and in other frameworks) is a method by which you can use to update your database schema when there are multiple versions of the ...

 ruby-on-rails                     3 answers                     78 view
 2018-10-22         Bella

cmd.exe vs & for executing batch file?

I want to execute a batch(*.bat) file from Powershell. Is there any reason not to use option 1 below?& path-to-batch-filecmd.exe /c path-to-batch-file I can only think of corner cases...Option 1 probably uses the default file handler for .bat files. If that handler is changed, corrupted, or different than expected, a problem could arise. Though, this seems pretty unlikely.Option 2 gives you the power to pass additional parameters to cmd.exe, which might be valuable.Option 2 might be slightly faster, but it's only a guess: in Option 1 powershell might need to lookup t...

 powershell                     1 answers                     92 view
 2018-10-22         Bella

Creating table sections with NSFetchedResultsController

I'm using NSFetchedResultsController to drive the data for my UITableViewController. A simplified version of the managed object I am fetching looks like this (well for example):Person:-(BOOL)hasPet;-(BOOL)hasDog;Basically, I want my table to only show those Person objects who have a pet. So that's simple, I can use a predicate. Now, for those who hasPet == YES, I want to put them in the table in 2 sections, first section hasDog == YES, and the second is hasDog == NO. This is where I'm a little fuzzy. Here is where I configure my results controller, hopefully someone can hel...

 ios                     1 answers                     42 view
 2018-10-22         Bella

How to serialize queryset in get method in Django Rest Framework?

I am trying to implement calculation logic in APIView class following this page.However, I got below error because I tried to serialize queryset, not dictionary as demonstrated in the page.Does anyone know how I can pass queryset to serializer as argument? If not, are there any way to convert into format which can be serialized by serializer? { "non_field_errors": [ "Invalid data. Expected a dictionary, but got QuerySet." ]} views.py class envelopeData(APIView): def get(self,request,pk): #pk=self.kwargs['pk'] #print (pk) glass_json=se...

 django                     2 answers                     17 view
 2018-10-22         Bella

When are bash variables exported to subshells and/or accessible by scripts?

I'm confused over whether bash variables are exported to subshells and when they are accessible by scripts. My experience so far led me to believe that bash variables are automatically available to subshells. E.g.:> FOO=bar> echo $FOObar> (echo $FOO)barThe above appears to demonstrate that bash variables are accessible in subshells.Given this script:#! /usr/bin/bash# c.shfunc(){ echo before echo ${FOO} echo after}funcI understand that calling the script in the current shell context gives it access to the current shell's variables:> . ./c.sh beforebarafterIf I...

 bash                     1 answers                     61 view
 2018-10-22         Bella

Pause game shell window on tkinter and open a new shell window

Using Tkinter python.I am creating a game and in which I have a quit button. I want when I click on quit button my game pause and open a new shell. If I click on NO button then game shell resume working. If I click on Yes button then quit the game. Yes button is working fine. I have problem on when I click on quit button game should be paused and resume when clicking on the no buttondef quit_function(): YES = Button(tk9,text="YES",font=("Showcard Gothic",10), command= os._exit(0), fg='white', bg='red', width=10) NO = Button(tk9,text="NO",font=("Showcard Gothic",10), c...

 python-3.x                     1 answers                     70 view
 2018-10-22         Bella

Applying styles in Webpack 4

I am having big problems applying classes to my ul elements in React using SCSS and Webpack 4. I have upgraded my project to Webpack 4 ( #yesiamstupid ) If I taget a type of element (ul) it works. My own class "navMenu" is never applied, though. I can see the class in the web developer tools --> styles.scss I expect the text background to be blue in the navigation. [ app.js ]import 'babel-polyfill';import React from 'react';import ReactDOM from 'react-dom';import { Provider } from 'react-redux';import AppRouter from './routers/AppRouter';import 'normalize.css/normalize.css...

 sass                     1 answers                     36 view
 2018-10-22         Bella

How to add a few restrictios to a query?

I have difficulty with syntax...This is my query: SELECT t.diapason, Count(*) AS 'number_of_users'FROM (SELECT CASE WHEN amount < 200 THEN '0-200' WHEN amount >= 200 THEN '200 +' end AS diapason FROM (SELECT Sum(amount) AS amount FROM payments) p) tGROUP BY t.diapasonORDER BY number_of_users DESC; But now I need to select only users which had activity.login_time between '2018-01-01' and'2018-01-12'.So, I think I should use INNER JOIN and set period of time. Bu how?My tables:activityuser...

 mysql                     2 answers                     32 view
 2018-10-22         Bella

Add a percentage discount based on customer total purchases sum in Woocommerce

In Woocommerce, I would like to set a percentage discount based on customer total purchases sum. For example if the total purchase sum greater or equal to 200$, customer get 5% discount.So, I have first part of code for showing the total sum:function get_customer_total_order() { $customer_orders = get_posts( array( 'numberposts' => - 1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => array( 'shop_order' ), 'post_status' => array( 'wc-completed' ) ) ); $total = 0; foreac...

 php                     1 answers                     50 view
 2018-10-22         Bella

Can you recommend a Sql Server 2008 book for developers that only addresses the new features?

I am looking for a book that only addresses the new development features of Sql Server 2008. I had read "A First Look at Sql Server 2005 for Developers" years ago but cannot find an equivalent book. I picked this one up recently and it has a good focus on 2008 specific items:http://www.amazon.com/Programming-Microsoft-Server-2008-PRO-Developer/dp/0735625999/ref=sr_1_1?ie=UTF8&s=books&qid=1242660997&sr=8-1 [XXX]There is a nice list here http://www.microsoft.com/sqlserver/2008/en/us/whats-new.aspx [XXX]You could also just check out MS books online and s...

 sql-server                     6 answers                     7 view
 2018-10-22         Bella

What kind of signal is emitted when QScrollArea entry is selected/clicked?

I'm having though time figuring out what kind of signal is emitted in following situation:Basicly that's QScrollArea that holds multiple QTableWidgets:class ScrollArea(QtGui.QScrollArea): def __init__(self): super(ScrollArea, self).__init__() self.scroll_widget = QtGui.QWidget() self.scroll_layout = QtGui.QVBoxLayout() self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setWidgetResizable(True) self.__create_content() self.setWidget(self._...

 python                     1 answers                     40 view
 2018-10-22         Bella

Merge additional nodes to Stripe token before passing it to the Firebase database

I want to be able to add an additional node to my token object after receiving it from Stripe to push it to the firebase database in a single write. In my project, I am pushing the token object to the database and then calling another write to add the additional node...DatabaseReference tokenRef;tokenRef = mRootRef.child("users").child(mUser.getUid()).child("payments").push();tokenRef.setValue(token);tokenRef.child("amount").setValue(500);Ultimately, I want my database to look like this on a single writeIs there a way to merge the "amount" node to the token before passing i...

 android                     1 answers                     17 view
 2018-10-22         Bella

Azure SQL Database or SQL Data Warehouse

I am working on a solution architecture and am having hard time choosing between Azure SQL DB or SQL DW.The current scope involves around developing real-time BI reporting solution which is based on multiple sources. But in the long run the solution may be extended into a full fledged EDW and Marts.I initially thought of using SQL DW so that for future scope the MPP capabilities could be used. But when I spoke to a mate who recently used SQL DW, he explained that the the development in SQL DW is not similar to SQL DB. I have worked previously on Real Time reporting with no ...

 azure-sql-database                     3 answers                     28 view
 2018-10-22         Bella

Result of excuting Stored Procedure on Cosmos DB

I created a stored procedure like this:// SAMPLE STORED PROCEDUREfunction sample() { var prefix = ""; var collection = getContext().getCollection(); // Query documents and take 1st item. var isAccepted = collection.queryDocuments( collection.getSelfLink(), 'SELECT * FROM c', function (err, feed, options) { if (err) throw err; // Check the feed and if empty, set the body to 'no docs found',  // else take 1st element from feed if (!feed || !feed.length) { var response = getContext().getResponse(); ...

 azure                     1 answers                     26 view
 2018-10-22         Bella

netmiko connection error - TypeError: connect() got an unexpected keyword argument 'passphrase'

I'm taking my first steps with netmiko and trying a basic connection:from netmiko import ConnectHandlerdevice = ConnectHandler(device_type="cisco_ios", ip="", username="name", password="passowrd")output = device.send_command("show version")print outputdevice.disconnect()I've tries device_type="cisco_ios" and arista_eos, on both occasions I receive the following:Traceback (most recent call last):File "netmiko_v1.py", line 3, in <module>device = ConnectHandler(device_type="cisco_ios", ip="", username="name", password="password")File "build/bdist.li...

 python                     2 answers                     34 view
 2018-10-22         Bella

How do I import espresso withID on android studio?

I am trying to write a unit test with espresso for my application, but whenever I try to use withId, it cannot be found. How do I fix this?onView works fine, but when I try onView(withId) it doesn't work.Here is my code:package com.example.webowner.authenticate;import android.content.Context;import android.content.Intent;import android.support.test.InstrumentationRegistry;import android.support.test.espresso.Espresso;import android.support.test.rule.ActivityTestRule;import android.widget.Button;import android.widget.EditText;import android.widget.ProgressBar;import static a...

 android                     1 answers                     95 view

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