2018-10-22         Mike

batch: combine string operations

I'd like to combine the following string operations...SET MYVAR=someStringWithSomeExpressionInsideSET MYVAR=%MYVAR:Expression=thing%SET MYVAR=%MYVAR:~4%...to something like this:SET MYVAR=%MYVAR:Expression=thing~4%EDITTo give you an idea of what i'm intend to do:SET TIMESTAMP=%DATE:~8,2%%DATE:~3,2%%DATE:~0,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%SET TIMESTAMP=%TIMESTAMP: =0%..this should be a single SET command without any helper variables. You mean like this?set "MYVAR=someStringWithSomeExpressionInside"set "MYVAR1=%MYVAR:Expression=thing%"set "MYVAR2=%MYVAR1:~4%"set "VAR=%M...

 string                     2 answers                     11 view
 2018-10-22         Mike

BotDetect Captcha Issue: New Session Initialized on Postback

Good Day!I just need some help regarding this issue that I'm encountering using BotDetect Captcha. Issue: Session Troubleshooting: New Session Initialized on Postback, potential timeout or Session resume problemI'm using version of BotDetect.dll in asp.net/SharePoint site. The issue is happening upon clicking the Submit button in the page and when it postback to validate the page inputs, the captcha section will fail and show this issue. This is the code that I use to validate the captcha input: isValid = BotDetectCaptcha.Validate(CaptchaCodeTextBox.Text.Trim().ToU...

 c#                     1 answers                     57 view
 2018-10-22         Mike

where to include json web token

I maybe missing an important piece of jwt concept but I'm having a hard time finding info on where the server is supposed to include the generated json web token in the response and where the client is supposed to include it in the subsequent requests. Are there any rules/guidelines/best practices on that? The JWT should be sent to the client in the response body. In the subsequent requests you've got to include an header field called Authorization with the token. Check this link for more details. [XXX]

 jwt                     1 answers                     2 view
 2018-10-22         Mike

How to put arguments in a jchart.Chart class

I am trying to make a chart in Django using the jchart module and to be able to chose which rows i want to retrieve from the db using the variable hosp from my views.py to HomeTotalStudies() (below)views.pyfrom charts.chartsclass import HomeTotalStudiesdef home(request): hosp = request.user.userprofile.hospital chart = HomeTotalStudies() return render .....here is the /charts/chartsclass.pyfrom jchart import Chartfrom jchart.config import (DataSet, Axes, rgba, ScaleLabel, Tick, Tooltips, Legend, LegendLabel, Title, Hover, InteractionModes,...

 python                     2 answers                     39 view
 2018-10-22         Mike

How to get output of terminal commands to python gui text area using subprocess?

import subprocess subprocess.call('gcc a.c', shell=True) subprocess.call('./a.out', shell=True)I am executing this statement to compile a ".c" file. I got the output in the backend. But how can I get the output of that C program in a python text area (I'm using tkinter, python 2.7 )?Another problem is, I'm not able to scan input data but only able to compile programs which will not take input data. you can use subprocess.Popen and redirect stdout to PIPE and test simply read stdout e.g complie.stdout.readlines() in you set text area calls import subprocesscomplie = s...

 python                     1 answers                     84 view
 2018-10-22         Mike

Webdriver.get() will not navigate to another page until I add wait before the call

I have a Python 3.5 script that basically logs into a web site (and gets redirected after login) and then navigates to another page where it actually does its job. If I run webdriver.get() to this second page right after the login, it doesn't navigate to the target location and stays on the page it gets redirected to after I log in. But if I put a breakpoint or just time.sleep(5) - it opens up fine. I found this question with the C# code, where it is suggested to add async waits. Is there a Pythonic way to work around it?My code for reference:# underneath is webdriver.Chrom...

 python                     1 answers                     91 view
 2018-10-22         Mike

How do I change an id to a slug for the URL using React Router DOM

I'm using an API where I can search using the post id. How do I change the link to a slug I created. Ex instead of /posts/1, it'll become posts/slugtitlePost.jscomponentDidMount() { const { match: { params } } = this.props; axios .get(`/api/posts/${params.postId}`) .then(response => { console.log(response); this.setState({ post: response.data }); }) .catch(error => console.log(error));}Routes.js<Route path={"/post/:postId"} strict component={PostShow} />Also, what's the easiest way to redirect if there is no post with the id that is sear...

 reactjs                     1 answers                     55 view
 2018-10-22         Mike

How to run code every 24h in android

In my application, I want run code every 24hours for per user!For example : When show Toast message on 12:00 am , then show again this Toast message in tomorrow 12:00.How can I do it? You need to register an alarm, try belowStep 1: Register an Alarm.private void registerAlarm(Context context, int requestCode) { int HOUR = 60 * 60 * 1000; Intent intent = new Intent(context, DailyAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast( context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager =...

 java                     2 answers                     88 view
 2018-10-22         Mike

Keep zero values with GROUP BY and SUM in mysql

I have two tables career_types and bookingscareer_typesid | name1 | foo2 | bar3 | bazbookingsid | career_type_id | details1 | 1 | foo2 | 1 | bar3 | 2 | bazMy bookings table has a lot of entries for all career types except career_types.id of 3.I want a query that will list all my career_types.name's and how many each booking has, and in the case of career_types.id = 1 where there are no bookings for it. I want to return 0.So far I've been trying variations ofSELECT career_types.name, sum(bookings.id)FROM career_typesLEFT JOIN bookings ON (career_types.id = bookings.career_ty...

 mysql                     1 answers                     54 view
 2018-10-22         Mike

How can I detect a SQL table's existence in Java?

How can I detect if a certain table exists in a given SQL database in Java? You can use DatabaseMetaData.getTables() to get information about existing tables.This method works transparently and is independent of the database engine. I think it queries information schema tables behind the scenes.Edit:Here is an example that prints all existing table names.DatabaseMetaData md = connection.getMetaData();ResultSet rs = md.getTables(null, null, "%", null);while (rs.next()) { System.out.println(rs.getString(3));} [XXX]Use java.sql.DatabaseMetaData.getTables(null, null, YOU...

 java                     10 answers                     71 view
 2018-10-22         Mike

Creating index on schema binding view in SQL Server

I am trying to create index for schema binding view. This view contains union all operator and some joins also. How can I create an index for this view? Because I am using the type of views in my procedure using left join. So I have to improve performance.For examplecreate table a( prodid int, prodname varchar(100))insert into a values(1,'ramesh')create table b( prodid int, prodname varchar(100))insert into b values(2,'kumar')create view v1 with schemabinding as select tb1.prodid, tb1.prodname from dbo.a tb1 union all select tb2.prodid, tb...

 sql-server                     2 answers                     13 view
 2018-10-22         Mike

Delete from database only works when debugging

I am reading rows from a database which contains BLOB's. I take each of these blobs and saves them as a file to my disk. Afterwards I want to delete the rows I have just read. Now the problem: When I debug, all works like a charm. When I run without having a debug breakpoint, it doesn't delete anything! And it doesn't come up with an error.I use C# and MS-SQL server.Here is my code:class Program{ static void Main(string[] args) { if (args[0] == "/?" || args.Length != 1) { Console.WriteLine("BlobReader"); Console.WriteLine("Will read...

 c#                     2 answers                     32 view
 2018-10-22         Mike

Custom date format parsing in python

I am trying to the parse dates of the format '2016-04-15T12:24:20.707Z' in Python, tried strptime, doesn't work and I also tried django parse_datetime but it only returns none as the value import dateutil.parserfrom datetime import datetime dt = dateutil.parser.parse('2016-04-15T12:24:20.707Z') [XXX]This seems to be working alright:import dateparserdateparser.parse('2016-04-15T12:24:20.707Z')> datetime.datetime(2016, 4, 15, 12, 24, 20, 707000, tzinfo=<StaticTzInfo 'Z'>) [XXX]You have to specify the format as "%Y-%m-%dT%H:%M:%S.%fZ" while conversionIn [11]:...

 python                     5 answers                     37 view
 2018-10-22         Mike

Service Fabric Cluster Custom endpoints vs Application start-end port

This screenshot was taken while creating a cluster on portal. As given in the picture below, what is the difference between Custom endpoint and applicationstart-end port range?Why is one called endpoint and other called port?The custom endpoints help says "Custom endpoints allow for connections to applications running on this node type. Enter endpoints separated by a comma.". In the documentation here and here it is explained in a very clear way,Custom endpoints: This field allows you to enter a comma-separated list of ports that you want to expose through the Azure L...

 azure                     1 answers                     45 view
 2018-10-22         Mike

Windows Azure: Delete disk attached to non-existent VM

Just found out I was taking up - and paying for - a lot of storage due to abandoned disks from long ago deleted VMs. I manged to delete most of them, but now I'm stuck with a set that cannot be deleted as they remain attached to VMs nowhere to be found.Any ideas how to get rid of these disks, PowerShell tricks maybe? If I am understanding correct, Once you delete a Virtual Machine, it delete the service but keep a copy of the VHD image under Disks. So please go to the Disks tab under virtual Machine and try to delete it. If that is not the case, please add a screenshot w...

 azure                     4 answers                     49 view
 2018-10-22         Mike

Unable to authenticate cassandra cluster through spark scala program

Please suggest me to solve the below issue, or suggest me any different approach to achieve my problem statement.I am getting data from somewhere and inserting it into cassandra daily basis then I need to retrieve the data from cassandra for whole week and do some processing and insert result back onto cassandra.i have lot of records, each record executing most of the below operations. According to my previous post Repreparing preparedstatement warning suggestion, to avoid repreparing the prepared statement,tried to keep a map of query string vs prepared statements.I tried ...

 scala                     3 answers                     11 view

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