2018-10-22         Jeremy

When I open CMD from Java, I cannot change the Directory

I have a problem with my Java program where I have a button that opens the command prompt and opens a batch file to run a series of commands. To do this, I need to change directory. Here is my code:private void CommandPromptButtonActionPerformed(java.awt.event.ActionEvent evt) { try { new java.lang.ProcessBuilder("cmd.exe").start(); java.lang.Runtime.getRuntime().exec(new String[]{ //I need to change the directory in command prompt and I do not want to use escape "cmd.exe","/c","start...

 java                     4 answers                     94 view
 2018-10-22         Jeremy

Core Data NSFetchRequest problem

I am trying to develop a test Core Data app so i can use it in my main app. But im having problems fetching stored data.I have 1 Entity "User" with 2 attributes: name (String) & email (String)I can successfully populate my store file with data... here is the code im using below.Any help would be greatly appreciated.NSManagedObjectContext *managedObjectContext;NSError *error;NSString *basePath = @"/Users/Jamie/Desktop";NSURL *storePath = [NSURL fileURLWithPath: [basePath stringByAppendingPathComponent:@"datastore.xml"]];NSLog(@"Data Store path: %@", storePath);NSPersiste...

 objective-c                     1 answers                     49 view
 2018-10-22         Jeremy

JWT signature failed errors are not coming as JSON errors in SLIM

I am using Firebase JWT in one of my SLIM framework apps for RESTFul api. But all the JWT errors occur as slim app error rather than throwing back json errors ,which i can return to user.Like in image belowCan you help how can i display JWT errros in json format ,so that my restful api return that json error to user. If you need to output error as JSON, you need to handle the exception. For example:try { //do something when everything is OK} catch (\Firebase\JWT\SignatureInvalidException $e) { return $response->withJson( (object) [ 'error' => t...

 php                     1 answers                     89 view
 2018-10-22         Jeremy

django rest framework nested objects

I'm trying to find an elegant solution to this problem encountered using the Django REST framework. We have a parent model with a child object and a one to one relationship. Our requirements are that the child object is optional, can be null and can also be patched to null from a previously existing value. Additionally, if the parent object is deleted the child object should be as well.This simple set-up that recreates the problem:class ChildSerializer(serializers.ModelSerializer): class Meta: model = Childclass ParentSerializer(serializers.HyperlinkedModelSeriali...

 python                     2 answers                     20 view
 2018-10-22         Jeremy

python ip output error

From this script i only want to print the ips which have 'bytes from' and save that output in txt format.after adding the if statement,i'm still getting the full ips. Please help.import subprocesswith open('ips') as f: line = f.readlines()for i in line: p1=subprocess.Popen(['ping', '-c 1', i], stdout=subprocess.PIPE) output = p1.communicate()[0] print(output) if 'bytes from' in line: print(output)Output:PING 10.11.1.1(10.11.1.1) 56(84) bytes of data.From 10.11.0.92 icmp_seq=1 Destination Host Unreachable--- 10.11.1.1 ping statistics ---1 packets transm...

 python                     1 answers                     63 view
 2018-10-22         Jeremy

How to display the value of a variable as text using pygame

I am using Windows 10 and Python 3.7 with pygame 1.9.4.My application requires that the value of a variable is displayed onto a pygame screen.Currently, I have:tnr = pygame.font.SysFont('Times New Roman', 30)text2 = tnr.render(timePriorities, False, (0, 0, 0))screen.blit(text2,(0,0))This outputs this error:TypeError: text must be a unicode or byteDoes anyone know how to solve this issue?Thx!Oh, and this is the related code:timePriorities = 1.1timeRightTurn = 2.2timeDeadEnd = 3.3timeIntersection = 4.4array = sorted([timePriorities,timeRightTurn,timeDeadEnd,timeIntersection])...

 python-3.x                     1 answers                     71 view
 2018-10-22         Jeremy

Webpack split chunks aren't being executed

I have created a webpack config that has three entry points which I am trying to split when bundled. Below is my webpack.config.jsvar path = require('path');var webpack = require('webpack');module.exports = { mode: "development", optimization: { splitChunks: { chunks: "all" } }, context: path.resolve('js'), entry: { about: './about_page.js', home: './home_page.js', contact: './contact_page.js' }, output: { path: path.resolve('build/js/'), publicPath: '/public/assets/js/', filename: "[nam...

 javascript                     2 answers                     38 view
 2018-10-22         Jeremy

How to use a Spring profile expression?

Spring Boot: 2.0.4.RELEASEI have specified a Spring Boot multi-profile YAML configuration file:server: address: 192.168.1.100---spring: profiles: developmentserver: address: 127.0.0.1---spring: profiles: production | eu-centralserver: address: 192.168.1.120According to the reference guide, if the production or eu-central profile is active, the server.address property is 192.168.1.120. But when I run this test@ActiveProfiles({"production"})@RunWith(SpringRunner.class)@SpringBootTestpublic class ProfileTest { @Autowired private Environment...

 spring                     1 answers                     44 view
 2018-10-22         Jeremy

Parent of Theme.AppCompat.Light.NoActionBar

What's the parent of Theme.AppCompat.Light.NoActionBar? I can't find a "parent" attribute in Android SDK resources. I guess it should be Theme.AppCompat.Light. But I didn't find any document to prove that. You can inherit styles by using dot instead of using parent (docs). So Theme.AppCompat.Light is parent of Theme.AppCompat.Light.NoActionBar You can also inherit styles (except those from the platform) by extending a style's name with a dot notation, instead of using the parent attribute. That is, prefix the name of your style with the name of the style you want to inh...

 android                     1 answers                     70 view
 2018-10-22         Jeremy

SQL query to compare the amount

I have a Claim table that holds the claim amount. I need to write a query to compare if the amount is the same or not. SELECT CLAIM_NO, SUM(TRAN_AMOUNT) AS AmountFROM CLMTABLEWHERE TRTYPE = 0GROUP BY CLAIM_NOUNION ALLSELECT CLAIM_NO, SUM(TRAN_AMOUNT) AS AmountFROM CLMTABLEWHERE TRTYPE <> 0GROUP BY CLAIM_NOOUTPUTCLAIM_NO AMOUNT-----------------1234567890 883.001234567890 883.001234567891 990.001234567891 990.001234567892 883.001234567892 893.00The last record the amount is not the same, i want to be able to spot the claim that the amou...

 sql                     2 answers                     37 view
 2018-10-22         Jeremy

Updating user status using PHP and SQL

Here, I'm trying to get a list of admin users and add and remove it using PHP and SQL.I listed some users but I couldn't think of removing and adding by updating a Boolean data (made this Boolean data to state them as valid or invalid) individually. Help from anyone would be highly appreciated.Thank you.<?php// connection to databaserequire 'config.php'; $sql = "SELECT id, adminUser, password FROM admins WHERE legal = '1'"; $result = mysqli_query($conn, $sql); $sql2 = "SELECT id, adminUser, password FROM admins WHERE legal = '0'"; $result2 = mysqli_query($con...

 php                     2 answers                     53 view
 2018-10-22         Jeremy

Password Encryption / Database Layer AES or App Layer AES

I need to encrypt / decrypt passwords for a new application. The spec requires me to use AES; can anyone suggest a good reason to eitherDo all my encryption in the database layer using CLR functions orDoing it at the .Net app layer ?a mixture of db and serverAm going to be validation passwords; the app is n-tiered using Telerik ORM. The only real functions are going to be create/ update password and check the entered value. In my gut i think database is better for validating the users entered password against an existing record; and the front end for creating/ updating pass...

 .net                     2 answers                     8 view
 2018-10-22         Jeremy

Python/Django with Stripe: Error in Post request in creating stripe subscription

This is my first time using stripe does this look familiar to anyone?So I am able to see that a token is being created upon payment, but instead of being redirected to my template, i throws this error below!ERROR>**InvalidRequestError:**>Request req_d5BvUPtlpLrsG5: Received unknown parameter: source>Request Method: POST>Django Version: 2.1>Exception Type: InvalidRequestError>Exception Value: >**Request req_d5BvUPtlpLrsG5: Received unknown parameter: source**CODEdef PaymentView(request): user_membership = get_user_membership(request) sel...

 python                     1 answers                     20 view
 2018-10-22         Jeremy

Failed to delete VNet in Azure after checking the connections and connected devices

I have an Azure VNet and it was used for Azure Environment Service. Since it is no longer used, I deleted all relative resources. But when I delete this VNet, there is an error : Failed to delete virtual network 'name-vnet'. Error: Subnet legoexttest-subnet is in use by /subscriptions/XXX/providers/Microsoft.Web/hostingEnvironments/name and cannot be deleted.I've found this Troubleshooting: Failed to delete a virtual network document.I checked the issues one by one and still didn't solve my problem. I'm sure that there is no connected device or service endpoint in my VNet. ...

 azure                     1 answers                     31 view
 2018-10-22         Jeremy

DocumentDb write within a transactionscope

I am trying to use a DocumentDb write as a part of a transaction like below - using (var scope = new TransactionScope){//first transaction//write to document db//third transaction}I observed that if the third transaction fails, documentDb write is not rolled back and I still see the document in the collection. The first transaction (NEventStore in this case) rolls back perfectly. Does anyone know if DocumentDb supports TrnasactionScope. What if I have a nested transaction?Thanks!Edit:So looks like TransactionScope is not supported with DocumentDb and it knows nothing about ...

 c#                     2 answers                     28 view
 2018-10-22         Jeremy

Android studio device file explorer gets stuck when downloading a file

When I try to download files from my device in Android Studios Device File Explorer the download always gets stuck.I open the folder in the Device File Explorer, right click on the file(s) and choose "Save as...". The problem occurs on several devices (same model).Above the progress bar it says: Downloading file 12 of 14: "/data/data/com.some.name/files/data.txt" (15,9 MB / 16,8 MB)But no matter how long I wait it doesnt continue to download.The only hint I could find are these lines in the log file (maybe they are completly irrelevant):09-06 12:49:14.385 3784-3812/? W/Sto...

 android                     1 answers                     103 view

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