Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-08-19T02:46:24Z
Updated: 37 min 17 sec ago

How to use AuthorizationServerSecurityConfigurer?

38 min 20 sec ago

I am looking at a Spring boot project which has this code:

public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception { oauthServer .tokenKeyAccess("permitAll()") .checkTokenAccess("isAuthenticated()"); }

Unfortunately, I am not able to find any resources anywhere (i.e. Google, Spring docs, Spring oauth docs) that explains to me how to actually use AuthorizationServerSecurityConfigurer. Moreover, I do not understand exactly what tokenKeyAccess("permitAll()") or checkTokenAccess("isAuthenticated()") do.

Other than helping me understand what those two functions do, please help me learn where to look for these types of information in the future.

passing the data in $scope variable

39 min 58 sec ago

I am getting the data from my web service and storing the same data into my scope variable like

then(function (Tlist) { $scope.Tlist=Tlist.data; })

and displaying the same data into table, now in my table i am selecting the row by checkbox like

<td> <input type="checkbox" ng-checked="checkall" ng-model="Ldata.checked" data-ng-click="calculateTotal(Ldata)" /> </td>

and in my "calculateTotal(Ldata)" function i want to store the value of (Ldata.amount) into another $scope variable

this is how my condition inside the function looks

if (Ldata.checked) { $scope.total += Number(Ldata.amount); console.log(Ldata.amount); console.log(Number($scope.total)); }

but on

console.log(Number($scope.total));

line my result is coming as NaN but on this line and on console.log(Ldata.amount); this line my result is coming as 1400 so i am not able to understand why i am unable to pass data from one variable to another

How to redirect to my home page for expired web pages

40 min 56 sec ago

Now using my domain name for my Joomla website which was earlier redirected to a blogger blog. While the blog still exists with its blogspot.com ending domain name, the problem is the links which over the years I have shared on with the domain name that is now not connected with the blogspot.com.

So, if someone clicks a page like http://www.sdsolutions.firm.in/p/join-altos.html (which was earlier connected with blogger blog), how to redirect to the home page (or any other page of my choice which is live of my domain sdsolutions.firm.in).

Conditional dashboard in Ruby on Rails

41 min 16 sec ago

As a user, I want the root page to be dynamic based on different scenarios. As an example, let's say I have the following models:

class User end class Event end

Users can attend events and/or manage events.

The end goal is to have a dashboard that lists Events that the user is subscribed to, but also events that the user manages. Here's what I currently have:

class DashboardsController < ApplicationController def show @events = current_user.events @managed_events = current_user.managed_events end end

Then I have a view that shows both. These queries are slightly excessive if you only attend events or only manage events however.

Should I have a root path that directs to a controller action that ultimately redirects to the correct route based on if they only attend events, only manage events, or do both? Or would it be better to have some kind of single view that lists all events that they attend and manage together?

I'm unsure of the "Rails-way" kind of solution to this scenario.

Object Class in Java and Inheritance

41 min 22 sec ago

I have learnt java does not support multiple inheritance (in classes). Here is my doubt.

