2018-10-22         Jason

What is the best way to query the row count from Core Data?

I am trying to get the number of rows for a given request. The only obvious way I've found to accomplish it is:NSManagedObjectContext *context;NSFetchRequest *request; ...NSInteger count = [[context executeFetchRequest:request error:&error] count];This seems wasteful to me, building an entire array of a large database's objects, just to find out how many there are. Is there a better way to accomplish this, in a "Core Data" way?Thanks for the help! NSManagedObjectContext has a method which evaluates the count for a fetch request:- (NSUInteger)countForFetchRequest:(...

 iphone                     1 answers                     41 view
 2018-10-22         Jason

VueJS add external site to router history

I am building an app using Vue Router that uses an "external" site for login credentials. It essentially looks like this:Home.Vue<template></template><script> export default { name: "Home", data() { return { } }, created() { window.location = 'https://third_party_site.com?nextpage=http://my_site.com/#/entry' } }</script><style scoped></style>This third_party_site.com handles auth and sends a JWT back as a query string in the resulting URL. When I try to use a navigation guard (as shown below) to get the q...

 vue.js                     1 answers                     84 view
 2018-10-22         Jason

Format of DRF error messages

I was wondering if anyone knows why is it that DRF doesn't capitalise the first letter of the user object in the error message and is there a simple way to correct this?Error message for create user:{ "password": [ "This field is required." ], "email": [ "user with this email already exists." ]}models.pyclass User(AbstractBaseUser, PermissionsMixin): created = models.DateTimeField(auto_now_add=True) email = models.EmailField(max_length=255, unique=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(defaul...

 django                     2 answers                     16 view
 2018-10-22         Jason

Python subprocess does not generate file like running through the command prompt does

If I run .\program.exe -API api.json in the command prompt, the program creates an api dump named api.json. I'm trying to do this through a Python script instead, butwith open("api.json", "w+") as file: subprocess.Popen(["program.exe", "-API", "api.json"], stdout=file, stderr=file)does not generate the api dump -- api.json is blank after the operation completes. Am I doing something wrong? The program I'm using can be downloaded here. Running will install the program to %localappdata%\Roblox\versions, and you can copy everything into your project's working directory. ...

 python-3.x                     1 answers                     60 view
 2018-10-22         Jason

Static webpage webpack hotloader does not work

Here is a repo I just created to get this issue solved: https://github.com/DevCubeHD/WebpackStaticPageFirst of all: File structure. There are two important folders you should know to understand my example in case it isn't even convention. The /src folder is where all the raw content goes and the /dist folder is where the packed website goes by default. From there it is ready to deploy on any server. I'm not sure if development needs this directory anyways, but I hope you are.I'm trying to set-up two webpack scripts for production and development.Production works fine: The s...

 webpack                     2 answers                     35 view
 2018-10-22         Jason

Not able to return ResponseEntity with Exception Details in spring

I have created a Spring Restful Service and Spring MVC application.Restful Service :: Restful service returns an entity if its existing in DB. If it doesn't exist It returns a custom Exception information in ResponseEntity object.It is working as expected tested using Postman.@GetMapping(value = "/validate/{itemId}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })public ResponseEntity<MyItem> validateItem(@PathVariable Long itemId, @RequestHeader HttpHeaders httpHeaders) { MyItem myItem = myitemService.validateMyItem(itemId); Re...

 java                     4 answers                     42 view
 2018-10-22         Jason

How to actually use a color palette generated by Material Design tool in Android?

I have recently used the material palette generator found at https://material.io/tools/color/ to generate a palette.This tool is an official tool on Material.io, as you can see. It generated several colors - a primary and secondary, including two variations of each. This led me to create something like this in my colors.xml file.<!-- Color palette --><!-- ... --><!-- Colors by usage --><color name="colorPrimary">@color/black</color><color name="colorPrimaryDark">@color/blackDark</color><color name="colorPrimaryLight">@color/gr...

 android                     1 answers                     68 view
 2018-10-22         Jason

query using the where clause if variables are not null

This question already has an answer here: Can I pass column name as input parameter in SQL stored Procedure 8 answers ReadALTER PROCEDURE [dbo].[spPagination] -- ORDER BY id @filterCol NVARCHAR(20) = NULL, --<<<< @filterValue NVARCHAR(40) = NULL, --<<<< @PageNumber INT, @PageSize INTASBEGIN SET NOCOUNT ON; DECLARE @SQL NVARCHAR(max) SET @SQL='SELECT Emp.id , Emp.email, Emp.[firstName], Emp.[lastName], Emp.[salary], Emp.[startDateWork], Emp.age ...

 sql                     1 answers                     31 view
 2018-10-22         Jason

How sent input information to Localdatabase from androidstodio

I'm starter with Android and I'm trying an example to get some information from an edittext and send that to my localhost and if my Localdatabaseisset that so echo something, but whatever I did, it doesn't work and OutputStreamWriter work in Android Studio when I check it with debugger but nothing send to my local database.Below I share my codes. The error is that $_POST["email"] doesn't work and errors that email is undefined?!//It's my MainActivity's codespublic class MainActivity extends AppCompatActivity {Button show;TextView txt;EditText edt;public static Context conte...

 php                     1 answers                     49 view
 2018-10-22         Jason

Including a sometimes missing column in TSQL if it's there (or alternative if it's not)

