qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
56,376,134
I will read data from a file, I have only two number in file are(1.63 , -0.21),output : ``` {'y': array([-0.21]), 'x': array([1.63])} ``` I need the output like this: ``` position = {'x': 1.63 , 'y' : -0.21} ``` this my code: ``` import pandas as pd import numpy as np def read(): data = pd.read_csv('distan...
2019/05/30
[ "https://Stackoverflow.com/questions/56376134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11162983/" ]
try this ``` import numpy as np data = np.genfromtxt('distance.csv', dtype=list).tolist() x0,y0 = float(data[0]), float(data[1]) position = {'x': x0 , 'y' : y0} print position ``` the output is: ``` {'y': -0.7, 'x': 1.7} ```
by this way worked but it is long ``` import pandas as pd import numpy as np import csv def read(): data_path = 'distance.csv' with open(data_path, 'r') as f: reader = csv.reader(f, delimiter=',') # get all the rows as a list data = list(reader) # transform data into numpy arra...
56,116,467
I have blogposts that I need to render. The first 4 are shown. When clicking on the button underneath it, two more need to show up. When the button is clicked again, two more need to show up and so on. Unfortunately, I am not able to do so. Here is my code: ``` import React from 'react'; import axios from 'axios'; im...
2019/05/13
[ "https://Stackoverflow.com/questions/56116467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7965439/" ]
Since you're only using `args` as an array, you could remove `axios.spread`. `axios.spread()` might only be useful in older browsers now that ES2015 introduced its own [*spread* operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax). The main purpose of `axios.spread()` is...
To avoid promise chaining and improve readability, I think below can be used. ``` const [arg1, arg2] = await Promise.all(promises) ```
56,116,467
I have blogposts that I need to render. The first 4 are shown. When clicking on the button underneath it, two more need to show up. When the button is clicked again, two more need to show up and so on. Unfortunately, I am not able to do so. Here is my code: ``` import React from 'react'; import axios from 'axios'; im...
2019/05/13
[ "https://Stackoverflow.com/questions/56116467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7965439/" ]
Axios.all ========= as well as [Promise.all](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) accepts array of promises and returns a new Promise which is resolved whenever all of the given promises are resolved with an array with the result of each promise e.g. ``` const...
Since you're only using `args` as an array, you could remove `axios.spread`. `axios.spread()` might only be useful in older browsers now that ES2015 introduced its own [*spread* operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax). The main purpose of `axios.spread()` is...
56,116,467
I have blogposts that I need to render. The first 4 are shown. When clicking on the button underneath it, two more need to show up. When the button is clicked again, two more need to show up and so on. Unfortunately, I am not able to do so. Here is my code: ``` import React from 'react'; import axios from 'axios'; im...
2019/05/13
[ "https://Stackoverflow.com/questions/56116467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7965439/" ]
Axios.all ========= as well as [Promise.all](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all) accepts array of promises and returns a new Promise which is resolved whenever all of the given promises are resolved with an array with the result of each promise e.g. ``` const...
To avoid promise chaining and improve readability, I think below can be used. ``` const [arg1, arg2] = await Promise.all(promises) ```
53,979,189
I wish to replace character `'/'` when occurred in a certain pattern (preceded and followed by a character) with `""`. Example 1. `"a/b b/c"` should be replaced to `"ab bc"` 2. `"a/b python/Java"` should be replaced to `"ab python/Java"` While, I know how to substitute using regex `re.sub("/","","a/b python")`, the ...
2018/12/30
[ "https://Stackoverflow.com/questions/53979189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3788040/" ]
This simplifies and expands on [Code Maniac's](https://stackoverflow.com/users/9624435/code-maniac) comment: You can replace a found pattern using [re.sub](https://docs.python.org/3/library/re.html#re.sub) ``` import re regex = r"(\b\w)\/(\w\b)" # do not capture the / test_str = """a/b b/c a/b python/Java""" subst...
What you might do is to first match the pattern with a 1+ characters, `/`, 1+ characters between double quotes. Then because the pattern matches, you could split the string and check if then item has a string length of 3. If it does, use map and replace the `/` with an empty string and reconstruct the string. Match t...
43,186,918
I would like to create a list of car makers with their models. For this I'm using dictionary, where the key is the make and the item is a collection of models. For example: The key in the dictionary is "Volkswagen" and the collection contains polo, cc, passat, etc... The code reads the items from a worksheet. The probl...
2017/04/03
[ "https://Stackoverflow.com/questions/43186918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7307138/" ]
Here is a minimal example of: * Creating a dictionary * Creating collections and adding to dictionary with a key of `String` * Iterating each item of the dictionary * Printing the item in each collection that is dictionary value You can adapt the sample code to suit your worksheet: ``` Option Explicit Sub TestDicti...
I've corrected some things and taken liberties with others to get your code to work. It's a good idea to use the option explicit directive as it helps with debugging: ``` Option Explicit Sub collectModels() Dim imp_wb As Workbook Dim ws_model_list As Worksheet Dim lastRow As Long, lastCol As Long Dim model_...
43,186,918
I would like to create a list of car makers with their models. For this I'm using dictionary, where the key is the make and the item is a collection of models. For example: The key in the dictionary is "Volkswagen" and the collection contains polo, cc, passat, etc... The code reads the items from a worksheet. The probl...
2017/04/03
[ "https://Stackoverflow.com/questions/43186918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7307138/" ]
Here is a minimal example of: * Creating a dictionary * Creating collections and adding to dictionary with a key of `String` * Iterating each item of the dictionary * Printing the item in each collection that is dictionary value You can adapt the sample code to suit your worksheet: ``` Option Explicit Sub TestDicti...
It is important to handle empty cells. As soon as a list is over, then the code saves the dictionary with the collection. To refer to the collection inside the dictionary you have to create a loop inside a loop. ``` ws_model_list.Activate lastRow = Last(1) lastCol = Last(2) Set dict_ModelMapping = CreateObject("scrip...
26,289,256
I am looking to select multiple items in my DB based on the primary key. so if I have the name I want to select imagename and refName from the DB. I found something here <http://www.objectdb.com/java/jpa/query/jpql/select> ``` TypedQuery<Object[]> query = em.createQuery( "SELECT c.name, c.capital.name FROM Cou...
2014/10/09
[ "https://Stackoverflow.com/questions/26289256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3599960/" ]
The problem is because of this code: ``` q.setParameter("i.name", plan.getFace()[i].name); ``` Take a look at your JPQL: ``` SELECT i.name, i.refName, i.imageName FROM Items AS i ``` You have no parameter named `i.name`. You should create one that will receive the parameter. Something like ``` SELECT i.name,...
The problem is param name ``` TypedQuery<Object[]> q = em2.createQuery("SELECT i.name, i.refName, i.imageName FROM Items WHERE i.name = :someparam AS i",Object[].class); q.setParameter("someparam", plan.getFace()[i].name); ```
56,216,756
It's troubling me building an array of objects with a lot of data in qml using the Windows platform (it's the only one that the crash happens). For some reason the application is crashing if the processing function takes too long! I'm going to illustrate with a portion of code what i want to do: `main.qml` ``` impor...
2019/05/20
[ "https://Stackoverflow.com/questions/56216756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4663570/" ]
you have a bug here ``` ... for(var pSndrModeAdd=0; 32; pSndrModeAdd++) { ... ``` and the loop will run forever. Change to ``` ... for(var pSndrModeAdd=0; pSndrModeAdd<32; pSndrModeAdd++) { ... ``` Anyway, arrays in QML are just JavaScript arrays, as such have (practically) no maximum size.
It turns out the crashing of the application only happens on the windows platform. In MACOS and LINUX it only blocks for the time of the function processing. Maybe it really is a memory problem after all, that happens on windows using versions of QT that use MinGW 32-bit. The solution to solve this problem? The usag...
14,559,035
I am trying to animate a div to move to the right when I click its grandchild. However I am constantly running into a problem with the timing. My doubt is that I am not using the `setTimeout` function right. Could someone kindly see if they spot an error. I would prefer if my own function worked rather than using a `jq...
2013/01/28
[ "https://Stackoverflow.com/questions/14559035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1996198/" ]
Yes you are incrementing synchronously before calling the async `setTimeout`. Here's how it can be done: ``` var element = element.parentNode.parentNode; var i=0, myVar; function sendrequest(){ if (i < 150) { var right = i+"%"; element.style.right = right; i++; myVar = setTimeout(sendre...
Please add a css style where you use TRANSLATE. so this would help you, rather than using setTimeOut, because it is basically system clock cycle which can give nasty results, so i would prefer that dont depend on it simply use following format ``` el.on('click', function(){ document.getElementByid("#id"...
6,874,162
I have records in my db as below ``` userid email first_name SUM Currency_flag 1 abc@gmail.com User2 8609.00 0 1 abc@gmail.com User2 12.00 1 9 xyz@gmail.com User1 99.00 0 9 xyz@gmail.com User1 200.00 1 34 qwer@gmail.com User3 345.00 0 ...
2011/07/29
[ "https://Stackoverflow.com/questions/6874162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/869487/" ]
try this: ``` SELECT `userid`, `email`, `first_name`, SUM(IF(`currency_flag`=0, `SUM`, 0)) AS `SUM_0` SUM(IF(`currency_flag`=1, `SUM`, 0)) AS `SUM_1` FROM `users` GROUP BY (`userid`) ```
``` select userid,email,first_name,sum(if(currency_flag=0,SUM,0)),sum(if(currency_flag=1,SUM,0)) from table group by 1 ```
6,874,162
I have records in my db as below ``` userid email first_name SUM Currency_flag 1 abc@gmail.com User2 8609.00 0 1 abc@gmail.com User2 12.00 1 9 xyz@gmail.com User1 99.00 0 9 xyz@gmail.com User1 200.00 1 34 qwer@gmail.com User3 345.00 0 ...
2011/07/29
[ "https://Stackoverflow.com/questions/6874162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/869487/" ]
One way of doing this is a self-join: ``` SELECT A.UserID, A.Email, A.First_Name, A.SUM AS SUM_0, B.SUM AS SUM_1 FROM (SELECT * FROM AnonymousTable WHERE Currency_Flag = 0) AS A JOIN (SELECT UserID, SUM FROM AnonymousTable WHERE Currency_Flag = 1) AS B ON A.UserID = B.UserID; ```
``` select userid,email,first_name,sum(if(currency_flag=0,SUM,0)),sum(if(currency_flag=1,SUM,0)) from table group by 1 ```
37,906,667
I have a service `MoneyMover` that change state of two entities: reduce `amount` of money from `sender` and adds this amount to `receiver`. I don't have implementation yet. And according to BDD I'm writing spec for this feature: ``` function it_should_reduce_balance_of_sender(User $sender, User $receiver) { $send...
2016/06/19
[ "https://Stackoverflow.com/questions/37906667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2261177/" ]
For me it was caused by the `angular2-universal-polyfills` package that contains an old version of the `reflect-metadata` package. I've fixed it by downloading the actual reflect-metadata with npm: ``` npm install reflect-metadata ``` Then copied the node\_modules\reflect-metadata folder into the node\_modules\angul...
Latest tsconfig.json from webpack introduction article looks like below- ``` { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicit...
37,906,667
I have a service `MoneyMover` that change state of two entities: reduce `amount` of money from `sender` and adds this amount to `receiver`. I don't have implementation yet. And according to BDD I'm writing spec for this feature: ``` function it_should_reduce_balance_of_sender(User $sender, User $receiver) { $send...
2016/06/19
[ "https://Stackoverflow.com/questions/37906667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2261177/" ]
For me it was caused by the `angular2-universal-polyfills` package that contains an old version of the `reflect-metadata` package. I've fixed it by downloading the actual reflect-metadata with npm: ``` npm install reflect-metadata ``` Then copied the node\_modules\reflect-metadata folder into the node\_modules\angul...
The `reflect-metadata` package has a dependency over `crypto` so install them as, `npm install reflect-metadata crypto --save`
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
We had our first session last night and it was a tremendous success. We used Skype for both in-character text chat and out-of-character rules and clarifying discussion. I really like this because the result is a relatively clean transcript of the actual in-character bits and speedier resolution of the mechanical elemen...
You have to have a rules of order so that people aren't typing over each other and causing there to be multiple conversations going on at the same time in a shared chatbox. It can be an issue, but having some way for people to buzz in (such as a smiley emoticon as the signal they want to talk) can help keep order. As...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I played in an IRC game back in college. I don't remember how long the sessions lasted, but the game fizzled after a month or two. **Pros** 1. The GM was able to copy and paste description. I think his doing this was what kept the game going at a good pace. 2. IRC dice rolling was easy. /roll 2d10. Trivial. 3. Infini...
You have to have a rules of order so that people aren't typing over each other and causing there to be multiple conversations going on at the same time in a shared chatbox. It can be an issue, but having some way for people to buzz in (such as a smiley emoticon as the signal they want to talk) can help keep order. As...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
We much preferred [VSee](http://vsee.com/) to other chat programs and play-by-post or -e-mail gaming. As far as dice goes, you can't go wrong with [dicelog](http://dicelog.com/dice). The most difficult challenges was keeping people focused, from a DM perspective. Being at the same table contributes a lot. I combated t...
You have to have a rules of order so that people aren't typing over each other and causing there to be multiple conversations going on at the same time in a shared chatbox. It can be an issue, but having some way for people to buzz in (such as a smiley emoticon as the signal they want to talk) can help keep order. As...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I ran D&D games on IRC for several years. The biggest challenges were: 1. **Agreeing on a game time is tricky.** When you've got international players, this is a major factor. We used a Google Calendar to post availability, and picked times when five or more were available. 2. **Communication is more cumbersome online...
I played in an IRC game back in college. I don't remember how long the sessions lasted, but the game fizzled after a month or two. **Pros** 1. The GM was able to copy and paste description. I think his doing this was what kept the game going at a good pace. 2. IRC dice rolling was easy. /roll 2d10. Trivial. 3. Infini...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I've played in numerous text-based games and the problems I encountered in those inspired me to work on my own text based gaming medium. While this answer will sum up problems I've encountered as Jonathan already mentioned some, it's also an ad for my free, non-profit text based roleplaying platform. But first, issues...
I played in an IRC game back in college. I don't remember how long the sessions lasted, but the game fizzled after a month or two. **Pros** 1. The GM was able to copy and paste description. I think his doing this was what kept the game going at a good pace. 2. IRC dice rolling was easy. /roll 2d10. Trivial. 3. Infini...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I've played in numerous text-based games and the problems I encountered in those inspired me to work on my own text based gaming medium. While this answer will sum up problems I've encountered as Jonathan already mentioned some, it's also an ad for my free, non-profit text based roleplaying platform. But first, issues...
We much preferred [VSee](http://vsee.com/) to other chat programs and play-by-post or -e-mail gaming. As far as dice goes, you can't go wrong with [dicelog](http://dicelog.com/dice). The most difficult challenges was keeping people focused, from a DM perspective. Being at the same table contributes a lot. I combated t...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I ran D&D games on IRC for several years. The biggest challenges were: 1. **Agreeing on a game time is tricky.** When you've got international players, this is a major factor. We used a Google Calendar to post availability, and picked times when five or more were available. 2. **Communication is more cumbersome online...
I've played in numerous text-based games and the problems I encountered in those inspired me to work on my own text based gaming medium. While this answer will sum up problems I've encountered as Jonathan already mentioned some, it's also an ad for my free, non-profit text based roleplaying platform. But first, issues...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I ran D&D games on IRC for several years. The biggest challenges were: 1. **Agreeing on a game time is tricky.** When you've got international players, this is a major factor. We used a Google Calendar to post availability, and picked times when five or more were available. 2. **Communication is more cumbersome online...
You have to have a rules of order so that people aren't typing over each other and causing there to be multiple conversations going on at the same time in a shared chatbox. It can be an issue, but having some way for people to buzz in (such as a smiley emoticon as the signal they want to talk) can help keep order. As...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I ran D&D games on IRC for several years. The biggest challenges were: 1. **Agreeing on a game time is tricky.** When you've got international players, this is a major factor. We used a Google Calendar to post availability, and picked times when five or more were available. 2. **Communication is more cumbersome online...
We had our first session last night and it was a tremendous success. We used Skype for both in-character text chat and out-of-character rules and clarifying discussion. I really like this because the result is a relatively clean transcript of the actual in-character bits and speedier resolution of the mechanical elemen...
16,875
I'm specifically looking for feedback from people that have tried real-time instant messaging systems, not asynchronous play-by-post or play-by-email. What were the most difficult challenges? Were you able to overcome them? What were the best aspects of playing like this? How long were your sessions? Was this too long...
2012/09/22
[ "https://rpg.stackexchange.com/questions/16875", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/4458/" ]
I ran D&D games on IRC for several years. The biggest challenges were: 1. **Agreeing on a game time is tricky.** When you've got international players, this is a major factor. We used a Google Calendar to post availability, and picked times when five or more were available. 2. **Communication is more cumbersome online...
We much preferred [VSee](http://vsee.com/) to other chat programs and play-by-post or -e-mail gaming. As far as dice goes, you can't go wrong with [dicelog](http://dicelog.com/dice). The most difficult challenges was keeping people focused, from a DM perspective. Being at the same table contributes a lot. I combated t...
66,223,260
i want to delete duplicated lists from main list input : `[['a','b'],['c','f'],['a','b'],['d','f']]` output: `[['a','b'],['c','f'],['d','f']]`
2021/02/16
[ "https://Stackoverflow.com/questions/66223260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15219984/" ]
Try ``` df[!,"x"] = convert.(Float64, df[!,"x"]) ``` Note the "!" in brackets - this gives you the actual `DataFrame` column (analogue to the dot notation), whereas ":" gives a copy of it.
you can alternatively write: ``` julia> df = DataFrame(rand(1:10, 3, 4), :auto) 3×4 DataFrame Row │ x1 x2 x3 x4 │ Int64 Int64 Int64 Int64 ─────┼──────────────────────────── 1 │ 9 7 7 10 2 │ 2 5 7 10 3 │ 6 4 9 1 julia> transform!(df, ...
39,686,636
Hi I am writing unit test cases for a program. In that program I am testing a certain method in which their is this method : Collections.sort(Arraylist object). Its something like this. ``` public void abc(){ try{ Arraylist<object_class> object=some_method.get(list); Collections.sort(object); System.out....
2016/09/25
[ "https://Stackoverflow.com/questions/39686636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6649483/" ]
This is wrong on many levels: 1. You are using a **raw** type there (by using ArrayList **without** a generic type parameter) - never do that! 2. If your test setup makes that other method return null, then don't manipulate "later" code - instead either avoid that **null** or make sure your production code can deal wi...
> > I can return a mock list to object but I want to know if I can prevent Collections.sort() from executing. > > > I don't see a way to prevent that `Collections.sort()` is executed as long as the method that calls it is executed and as long as you can't change the tested code. The reason is that `sort` is a stat...
39,686,636
Hi I am writing unit test cases for a program. In that program I am testing a certain method in which their is this method : Collections.sort(Arraylist object). Its something like this. ``` public void abc(){ try{ Arraylist<object_class> object=some_method.get(list); Collections.sort(object); System.out....
2016/09/25
[ "https://Stackoverflow.com/questions/39686636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6649483/" ]
It' simple if you want to execute Collections.sort() without any exception follow below steps: 1) Create a list object with dummy values in your test class and send it to main class ``` list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); ``` 2) Second step is make sure that your ``` some_method...
> > I can return a mock list to object but I want to know if I can prevent Collections.sort() from executing. > > > I don't see a way to prevent that `Collections.sort()` is executed as long as the method that calls it is executed and as long as you can't change the tested code. The reason is that `sort` is a stat...
39,686,636
Hi I am writing unit test cases for a program. In that program I am testing a certain method in which their is this method : Collections.sort(Arraylist object). Its something like this. ``` public void abc(){ try{ Arraylist<object_class> object=some_method.get(list); Collections.sort(object); System.out....
2016/09/25
[ "https://Stackoverflow.com/questions/39686636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6649483/" ]
It' simple if you want to execute Collections.sort() without any exception follow below steps: 1) Create a list object with dummy values in your test class and send it to main class ``` list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); ``` 2) Second step is make sure that your ``` some_method...
This is wrong on many levels: 1. You are using a **raw** type there (by using ArrayList **without** a generic type parameter) - never do that! 2. If your test setup makes that other method return null, then don't manipulate "later" code - instead either avoid that **null** or make sure your production code can deal wi...
6,833,207
I have been learning Android for a few days (or at least trying), but I can get around Drawables, ColorDrawables and so on. I tried using a simple ColorDrawable that fills the whole screen with a red color... ``` <color xmlns:android="http://schemas.android.com/apk/res/android"> android:color="#FFFF0000" </color> ```...
2011/07/26
[ "https://Stackoverflow.com/questions/6833207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/833937/" ]
For a solid color, in particular, you normally wouldn't bother with a ColorDrawable in code because most standard classes give you a `setBackgroundColor(int)`; and in XML the `android:background attribute` lets you specify a color. Let's assume you have more complicated things in mind. In general, you'll use `Drawabl...
See if this helps [Drawable Manual](http://idunnolol.com/android/drawables.html)
107,740
I must admit, that despite having spoken English for quite some time, i still cannot grasp all the intricacies of articles. My native tongue just doesn't have them, and they continue to perplex me. The phrase "jump in the air" seems to stand out as something unusual. One is not jumping into the tank with some specific...
2016/10/28
[ "https://ell.stackexchange.com/questions/107740", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/25577/" ]
There are certain uncountable nouns used in idiomatic phrases that behave in this way. After all, we see similar wording with: * swim in the ocean * a stab in the dark * bring home the bacon * another one bites the dust * turn up the volume * hands in the air However, I understand your confusion! After all, we [gener...
I don't agree with "whatever air one meets there is quite irrelevant and unknown." Whatever air you meet there is quite specific. It is the specific air you are jumping into. Just like *the ground* you land on is the specific ground that forms your landing place. Otherwise, it is not really common to say *jump in ...
34,650,369
Please tell me whats wrong in the below coding? It gives the following error! **SyntaxError: unexpected character after line continuation character** ``` while True: for i in ["\","-","|","\\","|"]: print "%s\r" % i, ```
2016/01/07
[ "https://Stackoverflow.com/questions/34650369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5756351/" ]
`Append` add each element when you pass on parameter, but each `''` is one parameter. Please try with `after` event. `After` accept multiple data ``` function myusr_lst_get(myData, txtSts, rslt){ try { var myData = null; var ret = JSON.parse(rslt.responseText); if( ret.ret != null && ret.r...
instead of append tr tag in for loop first create html string and then append to the element, this will also improve performance. ``` var str = ''; for(var i = 0; i < myData.length; i++) { str +='<tr><td>'+ myData[i].user_name +'</td><td><a href="javascript:void(0)" onclick="if(confirm(\'Do you want to delete? \')){...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
I'm also looking for the answer to this problem. With `max-width`, `width=` and `height=`, the browser has enough data that it *should* be able to leave the right amount of space for an image but it just doesn't seem to work that way. I worked around this with a jQuery solution for now. It requires you to provide the ...
For a css only solution, you can wrap the `img` in a container where the `padding-bottom` percentage reserves space on the page until the image loads, preventing reflow. Unfortunately, this approach does require you to include the image aspect ratio in your css (but no need for inline styles) by calculating (or lettin...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
If I understand the requirements ok, you want to be able to set an image size, where this size is known only on content (HTML) generation, so it can be set as inline styles. But this has to be independent of the CSS, and also prior to image loading, so also independent from this image sizes. I have come to a solutio...
I find the best solution is to create a transparent base64 gif with corresponding dimensions as a placeholder for img tags where loading is triggered via js after page is loaded. ``` <img data-src="/image.png" src="data:image/gif;base64,R0lGODlhyAAsAYABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="> ``` For blog post...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
**UPDATE 2:** (Dec 2019) Firefox and Chrome now deal with this by default. Simply add the `width` and `height` attributes as normal. See [this blog post](https://dev.to/ben/firefox-and-other-browsers-will-be-making-better-use-of-height-and-width-attributes-for-modern-sites-4kpm) for more details. --- **UPDATE 1:** (...
If I understand the requirements ok, you want to be able to set an image size, where this size is known only on content (HTML) generation, so it can be set as inline styles. But this has to be independent of the CSS, and also prior to image loading, so also independent from this image sizes. I have come to a solutio...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
**UPDATE 2:** (Dec 2019) Firefox and Chrome now deal with this by default. Simply add the `width` and `height` attributes as normal. See [this blog post](https://dev.to/ben/firefox-and-other-browsers-will-be-making-better-use-of-height-and-width-attributes-for-modern-sites-4kpm) for more details. --- **UPDATE 1:** (...
I find the best solution is to create a transparent base64 gif with corresponding dimensions as a placeholder for img tags where loading is triggered via js after page is loaded. ``` <img data-src="/image.png" src="data:image/gif;base64,R0lGODlhyAAsAYABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="> ``` For blog post...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
I'm also looking for the answer to this problem. With `max-width`, `width=` and `height=`, the browser has enough data that it *should* be able to leave the right amount of space for an image but it just doesn't seem to work that way. I worked around this with a jQuery solution for now. It requires you to provide the ...
If I understand the requirements ok, you want to be able to set an image size, where this size is known only on content (HTML) generation, so it can be set as inline styles. But this has to be independent of the CSS, and also prior to image loading, so also independent from this image sizes. I have come to a solutio...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
For a css only solution, you can wrap the `img` in a container where the `padding-bottom` percentage reserves space on the page until the image loads, preventing reflow. Unfortunately, this approach does require you to include the image aspect ratio in your css (but no need for inline styles) by calculating (or lettin...
I find the best solution is to create a transparent base64 gif with corresponding dimensions as a placeholder for img tags where loading is triggered via js after page is loaded. ``` <img data-src="/image.png" src="data:image/gif;base64,R0lGODlhyAAsAYABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="> ``` For blog post...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
**UPDATE 2:** (Dec 2019) Firefox and Chrome now deal with this by default. Simply add the `width` and `height` attributes as normal. See [this blog post](https://dev.to/ben/firefox-and-other-browsers-will-be-making-better-use-of-height-and-width-attributes-for-modern-sites-4kpm) for more details. --- **UPDATE 1:** (...
I'm also looking for the answer to this problem. With `max-width`, `width=` and `height=`, the browser has enough data that it *should* be able to leave the right amount of space for an image but it just doesn't seem to work that way. I worked around this with a jQuery solution for now. It requires you to provide the ...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
**UPDATE 2:** (Dec 2019) Firefox and Chrome now deal with this by default. Simply add the `width` and `height` attributes as normal. See [this blog post](https://dev.to/ben/firefox-and-other-browsers-will-be-making-better-use-of-height-and-width-attributes-for-modern-sites-4kpm) for more details. --- **UPDATE 1:** (...
For a css only solution, you can wrap the `img` in a container where the `padding-bottom` percentage reserves space on the page until the image loads, preventing reflow. Unfortunately, this approach does require you to include the image aspect ratio in your css (but no need for inline styles) by calculating (or lettin...
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
I'm also looking for the answer to this problem. With `max-width`, `width=` and `height=`, the browser has enough data that it *should* be able to leave the right amount of space for an image but it just doesn't seem to work that way. I worked around this with a jQuery solution for now. It requires you to provide the ...
At first I would like to write about the answer from october 2013. This was incomplete copied and because of them it is not correct. Do not use it. Why? We can see it in this snippet (scroll the executed snippet to the bottom): ```js $('img').each(function() { var aspect_ratio = $(this).attr('height') / $(this)....
16,850,988
When I use image tags in html, I try to specify its width and height in the `img` tag, so that the browser will reserve the space for them even before the images are loaded, so when they finish loading, the page does not reflow (the elements do not move around). For example: ``` <img width="600" height="400" src="..."...
2013/05/31
[ "https://Stackoverflow.com/questions/16850988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1269021/" ]
**UPDATE 2:** (Dec 2019) Firefox and Chrome now deal with this by default. Simply add the `width` and `height` attributes as normal. See [this blog post](https://dev.to/ben/firefox-and-other-browsers-will-be-making-better-use-of-height-and-width-attributes-for-modern-sites-4kpm) for more details. --- **UPDATE 1:** (...
At first I would like to write about the answer from october 2013. This was incomplete copied and because of them it is not correct. Do not use it. Why? We can see it in this snippet (scroll the executed snippet to the bottom): ```js $('img').each(function() { var aspect_ratio = $(this).attr('height') / $(this)....
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
You might try `ps -aux | grep foobar` for getting the pid, then issuing the `kill` command against it, alternatively you might want to use [**`pkill`**](http://en.wikipedia.org/wiki/Pkill)`foobar`, in both cases `foobar` being the name of the app you want to terminate.
If you're starting this application from script you can get the pid of the last process that was created in background by using the special variable `$!`, this value you can save on a file for later use on your shutdown function. Below is an example: ``` nohup java -jar example.jar & echo $! > application.pid ```
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
you can use `pidof` to get the pid of your application `pidof <application name>`
[Find the pid of a java process under Linux](https://stackoverflow.com/questions/10201589/find-the-pid-of-a-java-process-under-linux) you can refer to this link...it tell you about finding a pid of specific class name
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
pid's for java processes -e.g `ps -aux | grep java | awk '{print $2}'` . You can also call `jps` which will give you a process list. A drawback of this is that it will only show you processes for the user issuing the jps command.
How about this then? ``` public static void killAll(String process) { try { Vector<String> commands = new Vector<String>(); commands.add("pidof"); commands.add(process); ProcessBuilder pb = new ProcessBuilder(commands); Process pr = pb.start(); pr.waitFor(); ...
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
You might try `ps -aux | grep foobar` for getting the pid, then issuing the `kill` command against it, alternatively you might want to use [**`pkill`**](http://en.wikipedia.org/wiki/Pkill)`foobar`, in both cases `foobar` being the name of the app you want to terminate.
How about this then? ``` public static void killAll(String process) { try { Vector<String> commands = new Vector<String>(); commands.add("pidof"); commands.add(process); ProcessBuilder pb = new ProcessBuilder(commands); Process pr = pb.start(); pr.waitFor(); ...
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
pid's for java processes -e.g `ps -aux | grep java | awk '{print $2}'` . You can also call `jps` which will give you a process list. A drawback of this is that it will only show you processes for the user issuing the jps command.
You'll probably have to invoke the `ps` and `kill` Unix commands using [Runtime.exec](http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html#exec%28java.lang.String%29) and scrape their output. I don't think a Java program can easily inspect / access processes it didn't create.
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
you can use `pidof` to get the pid of your application `pidof <application name>`
`ps aux | awk '/java/ {print "sleep 10; kill "$2}' | bash` in Ubuntu, `ps -aux` throws an syntax error, where `ps aux` works. the output is piped to `awk` which matches lines with java and sleeps for 10seconds and then kills the program with the pId. notice the pipe to bash. Feel free to specify however long you want...
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
pid's for java processes -e.g `ps -aux | grep java | awk '{print $2}'` . You can also call `jps` which will give you a process list. A drawback of this is that it will only show you processes for the user issuing the jps command.
`ps aux | awk '/java/ {print "sleep 10; kill "$2}' | bash` in Ubuntu, `ps -aux` throws an syntax error, where `ps aux` works. the output is piped to `awk` which matches lines with java and sleeps for 10seconds and then kills the program with the pId. notice the pipe to bash. Feel free to specify however long you want...
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
pid's for java processes -e.g `ps -aux | grep java | awk '{print $2}'` . You can also call `jps` which will give you a process list. A drawback of this is that it will only show you processes for the user issuing the jps command.
[Find the pid of a java process under Linux](https://stackoverflow.com/questions/10201589/find-the-pid-of-a-java-process-under-linux) you can refer to this link...it tell you about finding a pid of specific class name
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
pid's for java processes -e.g `ps -aux | grep java | awk '{print $2}'` . You can also call `jps` which will give you a process list. A drawback of this is that it will only show you processes for the user issuing the jps command.
If you're starting this application from script you can get the pid of the last process that was created in background by using the special variable `$!`, this value you can save on a file for later use on your shutdown function. Below is an example: ``` nohup java -jar example.jar & echo $! > application.pid ```
7,762,257
I'm trying to make an application that checks if this specific application is running, then kill the app after a specified amount of time. I'm planning to get the pid of the app. How can I get the pid of the app? Thanks
2011/10/14
[ "https://Stackoverflow.com/questions/7762257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983683/" ]
you can use `pidof` to get the pid of your application `pidof <application name>`
If you're starting this application from script you can get the pid of the last process that was created in background by using the special variable `$!`, this value you can save on a file for later use on your shutdown function. Below is an example: ``` nohup java -jar example.jar & echo $! > application.pid ```
16,566,172
I have a 2D particle system, where the particles are represented as ellipses. I need to calculate ellipse - ellipse overlap areas, but this is a hard analytical problem [Ellipse-Ellipse Overlap](http://arxiv.org/abs/1106.3787). I now represent my ellipses as 20-gons, so that they are "polygonized" and I am using `Boost...
2013/05/15
[ "https://Stackoverflow.com/questions/16566172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1678192/" ]
It seems you're wrong about Clipper and GPC "*they only output boolean results*". Both libraries calculate intersection polygon - for example, look at the code snippet with picture on Clipper page.
Can you submit a ticket into the Boost ticket system? Including a sample of a geometry pair giving invalid input exceptions? The error can have several causes, either it is indeed invalid, or it is a bug in the library. Some of these issues are fixed per 1.54.
16,566,172
I have a 2D particle system, where the particles are represented as ellipses. I need to calculate ellipse - ellipse overlap areas, but this is a hard analytical problem [Ellipse-Ellipse Overlap](http://arxiv.org/abs/1106.3787). I now represent my ellipses as 20-gons, so that they are "polygonized" and I am using `Boost...
2013/05/15
[ "https://Stackoverflow.com/questions/16566172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1678192/" ]
It seems you're wrong about Clipper and GPC "*they only output boolean results*". Both libraries calculate intersection polygon - for example, look at the code snippet with picture on Clipper page.
In Angus' benchmark of Clipper with the other libraries, he has a method for polygon Area calculation. I used that and modified his ellipse method. The result is the following: ``` void Ellipse2Poly(double theta, double A1, double B1, double H1, double K1, Poly& p) { const double pi = 3.1415926535898, tolerance =...
8,775,388
...using AutoKey 0.81.4 on Ubuntu 10.04 1. relatively new to Linux (<1yr) 2. This is the first python I've written the following script for AutoKey keeps failing with the following error. What am I not getting here?? ``` Script name: 'find files script' Traceback (most recent call last): File "/usr/lib/python2.6/d...
2012/01/08
[ "https://Stackoverflow.com/questions/8775388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/508984/" ]
The output attribute doesn't exist until Python 2.6. You could use subprocess.Popen and communicate(). Or you could backport subprocess.check\_output (also not in 2.6) following [this](https://gist.github.com/edufelipe/1027906).
Change the e.output to just e. Using str(e) will get you the error string. You may want to look up exceptions to find out what attributes they support. I don't think output is one of them.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
Just add `gin.SetMode(gin.ReleaseMode)` in your main function.
It would seem you do this by calling the [`SetMode`](https://godoc.org/github.com/gin-gonic/gin#SetMode) method from within your app. Probably in your `main`, or possibly in an `init` function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
Just set `GIN_MODE=release` to your environment config.
It would seem you do this by calling the [`SetMode`](https://godoc.org/github.com/gin-gonic/gin#SetMode) method from within your app. Probably in your `main`, or possibly in an `init` function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
You have to call `SetMode` method before you initialize the gin router. E.x: ``` gin.SetMode(gin.ReleaseMode) router := gin.New() ```
It would seem you do this by calling the [`SetMode`](https://godoc.org/github.com/gin-gonic/gin#SetMode) method from within your app. Probably in your `main`, or possibly in an `init` function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
``` gin.SetMode(gin.ReleaseMode) ``` This works. Remember that you need to set this before creating the router in your init function/main. It does not seem to work otherwise i.e Your code would look something like this. ``` func init() { gin.SetMode(gin.ReleaseMode) r := NewRouter() err := r.Run("8080") ...
It would seem you do this by calling the [`SetMode`](https://godoc.org/github.com/gin-gonic/gin#SetMode) method from within your app. Probably in your `main`, or possibly in an `init` function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
Just set `GIN_MODE=release` to your environment config.
Just add `gin.SetMode(gin.ReleaseMode)` in your main function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
You have to call `SetMode` method before you initialize the gin router. E.x: ``` gin.SetMode(gin.ReleaseMode) router := gin.New() ```
Just add `gin.SetMode(gin.ReleaseMode)` in your main function.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
You have to call `SetMode` method before you initialize the gin router. E.x: ``` gin.SetMode(gin.ReleaseMode) router := gin.New() ```
Just set `GIN_MODE=release` to your environment config.
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
Just set `GIN_MODE=release` to your environment config.
``` gin.SetMode(gin.ReleaseMode) ``` This works. Remember that you need to set this before creating the router in your init function/main. It does not seem to work otherwise i.e Your code would look something like this. ``` func init() { gin.SetMode(gin.ReleaseMode) r := NewRouter() err := r.Run("8080") ...
46,411,173
I need to set gin mode to release mode. How should I do it? Now when I run my API there is a hint like this: ``` [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) ``` I tried `gin.SetMode(gin.Re...
2017/09/25
[ "https://Stackoverflow.com/questions/46411173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849647/" ]
You have to call `SetMode` method before you initialize the gin router. E.x: ``` gin.SetMode(gin.ReleaseMode) router := gin.New() ```
``` gin.SetMode(gin.ReleaseMode) ``` This works. Remember that you need to set this before creating the router in your init function/main. It does not seem to work otherwise i.e Your code would look something like this. ``` func init() { gin.SetMode(gin.ReleaseMode) r := NewRouter() err := r.Run("8080") ...
38,161,358
**Problem** I am trying to find the connected components of my undirected graph. Matlabs function `conncomp` does exactly this. [Mathworks - connected graph components](http://se.mathworks.com/help/matlab/ref/graph.conncomp.html) **Example** Using the example given on matlabs webpage to keep it easy and repeatable:...
2016/07/02
[ "https://Stackoverflow.com/questions/38161358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6309794/" ]
Here's s plain Java solution: ``` map.computeIfPresent("key1", (k, v) -> Arrays.stream(v) .filter(s -> !s.equals("B")).toArray(String[]::new)); ```
You would get the values for the specific key and remove the given value from it, then put it back into the map. ``` public void <K> removeValueFromKey(final Map<K, K[]> map, final K key, final K value) { K[] values = map.get(key); ArrayList<K> valuesAsList = new ArrayList<K>(values.length); for (K current...
4,591,917
I have a GUI program which should also be controllable via CLI (for monitoring). The CLI is implemented in a while loop using raw\_input. If I quit the program via a GUI close button, it hangs in raw\_input and does not quit until it gets an input. How can I immediately abort raw\_input without entering an input? I r...
2011/01/04
[ "https://Stackoverflow.com/questions/4591917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/562283/" ]
That's not maybe the best solution but you could use the [thread module](http://docs.python.org/library/thread.html) which has a function `thread.interrupt_main()`. So can run two thread : one with your raw\_input method and one which can give the interruption signal. The upper level thread raise a KeyboardInterrupt ex...
Depending on what GUI toolkit you're using, find a way to hook up an event listener to the close window action and make it call [`win32api.TerminateProcess(-1, 0)`](http://docs.activestate.com/activepython/2.5/pywin32/win32api__TerminateProcess_meth.html). For reference, on Linux calling [`sys.exit()`](http://docs.pyt...
168,787
I've been trying to create a backup for a very large MyISAM DB with mysqldump and I've noticed that some of the tables have variations in index sizes after restoring. For example, one of my larger tables has an index length of 50316242944 and the restored dump of that table has an index length of 50227628032 I've run...
2017/03/31
[ "https://dba.stackexchange.com/questions/168787", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/120933/" ]
on mac os x startup parameters of mysql You can change by edit .plist file location: ``` /Library/LaunchDaemons com.oracle.oss.mysql.mysqld.plist ``` Use Xcode or for example BBEdit, and add line in section ProgramArguments ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0/...
Create a new file /etc/my.cnf and add the following lines ``` [mysqld_safe] [mysqld] secure_file_priv="/Users/abc/" ``` and restart
168,787
I've been trying to create a backup for a very large MyISAM DB with mysqldump and I've noticed that some of the tables have variations in index sizes after restoring. For example, one of my larger tables has an index length of 50316242944 and the restored dump of that table has an index length of 50227628032 I've run...
2017/03/31
[ "https://dba.stackexchange.com/questions/168787", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/120933/" ]
on mac os x startup parameters of mysql You can change by edit .plist file location: ``` /Library/LaunchDaemons com.oracle.oss.mysql.mysqld.plist ``` Use Xcode or for example BBEdit, and add line in section ProgramArguments ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0/...
``` echo "[mysqld]\nsecure_file_priv\t\t= ''\n" | sudo tee /etc/my.cnf ``` And then restart mysql. If brew was used to install the mysql run the following command: ``` brew services restart mysql ```
168,787
I've been trying to create a backup for a very large MyISAM DB with mysqldump and I've noticed that some of the tables have variations in index sizes after restoring. For example, one of my larger tables has an index length of 50316242944 and the restored dump of that table has an index length of 50227628032 I've run...
2017/03/31
[ "https://dba.stackexchange.com/questions/168787", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/120933/" ]
Create a new file /etc/my.cnf and add the following lines ``` [mysqld_safe] [mysqld] secure_file_priv="/Users/abc/" ``` and restart
``` echo "[mysqld]\nsecure_file_priv\t\t= ''\n" | sudo tee /etc/my.cnf ``` And then restart mysql. If brew was used to install the mysql run the following command: ``` brew services restart mysql ```
60,602
Rather than visit every SOFU, SE, and meta site every day to see if anyone has answered/replied/voted on my posts, I would like to have one page that consolidates all of these notifications.
2010/08/11
[ "https://meta.stackexchange.com/questions/60602", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/-1/" ]
This is now complete. 1. look for the small indicator on the Stack Exchange logo in the upper right 2. click it to expand a list of network-wide replies to you. ![global inbox](https://i.stack.imgur.com/7ZQmc.png)
This has been asked a few times. Here is something that might be what you're looking for: <http://stackcenter.quickmediasolutions.com> *Disclaimer: I wrote it.*
60,602
Rather than visit every SOFU, SE, and meta site every day to see if anyone has answered/replied/voted on my posts, I would like to have one page that consolidates all of these notifications.
2010/08/11
[ "https://meta.stackexchange.com/questions/60602", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/-1/" ]
This has been asked a few times. Here is something that might be what you're looking for: <http://stackcenter.quickmediasolutions.com> *Disclaimer: I wrote it.*
In addition to the topbar (which replaced the [supercollider](https://meta.stackexchange.com/a/65590/162102)), you can see all your responses (not reputation changes) from your network profile under the inbox tab. You can get to your network profile from the accounts section of any per-site profile page.
60,602
Rather than visit every SOFU, SE, and meta site every day to see if anyone has answered/replied/voted on my posts, I would like to have one page that consolidates all of these notifications.
2010/08/11
[ "https://meta.stackexchange.com/questions/60602", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/-1/" ]
This is now complete. 1. look for the small indicator on the Stack Exchange logo in the upper right 2. click it to expand a list of network-wide replies to you. ![global inbox](https://i.stack.imgur.com/7ZQmc.png)
In addition to the topbar (which replaced the [supercollider](https://meta.stackexchange.com/a/65590/162102)), you can see all your responses (not reputation changes) from your network profile under the inbox tab. You can get to your network profile from the accounts section of any per-site profile page.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If everything looks right and it is still giving error, change the 'mintty' to 'mintty.exe'. This solved my problem.
For Installing Cygwin follow the steps given here- -Link is now dead- <http://www.news.amigowork.com/how-to-install-unix-in-windows/> if problem is still there then go to installation directory and open Cygwin.bat or go to bin folder of installation directory and open mintty.exe. it will solve your problem.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
For Installing Cygwin follow the steps given here- -Link is now dead- <http://www.news.amigowork.com/how-to-install-unix-in-windows/> if problem is still there then go to installation directory and open Cygwin.bat or go to bin folder of installation directory and open mintty.exe. it will solve your problem.
I had installed cygwin in e drive. But the path (in property, by right click on icon )showed c drive. When i changed it to e, the problem went away. It was on Windows 7 and cygwin installation was latest on 4th Jan 2018.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
For Installing Cygwin follow the steps given here- -Link is now dead- <http://www.news.amigowork.com/how-to-install-unix-in-windows/> if problem is still there then go to installation directory and open Cygwin.bat or go to bin folder of installation directory and open mintty.exe. it will solve your problem.
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If it is not as per your minty(you will get it inside bin folder) location change it.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If everything looks right and it is still giving error, change the 'mintty' to 'mintty.exe'. This solved my problem.
I had installed cygwin in e drive. But the path (in property, by right click on icon )showed c drive. When i changed it to e, the problem went away. It was on Windows 7 and cygwin installation was latest on 4th Jan 2018.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If everything looks right and it is still giving error, change the 'mintty' to 'mintty.exe'. This solved my problem.
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If it is not as per your minty(you will get it inside bin folder) location change it.
25,867,960
I just installed cygwin in my **windows7** pc. After installation when i click on **'Cygwin Terminal'** from start menu it shows a message like this - message title: **Missing Shortcut** "Windows is searching for **mintty**. To locate the file yourself, click Browse" with two buttons below **"Browse"** and **"Cancel"**...
2014/09/16
[ "https://Stackoverflow.com/questions/25867960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4046083/" ]
Open the Cygwin Terminal properties (by right click on the icon and go to properties) check the path of 'mintty'. If it is not as per your minty(you will get it inside bin folder) location change it.
I had installed cygwin in e drive. But the path (in property, by right click on icon )showed c drive. When i changed it to e, the problem went away. It was on Windows 7 and cygwin installation was latest on 4th Jan 2018.
70,424,716
I am not too familiar with GitHub, but I have a feature branch that I want to merge its current changes to master multiple times. Ideally, I want to break up the pull requests so that one pr doesn't get too long. So for example I want a pr for the frontend first. After that is merged, I will push changes for the backen...
2021/12/20
[ "https://Stackoverflow.com/questions/70424716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8684976/" ]
You can apply a fixed-width to your `cards`. Without defining a width, flex-box is going to try to determine the width for them, based on the screen size. If you set a fixed-width the cards will keep that width upon resizing the browser, which then your `flex-wrap: wrap;` on your container will kick in and wrap them wh...
Be ensure your flex item have maximum width . than the main container will be wrapping. ```css .card { max-width: 200px; } ```
19,865,840
Updated my play framework version to 2.2.1 ``` C:\>where play C:\apps\play-2.2.1\play C:\apps\play-2.2.1\play.bat ``` On Doing a build I get following error as shown below. ``` sbt.ResolveException: unresolved dependency: com.typesafe.play#play_2.10;2.2.1: not found ```
2013/11/08
[ "https://Stackoverflow.com/questions/19865840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2438383/" ]
Add this: ``` resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" ``` to `project/plugins.sbt`, and make sure your top-level `build.sbt` has this line: ``` playScalaSettings ``` I don't know of any reason it would need to be more complicated than that, as in your own answer.
Resolved by entering the following entry in `Resolvers.scala`: ``` import sbt._ import scala.xml.XML object Resolvers { /* # Online play 2.2.0 repository # */ val onLinePlayRepo = "Online Play Repository" at "https://private-repo.typesafe.com/typesafe/maven-releases/play/" val remResolvers = Seq(localMaven, ...
19,865,840
Updated my play framework version to 2.2.1 ``` C:\>where play C:\apps\play-2.2.1\play C:\apps\play-2.2.1\play.bat ``` On Doing a build I get following error as shown below. ``` sbt.ResolveException: unresolved dependency: com.typesafe.play#play_2.10;2.2.1: not found ```
2013/11/08
[ "https://Stackoverflow.com/questions/19865840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2438383/" ]
Resolved by entering the following entry in `Resolvers.scala`: ``` import sbt._ import scala.xml.XML object Resolvers { /* # Online play 2.2.0 repository # */ val onLinePlayRepo = "Online Play Repository" at "https://private-repo.typesafe.com/typesafe/maven-releases/play/" val remResolvers = Seq(localMaven, ...
If you are behind a proxy, you should set https proxy as far as http proxy. **HTTPS** ``` -Dhttps.proxyHost=host -Dhttps.proxyPort=port ``` **HTTP** ``` -Dhttp.proxyHost=host -Dhttp.proxyPort=port ```
19,865,840
Updated my play framework version to 2.2.1 ``` C:\>where play C:\apps\play-2.2.1\play C:\apps\play-2.2.1\play.bat ``` On Doing a build I get following error as shown below. ``` sbt.ResolveException: unresolved dependency: com.typesafe.play#play_2.10;2.2.1: not found ```
2013/11/08
[ "https://Stackoverflow.com/questions/19865840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2438383/" ]
Add this: ``` resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" ``` to `project/plugins.sbt`, and make sure your top-level `build.sbt` has this line: ``` playScalaSettings ``` I don't know of any reason it would need to be more complicated than that, as in your own answer.
If you are behind a proxy, you should set https proxy as far as http proxy. **HTTPS** ``` -Dhttps.proxyHost=host -Dhttps.proxyPort=port ``` **HTTP** ``` -Dhttp.proxyHost=host -Dhttp.proxyPort=port ```
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
Read in all your lines and use the `string.join()` method to join them together. ``` lines = open(file_in).readlines() out_list = "['" + "','".join(lines) + "']" ``` Additionally, `join()` can take any sequence, so reading the lines isn't necessary. The above code can be simplified as: ``` out_list = "['" + "','"....
You "right strip" for "," the result before adding the last "]". e.g. use the `string.rstrip(",")`
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
``` out_list = [] for line in open(file_in): out_list.append("'" + line + "'") return "[" + ",".join(out_list) + "]" ```
You "right strip" for "," the result before adding the last "]". e.g. use the `string.rstrip(",")`
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
Read in all your lines and use the `string.join()` method to join them together. ``` lines = open(file_in).readlines() out_list = "['" + "','".join(lines) + "']" ``` Additionally, `join()` can take any sequence, so reading the lines isn't necessary. The above code can be simplified as: ``` out_list = "['" + "','"....
``` out_list = [] for line in open(file_in): out_list.append("'" + line + "'") return "[" + ",".join(out_list) + "]" ```
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
Read in all your lines and use the `string.join()` method to join them together. ``` lines = open(file_in).readlines() out_list = "['" + "','".join(lines) + "']" ``` Additionally, `join()` can take any sequence, so reading the lines isn't necessary. The above code can be simplified as: ``` out_list = "['" + "','"....
Or ``` result = "['" for line in open(file_in): if len(result) > 0: result += "','" result += line result += "']" return result ```
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
Read in all your lines and use the `string.join()` method to join them together. ``` lines = open(file_in).readlines() out_list = "['" + "','".join(lines) + "']" ``` Additionally, `join()` can take any sequence, so reading the lines isn't necessary. The above code can be simplified as: ``` out_list = "['" + "','"....
Your desired output format is exactly Python's standard printable representation of a list. So an easy solution is to read the file, create a list with each line as a string element (stripping the end-of-line of each), and call the Python built-in function [repr](http://docs.python.org/library/functions.html#repr) to p...
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
Read in all your lines and use the `string.join()` method to join them together. ``` lines = open(file_in).readlines() out_list = "['" + "','".join(lines) + "']" ``` Additionally, `join()` can take any sequence, so reading the lines isn't necessary. The above code can be simplified as: ``` out_list = "['" + "','"....
``` def do(filepath): out = [] for line in open(filepath, 'r'): out.append("'" + line.strip() + "'") return out.__str__() ```
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
``` out_list = [] for line in open(file_in): out_list.append("'" + line + "'") return "[" + ",".join(out_list) + "]" ```
Or ``` result = "['" for line in open(file_in): if len(result) > 0: result += "','" result += line result += "']" return result ```
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
``` out_list = [] for line in open(file_in): out_list.append("'" + line + "'") return "[" + ",".join(out_list) + "]" ```
Your desired output format is exactly Python's standard printable representation of a list. So an easy solution is to read the file, create a list with each line as a string element (stripping the end-of-line of each), and call the Python built-in function [repr](http://docs.python.org/library/functions.html#repr) to p...
1,703,471
I'm trying to read a list of items from a text file and format with square brackets and separators like this: ['item1','item2', .... 'last\_item'] but I'm having trouble with the beginning and end item for which I always get: ...,'last\_item','], so I do not want the last ,' to be there. In python I've write: ``` ou...
2009/11/09
[ "https://Stackoverflow.com/questions/1703471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/207258/" ]
``` out_list = [] for line in open(file_in): out_list.append("'" + line + "'") return "[" + ",".join(out_list) + "]" ```
``` def do(filepath): out = [] for line in open(filepath, 'r'): out.append("'" + line.strip() + "'") return out.__str__() ```
11,738,134
In my webpage I have to show the contents of another webpage which is done using sencha touch.I am using iframes for this purpose.But the problem is that the select menu in the sencha touch webpage(loaded through iframe) is not coming when viewed in iphone browser.There is an overlay coming,but not the select menu.When...
2012/07/31
[ "https://Stackoverflow.com/questions/11738134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700284/" ]
Sorry @user700284 but overlay `iframe` not yet works on iOS and android browser; only for this moment works on browser desktop. But you can put `iframe` not overlay into your `Ext.Panel` something like this, ``` Ext.Panel({ items: [ { xtype: 'panel', html: '<iframe width="560" height="315" src="ht...
Use an [object tag](http://aplus.rs/web-dev/insert-html-page-into-another-html-page/) instead of an iframe and see if that makes a difference.
11,738,134
In my webpage I have to show the contents of another webpage which is done using sencha touch.I am using iframes for this purpose.But the problem is that the select menu in the sencha touch webpage(loaded through iframe) is not coming when viewed in iphone browser.There is an overlay coming,but not the select menu.When...
2012/07/31
[ "https://Stackoverflow.com/questions/11738134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700284/" ]
Use an [object tag](http://aplus.rs/web-dev/insert-html-page-into-another-html-page/) instead of an iframe and see if that makes a difference.
The iFrame loading a selectfield works perfectly on the iPad (native and mobile safari). But on the iPhone it gives the same error. Any other solutions for this ??
11,738,134
In my webpage I have to show the contents of another webpage which is done using sencha touch.I am using iframes for this purpose.But the problem is that the select menu in the sencha touch webpage(loaded through iframe) is not coming when viewed in iphone browser.There is an overlay coming,but not the select menu.When...
2012/07/31
[ "https://Stackoverflow.com/questions/11738134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700284/" ]
Sorry @user700284 but overlay `iframe` not yet works on iOS and android browser; only for this moment works on browser desktop. But you can put `iframe` not overlay into your `Ext.Panel` something like this, ``` Ext.Panel({ items: [ { xtype: 'panel', html: '<iframe width="560" height="315" src="ht...
The iFrame loading a selectfield works perfectly on the iPad (native and mobile safari). But on the iPhone it gives the same error. Any other solutions for this ??
1,756,069
prove that $$\mathop {\lim }\limits\_{n\to\infty} \sqrt[n] n = 1 $$ I am unable to get a way to solve this, but I have done a question like the one below prove that $$\mathop {\lim }\limits\_{n\to\infty} \sqrt[n] a = 1 $$ some one help me
2016/04/24
[ "https://math.stackexchange.com/questions/1756069", "https://math.stackexchange.com", "https://math.stackexchange.com/users/333466/" ]
Note that: $$\sqrt[n] n =n^\frac{1}{n}=e^{\frac{\ln n}{n}}$$ thus: $$ \lim\_{n\to+\infty}\sqrt[n] n=\lim\_{n\to+\infty}n^\frac{1}{n}=\lim\_{n\to+\infty}e^{\frac{\ln n}{n}}=1 $$ since $$ \lim\_{n\to+\infty}\frac{\ln n}{n}=0 $$
Rewrite the expression using e. This then reduces to showing that log(n)/n tends to 0 as n tends to infinity. which follows from l'Hôpital.
1,756,069
prove that $$\mathop {\lim }\limits\_{n\to\infty} \sqrt[n] n = 1 $$ I am unable to get a way to solve this, but I have done a question like the one below prove that $$\mathop {\lim }\limits\_{n\to\infty} \sqrt[n] a = 1 $$ some one help me
2016/04/24
[ "https://math.stackexchange.com/questions/1756069", "https://math.stackexchange.com", "https://math.stackexchange.com/users/333466/" ]
You could also use the binomial formula: put $$x\_n := n^{\frac{1}{n}} - 1 \geqq 0 \hspace{1.0cm} (n=1,2,3,...).$$ Thus, $n\geqq 2$ implies $$n = (x\_n +1)^n = \sum\_{j=0}^n {n\choose j} x\_n^j \geqq \frac{n(n-1)}{2}x\_n^2.$$ Therefore, $$ 0 < x\_n \leqq \sqrt{\frac{2}{n-1}} \hspace{1.0cm} (n \geqq 2).$$ Letting $n \ri...
Rewrite the expression using e. This then reduces to showing that log(n)/n tends to 0 as n tends to infinity. which follows from l'Hôpital.
46,088,711
After creating an initial cocos2d Lua project, but get the following bug error. **Error info** ``` Android NDK: /Users/beck/Documents/Cocos2d-x/Hello_CocosLua/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk: Cannot find module with tag 'scripting/lua-bindings/proj.android' in import path Android N...
2017/09/07
[ "https://Stackoverflow.com/questions/46088711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069213/" ]
These error occurs when the main core version and extension version doesn't match. Don't forget to download the external extensions by executing the python script; download-deps.py
Fix by add the following into Android.mk. Aiming to import the individual path "cocos2d-x", "cocos2d-x/external", "cocos2d-x/cocos", rightly. $(call import-add-path,$(LOCAL\_PATH)/../../../../cocos2d-x) $(call import-add-path,$(LOCAL\_PATH)/../../../../cocos2d-x/external) $(call import-add-path,$(LOCAL\_PATH)/../....
13,274,724
I have text and image inside a div and I want the text to be aligned at the top of the image, not the middle. Here's how it looks: <http://bitly.com/VSSoul> CSS: ``` .book1 { width: 100%; overflow: auto; } .book2 { width: 100%; overflow: auto; } .book1 img { float: right; width: 150px; ...
2012/11/07
[ "https://Stackoverflow.com/questions/13274724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736049/" ]
It actually is aligned to the top. The h4 tag has default margins, so setting: ``` h4 { margin-top: 0; } ``` would do the trick.
``` .book img { float: right; width: 150px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } .book { margin-bottom: 2em; overflow: auto; } ``` **Demo JSFiddle:** <http://jsfiddle.net/e636q/>
13,274,724
I have text and image inside a div and I want the text to be aligned at the top of the image, not the middle. Here's how it looks: <http://bitly.com/VSSoul> CSS: ``` .book1 { width: 100%; overflow: auto; } .book2 { width: 100%; overflow: auto; } .book1 img { float: right; width: 150px; ...
2012/11/07
[ "https://Stackoverflow.com/questions/13274724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736049/" ]
It actually is aligned to the top. The h4 tag has default margins, so setting: ``` h4 { margin-top: 0; } ``` would do the trick.
hear you go. add ``` h4 { margin-top: 0; } .book1 {margin-bottom: 1.5em;} ``` the extra margin on .book1 helps with spacing the individual books apart
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `sum` function is intended to sum all the elements in an array, which explains the error you're getting. Also, if you keep `output_str` being declared inside your `for` function, everytime if scans a new value from your list, `output_str` would reset. That's why I am now declaring it only once, before the `for` eve...
You could do: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ints = [str(i).isnumeric() for i in mylist] ix_int = np.flatnonzero(ints) np.array(mylist)[ix_int].astype(int).sum() 68 ``` And for the strings: ``` ix_str = np.setdiff1d(np.arange(len(mylist)), indices) ''.join(np.array(mylist)[ix_str]) 'jacksn...
53,822,006
new to python here. I am trying to learn how to perform operations on a list that has mixed types: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] ``` If the item is a str, I want to add it to output\_str, and if it is an int I want to sum it. This is what I have tried: ``` mylist = ['jack', 12, 'snake', 1...
2018/12/17
[ "https://Stackoverflow.com/questions/53822006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Use list comprehension which is faster and more readable and simpler: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] int_sum = sum([i for i in mylist if isinstance(i, int)]) str_join = ' '.join([i for i in mylist if isinstance(i, str)]) print(str_join) print(int_sum) ``` **Output:** ``` C:\Users\Documen...
Try this: ``` mylist = ['jack', 12, 'snake', 17, 'tumbleweed', 39] total = 0 output_str = '' for x in mylist: if isinstance(x, str): output_str = output_str + x elif isinstance(x, int): total += x print(output_str) print(total) ```