class A { //class definition } class B extends class A { //class definition }

Since every class implicitly extends object class .The code could mean something like this.

class A extends Object { //class definition } class B extends A ,Object { //class definition }

Does it mean something like this? Does this not violate java's multiple inheritance rule?

bash subsetting based on row and column names

42 min 16 sec ago

I have a big matrix 1.5M rows by 150,000 columns. I want subset this big matrix based on a given row and column names. Here is an example of big matrix

c1 c2 c3 c4 row1 11 12 13 14 row2 21 22 23 24 row3 31 32 33 34 row4 41 42 43 44 row5 51 52 53 54

I want select column c1 and c3 and the file name that contains these selected columns is called scol. The file name that contains selected rows called srow and contains row2 row4 row5

The output looks like as follows

c1 c3 row2 21 23 row4 41 43 row5 51 53

Any help?

Strange bug when concatenating two strings

43 min 19 sec ago

I have the following HTML element that I dynamically constructed:

var html = '<p name="var_"'; console.log(html); // prints out <p name="var_" as expected console.log(html + "aaa"); // prints out <p name="var_"aaa

Why does the second log not print out <p name="var_aaa? Why is there an extra " in front of aaa?

wc does not return an integer value

44 min 24 sec ago

I am trying to run this script:

#!/bin/sh cd $1 for i in */*.$2 do if [ 'wc –c $i' -gt $3 ] then chmod o-r $i fi done

When I run the script:

./script folder1 txt 500

I get this error:

./script: line 5: [: wc –c $i: integer expression expected ./script: line 5: [: wc –c $i: integer expression expected

Any ideas why wc is not returning an integer value?

I am using GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)

Get index of list of dictionaries while iterating through it

45 min 9 sec ago

I am using python v3.6.

I have a list of dictionaries which look like this;

dictionary_list = [{'f1': 'name1', 'f2':'1', 'f3':'4'}, {'f1': 'name2', 'f2':'2', 'f3':'5'}, {'f1': 'name3', 'f2':'3', 'f3':'6'}]

I have a simple for loop to iterate through this list of dictionary. I need to access the index of the list but this information is lost inside the loop. How do I modify the for loop to access the index?

for i in dictionary_list: #How to access the index in the dictionary_list pass

How to view prop values in the browser?

51 min 10 sec ago

I'm trying to view what props are getting passed to my component. Is there a way to log it in JSX? I'm using 2 functional components as in the following code block.

From the invocation I'm passing props as props:{programs:'Hello',locale:'en'}. It seems the props get into the ProgramsSummaryParent just fine but I am getting this message on the browser when it tries to render the ProgramsSummaryPlaceholder :

Failed prop type: The prop content is marked as required in TableCell, but its value is undefined.

Why am I unable to pass the prop?

const ProgramsSummaryParent = ({programs, locale,}) => ( <BaseSummary locale={locale}> <ProgramsSummaryPlaceholder prg={programs}/> </BaseSummary> ); const ProgramsSummaryPlaceholder = ({ prg, intl, }) => ( <div className="programs-summary"> <Table isStriped={true} isPadded={true}> <Table.Rows > <Table.Row > <Table.Cell content={prg.programs} /> </Table.Row> </Table.Rows> </Table> </div> );

style attribute '@android:attr/windowEnterAnimation' not found

53 min 30 sec ago

I opened the android project, i got this error, how do i fix it?

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar] Warning:The android.dexOptions.incremental property is deprecated and it has no effect on the build process. /Users/Ren/Desktop/17live/app/src/main/res/values/styles.xml Error:(515, 5) style attribute '@android:attr/windowEnterAnimation' not found Error:(515, 5) style attribute '@android:attr/windowExitAnimation' not found Error:(577, 5) style attribute '@android:attr/windowEnterAnimation' not found Error:(577, 5) style attribute '@android:attr/windowExitAnimation' not found Error:/Users/Ren/Desktop/17live/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:3534 style attribute '@android:attr/windowEnterAnimation' not found Error:/Users/Ren/Desktop/17live/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:3796 style attribute '@android:attr/windowEnterAnimation' not found Error:failed linking references Error:java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.AaptException: AAPT2 link failed: Error:com.android.builder.internal.aapt.AaptException: AAPT2 link failed: Error:Execution failed for task ':app:processDebugResources'.

Failed to execute aapt Information:BUILD FAILED in 13s Information:10 errors Information:1 warning Information:See complete output in console

do while answer is outside of number range or not a number

55 min 1 sec ago

I created a simple prompt that allows a user to input a number between 1 and 10. First I change answer from a string into a number. Second I check to see if answer is between 1 and 10 or is NaN. If answer is outside 1 and 10 or NaN the loop runs and checks again. while correctly detects if numbers are less than 1 or greater than 10 however it doesn't properly detect if answer == NaN. I'm not sure why it doesn't work with letters because the alert indicates that answer does = NaN when I input letters. Can anybody see what I'm doing wrong?

var answer; do { answer = prompt("Enter a number between 1 and 10."); answer = Number(answer); } while (answer < 1 || answer > 10 || answer == NaN); alert(answer);

How to capture the channel messages in Telegram using Telethon?

59 min 29 sec ago

I want to capture the channel messages and send them to another python function. By using the documentation, I'm able to connect to Telegram server and do the authentication. However, I'm not able to find out how to capture the channel messages.

The documentation provides the following method:

channels.getMessages#93d7b347 channel:InputChannel id:Vector<int> = messages.Messages

channel is an InputChannel. Below is the documentation

inputChannel#afeb712e channel_id:int access_hash:long = InputChannel

I'm not able to understand how to get the channel_id and the access_hash. Also I do not understand what to provide for id:Vector<int>

If I want to capture each message. Do I have to run this within an infinite loop? A small example will be greatly appreciated.

Declaring Size of Array Using Variable

1 hour 48 sec ago
#include <stdio.h> #include <stdlib.h> #pragma warning (disable : 4996) void main() { int matrix[30][50]; int sizeRow, sizeCol; printf("Number of Rows in your table : "); scanf("%d", &sizeRow); printf("Number of Columns in your table : "); scanf("%d", &sizeCol); int sum[sizeRow] = { 0 }; for (int row = 0; row < sizeRow; row++){ for (int col = 0; col < sizeCol; col++){ printf("Input element [%d][%d] : ", row, col); scanf("%d", &matrix[row][col]); sum[row] += matrix[row][col]; } } printf("Total of each row:\n"); for (int row = 0; row < sizeRow; row++){ printf("ROW[%d] SUM :\t%d\n", row, sum[row]); } system("pause"); }

I am getting error in the int sum[sizeRow] = { 0 }; where it says that my array should be a constant but the user in my case should determine the array size. Any way I can fix this?

How can i replace the Dom Elements in jquery

1 hour 6 min ago

How to Replace the dom element in jquery ?

I tried the replaceWith function but What i want is after the changing in the select box

$('select[name="role_id"]').on('change',function(){ if ($(this).val() == 3){ // I want to replace the role_id name into product_id } }

laravel 5.4 varchar field migration

1 hour 8 min ago

When you create a migration and you have a string field like varchar you set it like the code below but I get an error in a migration saying that it's too many bytes

Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email')->unique(); $table->timestamps(); });

So if I do this

$table->string('email', 255)->unique();

Setting it to it's maximum of 255 I still get the same error and I'm sure that 255 is the maximum for a varchar field but if I make the field 250 in the varchar field I get no errors. So what's going on with the migrations in laravel 5.4

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 1000 bytes (SQL: alter table users add unique users_email_unique(email))

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 1000 bytes

Difference between Promise.all and running Promises serially?

2 hours 1 min ago

Say I have a bunch of promises.

const promises = [ /*...*/ ];

And I want something to happen when all the promises have resolved. What's the difference between the following two ways of doing this:

  1. Using Promise.all

    const allDonePromise = Promise.all(promises);
  2. Running the promises serially

    async function allPromises(promisesArray) { const results = []; for (const promise of promisesArray) { results.push(await promise); } return results; } const allDonePromises = allPromises(promises);

Is Promise.all just a builtin which does what allPromises does or is there something else happening under the hood to make Promise.all faster. Where can I find information about the internals of Promise.all?

HOC to add prop if it's a certain type

Fri, 08/18/2017 - 23:38

I was trying to write a HOC that adds a prop if it's a certain type. I am iterating through it depth first. But when I try to set prop it says it's not extensible, I am trying to add prop of value to HEEHAW:

function fieldLayoutHOC(WrappedComponent: ComponentType) { return ( class FieldLayoutWrap extends WrappedComponent { static displayName = wrapDisplayName(WrappedComponent, 'FieldLayoutWrap') render() { const view = super.render() // depth first - stack - last in first out // iterate depth first until a Field is found const elements = [view]; // stack console.log('view:', view); while (elements.length) { const element = elements.pop(); const primative = typeof element; if (primative === 'object') { if (element.type === Field) { // fields.push(element); element.props.value = 'HEEHAW'; /////// not extensible error here console.log('added value HEEHAWW'); } else { if (element.props) { const children = element.props.children; if (children) { if (Array.isArray(children)) { elements.push(...children); } else { elements.push(children); } } } } } } return view; } } ) }

Am I doing it wrong?

NPM Upgrade on windows server 2008 for All Users

Fri, 08/18/2017 - 18:59

I have installed NPM on a window 2008 server. I have then upgraded to the latest npm 5.3 running the following command npm -g install npm.

I then check the NPM version.

NPM --version returns 5.3 so all looks good.

I then log onto the server as a second user and run NPM -version and the version of npm that is returned, is 3.10.

Is there a way to upgrade NPM for all users on a server to the same version. I do not want to have to log onto a server as each user and upgrade NPM.

Send Recv from client to server socket by establish TCP Connection only once

Fri, 08/18/2017 - 16:23

I am working on a client/server solution in C++.

From the client, I am sending data to my server, and from this server I am sending to another server. I am able to configure port and IP address, and am able to send successfully.

But, the other server (which is not on my side) needs to establish only one TCP connection from my side, after that only sending and receiving needs to happen.

If I am connecting twice (say from two clients at the same time), it shows connection refused.

Part of the code is shown below:

while ((len = stream->receive(input, sizeof(input)-1)) > 0 ) { input[len] = NULL; //Code Addition by Srini starts here //Client declaration TCPConnector* connector_client = new TCPConnector(); printf("ip_client = %s\tport_client = %s\tport_client_int = %d\n", ip_client.c_str(), port_client.c_str(),atoi(port_client.c_str())); TCPStream* stream_client = connector_client->connect(ip_client.c_str(), atoi(port_client.c_str())); //Client declaration ends if (stream_client) { //message = "Is there life on Mars?"; //stream_client->send(message.c_str(), message.size()); //printf("sent - %s\n", message.c_str()); stream_client->send(input, sizeof(input)); printf("sent - %s\n", input); len = stream_client->receive(line, sizeof(line)); line[len] = NULL; printf("received - %s\n", line); delete stream_client; } //Code Additon by Srini ends here stream->send(line, len); printf("thread %lu, echoed '%s' back to the client\n", (long unsigned int)self(), line); }

The full thread code where receiving from client, sending to server, receiving from server, and sending to client is shown in the below link:

https://pastebin.com/UmPQJ70w

How can I change my design flow? Even in a basic diagram of client/server program. When the client calls connect(), then the server calls accept() every time, then sending/receiving happens. So, what can be done to modify the flow so that the client can connect only once?

Pages