I have a weird table that I have to deal with that sometimes has a disappearing column. If the column is there, I need to use it. But if not, I need to account for that and use an alternative. But when I try this code when the column is missing, SSMS throws an error (Invalid column name 'DOB'). Shouldn't this short circuit if the column isn't there and never get to the part where it calls the column? So why the error message? Any solutions? Thanks in advance for any help!SELECT SalesClients.ClientName, (CASE WHEN (COL_LENGTH('dbo.SalesClients', 'DOB') IS NULL)...

 sql-server                     2 answers                     95 view
 2018-10-22         Jason

How to make a column case sensitive in sql 2005 or 2008

Is it possible to change the default collation based on a column? i want to make 1 column case sensitive but all the others not ALTER TABLE ALTER COLUMN allows to change collation for a single column:alter table Foo alter column Bar ntext collate Latin1_General_CS_AS (collation might be incorrect) [XXX]I don't specifically know SQL Server, but the generally accepted DBMS practice (for compatibility) would be to either:put insert and update triggers on the table so that they're stored in the case you want.use generated columns to store another copy of the column in the...

 sql                     3 answers                     6 view
 2018-10-22         Jason

Making PyQt QRadiobutton across multiple layout exclusive

I am trying to create radio buttons with only one being active at any one time. I have tried using the QButtonGroup and setting it Exclusive. However it doesn't seem to work. My code is as below:from PyQt4 import QtGui, QtCoreimport sysclass Window(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) button_group = QtGui.QButtonGroup() data_list = ['apple', 'orange', 'banana', 'mango'] main_widget = QtGui.QWidget() main_widget_layout = QtGui.QVBoxLayout() main_widget.setLayout(main_widget_layout) for it...

 python                     1 answers                     39 view
 2018-10-22         Jason

How to know if 3D Secure for Stripe is succeed or failed?

I'm new to Stripe.I've checked out the Stripe sample app and I've been able to redirect user to stripe web to validate 3D Secure with the url got from Source object: String url = source.getRedirect().getUrl()Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));context.startActivity(browserIntent);However, then intent returned from the web has no info for the result if it succeed or failed. The data contains only client_secret, livemode and source key.How do I know if the 3DS process succeeded or not?Thank you for your time. You need to listen for the sou...

 android                     1 answers                     16 view
 2018-10-22         Jason

Get-AzureRmSqlDatabaseRestorePoints fails with authorisation error

I am trying to use Get-AzureRmSqlDatabaseRestorePoints and New-AzureRmSqlDatabaseRestorePoint for managing Azure Datwarehouse restore points and restore process using Powershell. I am getting authorisation error when I call this command. I have contributor privileges at subscription and sql server level.What I noticed that subscription id in the https request for API call is different from my selected subscription.How can I force these commands to use my active subscription or can I pass subscription when I call this command.Error details Body: { "error": "code": "...

 azure                     3 answers                     27 view
 2018-10-22         Jason

Azure cosmosdb doesnt show proper value for select count(1) if count is more than 30k. Or if total count is more than 100k.

Azure cosmosdb doesnt show proper value for select count(1) if count is more than 30k. Or if total count is more than 100k. This is without partitioning. Is there any way I can get proper count? I tried using max() along with this,no luck. Per my experience, your error is resulted of bottleneck of RUs setting. The count query is limited by the number for RUs allocated to your collection. The result that you would have received will have a continuation token(even if on the portal). You may have 2 solutions:1.Surely, you could raise the RUs setting.2.You could keep looking...

 azure                     1 answers                     25 view
 2018-10-22         Jason

How to compile bootstrap-material-design sass files with gulp?

I have been struggling with gulp to compile scss files into css.I havn't used gulp and sass very much and the docs of this particular framework are not helpful on this matter.My gulpfile looks like thisvar gulp = require('gulp');var sass = require('gulp-sass');var scssFile='assets/scss/bootstrap-material-design.scss';gulp.task('sass', function () { return gulp.src(scssFile) .pipe(sass().on('error', sass.logError)) .pipe(gulp.dest('_site/assets/css'));});I did npm install gulp gulp-sass --save-dev to install libraries.And I copied the content of this folder https://gi...

 sass                     1 answers                     94 view

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