qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
11,820
How would I go about creating a menu system with fonts in OpenGL? I want to make a dungeon crawler and will need a menu for inventory and stats for the weapons. I can draw a world made out of blocks ok but I'm not quite sure how to do this. I think I need to use the matrix that glortho applies to the matrix stack. Spe...
2011/05/01
[ "https://gamedev.stackexchange.com/questions/11820", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/3128/" ]
If you're using WebGL, using the properties of the underlying 'canvas' element from which you created the context from to draw text. Don't make it harder than it needs to be until it needs to be.
Maybe I just don't understand your question, but if you want to draw text, you can use function [glutBitmapCharacter](http://www.opengl.org/resources/libraries/glut/spec3/node76.html).
11,820
How would I go about creating a menu system with fonts in OpenGL? I want to make a dungeon crawler and will need a menu for inventory and stats for the weapons. I can draw a world made out of blocks ok but I'm not quite sure how to do this. I think I need to use the matrix that glortho applies to the matrix stack. Spe...
2011/05/01
[ "https://gamedev.stackexchange.com/questions/11820", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/3128/" ]
OpenGL know nothing of fonts, so you have two choices. Either use bitmap fonts (a font written into a texture) or use Canvas/HTML to display your text. Most regular OpenGL games uses bitmap fonts.
Maybe I just don't understand your question, but if you want to draw text, you can use function [glutBitmapCharacter](http://www.opengl.org/resources/libraries/glut/spec3/node76.html).
11,820
How would I go about creating a menu system with fonts in OpenGL? I want to make a dungeon crawler and will need a menu for inventory and stats for the weapons. I can draw a world made out of blocks ok but I'm not quite sure how to do this. I think I need to use the matrix that glortho applies to the matrix stack. Spe...
2011/05/01
[ "https://gamedev.stackexchange.com/questions/11820", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/3128/" ]
OpenGL know nothing of fonts, so you have two choices. Either use bitmap fonts (a font written into a texture) or use Canvas/HTML to display your text. Most regular OpenGL games uses bitmap fonts.
If you're using WebGL, using the properties of the underlying 'canvas' element from which you created the context from to draw text. Don't make it harder than it needs to be until it needs to be.
35,677,830
In groovy the `.&` operator converts a method in a closure. In Java using the reflection Method object, one can get the method name, parameters names and types. Is there a way to get all the method reflection information from the closure? I'm only able to get the parameter types so far (via `closure.parameterTypes`)
2016/02/28
[ "https://Stackoverflow.com/questions/35677830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/468502/" ]
Just use the React.js Perf API, [here](https://facebook.github.io/react/docs/perf.html). Don't forget to use development's React bundle and not the production one.
I don't why it's not showing for you but have you tried using componentDidMount() rather than inside of your render? Also, React's performance tools do a great job detecting wasted renders: <https://facebook.github.io/react/docs/perf.html>
4,578,100
How do you make www.homepage.com/app/shoppingcart look like www.homepage.com/shoppingcart - how to rewrite the URL-s is there a url rewrite plugin for cakephp that does such things
2011/01/02
[ "https://Stackoverflow.com/questions/4578100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546063/" ]
The functionality of the two statements is exactly the same as long as an exception is not thrown -- the only difference between the two is that the `finally` block will be executed if an exception is thrown in the try block.
To quote the javadoc: > > Throws InterruptedException - if another thread has interrupted the current thread. > > > When your thread is not interrupted the two blocks of code are qequivalent, but you cannot know whether you will be interrupted or not, so to be sure your code is correct in both circumstances you s...
4,578,100
How do you make www.homepage.com/app/shoppingcart look like www.homepage.com/shoppingcart - how to rewrite the URL-s is there a url rewrite plugin for cakephp that does such things
2011/01/02
[ "https://Stackoverflow.com/questions/4578100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546063/" ]
The functionality of the two statements is exactly the same as long as an exception is not thrown -- the only difference between the two is that the `finally` block will be executed if an exception is thrown in the try block.
From the [Java tutorial](http://download.oracle.com/javase/tutorial/essential/exceptions/finally.html) on the finally block: > > The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. > > > **Note: If the JVM exits while th...
4,578,100
How do you make www.homepage.com/app/shoppingcart look like www.homepage.com/shoppingcart - how to rewrite the URL-s is there a url rewrite plugin for cakephp that does such things
2011/01/02
[ "https://Stackoverflow.com/questions/4578100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546063/" ]
The functionality of the two statements is exactly the same as long as an exception is not thrown -- the only difference between the two is that the `finally` block will be executed if an exception is thrown in the try block.
In your first code example the `someFunction()` will be executed always, even if the `try` block raises an `exception`. In that case, the `exception` block will be executed first and then the `finally` block. If no `exception` is raised then the `finally` block will be executed after the execution of the `try` block. ...
4,578,100
How do you make www.homepage.com/app/shoppingcart look like www.homepage.com/shoppingcart - how to rewrite the URL-s is there a url rewrite plugin for cakephp that does such things
2011/01/02
[ "https://Stackoverflow.com/questions/4578100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546063/" ]
To quote the javadoc: > > Throws InterruptedException - if another thread has interrupted the current thread. > > > When your thread is not interrupted the two blocks of code are qequivalent, but you cannot know whether you will be interrupted or not, so to be sure your code is correct in both circumstances you s...
From the [Java tutorial](http://download.oracle.com/javase/tutorial/essential/exceptions/finally.html) on the finally block: > > The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. > > > **Note: If the JVM exits while th...
4,578,100
How do you make www.homepage.com/app/shoppingcart look like www.homepage.com/shoppingcart - how to rewrite the URL-s is there a url rewrite plugin for cakephp that does such things
2011/01/02
[ "https://Stackoverflow.com/questions/4578100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/546063/" ]
To quote the javadoc: > > Throws InterruptedException - if another thread has interrupted the current thread. > > > When your thread is not interrupted the two blocks of code are qequivalent, but you cannot know whether you will be interrupted or not, so to be sure your code is correct in both circumstances you s...
In your first code example the `someFunction()` will be executed always, even if the `try` block raises an `exception`. In that case, the `exception` block will be executed first and then the `finally` block. If no `exception` is raised then the `finally` block will be executed after the execution of the `try` block. ...
39,536,236
In my book, it says Pointers are addresses and have a numerical value. You can print out the value of a pointer as cout << (unsigned long)(p) Write code to compare p,p+1,q, and q+1. Explain the results, Im not sure what the book wants me to so here's what I have. Does anyone Know if I am doing this right ``` int num =...
2016/09/16
[ "https://Stackoverflow.com/questions/39536236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6840311/" ]
Assuming it's the pointer arithmetic you have problems with, let my try to to show how it's done in a more "graphical" way: Lets say we have a pointer variable `ptr` which points to an array of integers, something like ``` int array[4] = { 1234, 5678, 9012, 3456 }; int* ptr = array; // Makes `ptr` point to the first...
You do it right, if you want to print the decimal representation of the addresses your pointers point to. If you wonder, why the results are such, you need to learn **pointer arithmetic.** If you add `1` to any pointer, it's address will be increased by `sizeof(<type>)`, where `type` is *the type of the variable you...
55,100,955
Hi everyone i have like this value in my column: ``` <?xml version="1.0" encoding="UTF-8"?><?dsk-revision 1.0?><Descriptor><pde><a><dov>784512</dov></a></pde></Descriptor> ``` I would retrieve just : ``` <dov>784512</dov> ``` Do you have any ideas? **Thank you !**
2019/03/11
[ "https://Stackoverflow.com/questions/55100955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10212296/" ]
This is a gaps-and-islands problem. I think `lag()` is the simplest approach: ``` select user_id, plan_type, created from (select t.*, lag(plan_type) over (partition by user_id order by created) as prev_plan_type from t ) t where prev_plan_type is null or prev_plan_type <> plan_type; ``` This...
use `row_number()` window function ``` select * from (select *,row_number()over(partition by user_id,plan_type order by created) rn ) a where a.rn=1 ```
55,100,955
Hi everyone i have like this value in my column: ``` <?xml version="1.0" encoding="UTF-8"?><?dsk-revision 1.0?><Descriptor><pde><a><dov>784512</dov></a></pde></Descriptor> ``` I would retrieve just : ``` <dov>784512</dov> ``` Do you have any ideas? **Thank you !**
2019/03/11
[ "https://Stackoverflow.com/questions/55100955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10212296/" ]
This is a gaps-and-islands problem. I think `lag()` is the simplest approach: ``` select user_id, plan_type, created from (select t.*, lag(plan_type) over (partition by user_id order by created) as prev_plan_type from t ) t where prev_plan_type is null or prev_plan_type <> plan_type; ``` This...
use `lag()` ``` select * from ( select user_id, plant_type, lag(plan_type) over (partition by user_id order by created) as changes, created from tablename )A where plan_type<>changes and changes is not null ```
52,380,022
I have a mysql table with 2 columns. ``` +---------+-----------+ | Barcode | StationID | +---------+-----------+ | 89411 | 1 | | 89411 | 2 | | 89411 | 3 | | 89412 | 1 | | 89413 | 1 | +---------+-----------+ ``` I would like to select all valus from Barcode column whi...
2018/09/18
[ "https://Stackoverflow.com/questions/52380022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8199942/" ]
Another approach is to use an `EXISTS` query: ``` SELECT t1.* FROM yourTable t1 WHERE t1.StationID = 1 AND NOT EXISTS (SELECT 1 FROM yourTable t2 WHERE t1.Barcode = t2.Barcode AND t2.StationID <> 1); ``` [Demo ----](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=4e544ed735f65c3f616345820069010a)
Try this: <https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=641d334c5f9e57bbdde07e4f24365f88> ``` select barcode from tablename group by barcode having sum(case when sanctionid=1 then 0 else 1 end)=0 ``` output: ``` barcode 89412 89413 ```
52,380,022
I have a mysql table with 2 columns. ``` +---------+-----------+ | Barcode | StationID | +---------+-----------+ | 89411 | 1 | | 89411 | 2 | | 89411 | 3 | | 89412 | 1 | | 89413 | 1 | +---------+-----------+ ``` I would like to select all valus from Barcode column whi...
2018/09/18
[ "https://Stackoverflow.com/questions/52380022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8199942/" ]
Another approach is to use an `EXISTS` query: ``` SELECT t1.* FROM yourTable t1 WHERE t1.StationID = 1 AND NOT EXISTS (SELECT 1 FROM yourTable t2 WHERE t1.Barcode = t2.Barcode AND t2.StationID <> 1); ``` [Demo ----](https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=4e544ed735f65c3f616345820069010a)
Use aggregation function [GROUP\_CONCAT](https://www.w3resource.com/mysql/aggregate-functions-and-grouping/aggregate-functions-and-grouping-group_concat.php), and use `HAVING` clause to filter out those barcodes, which has only one `StationID`, that is `'1'`: ``` SELECT barcode, GROUP_CONCAT(DISTINCT StationID) AS st...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
I think it has a different and specific meaning. "Do a shop" or "Do the shop" is a specific task, eg. the weekly trip to the supermarket for the big grocery shop. "Go shopping" is a more general, recreational, go out and look at the shops but with no specific aim. It's the same way that "load" is a verb or a noun. S...
"Do the shop." Usually means, "Do the weekly shop". Grammatically, going for a shop, is like going for a walk. "Walk" can be either a noun or a verb - "to walk", "the walk". When people say, "to go for a walk", what they mean is "to go walking" or to go on "the walk", or "the usual walk". Do people stop to consider...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If you don't use this phrase, you may not know that it carries some precision. If I say that after I do X, I think I will have time to go shopping, you don't know if I just intend to randomly browse, get birthday presents, or buy the weekly groceries. If I say I think I will have time to shop, then the random browsing ...
The OED’s definition 2e for *shop* is ‘An act of shopping for purchases’ and it is described as colloquial. The earliest citation in this sense is from 1960: *You should find it possible to have one big ‘shop’ a week with a small mid-week ‘shop’ for perishables.* Once we see *shop* used as a noun in this way, any gramm...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
"Do the shop." Usually means, "Do the weekly shop". Grammatically, going for a shop, is like going for a walk. "Walk" can be either a noun or a verb - "to walk", "the walk". When people say, "to go for a walk", what they mean is "to go walking" or to go on "the walk", or "the usual walk". Do people stop to consider...
"Do a shop" is no more or less "correct" than other slang, e.g., "Let's do lunch", "Let's take a meeting", and "**Enhance** your manhood by 3 inches instantly!" It's what people say. If they say it, and if other people understand what they mean, what on Earth does it matter?
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If you don't use this phrase, you may not know that it carries some precision. If I say that after I do X, I think I will have time to go shopping, you don't know if I just intend to randomly browse, get birthday presents, or buy the weekly groceries. If I say I think I will have time to shop, then the random browsing ...
"Do the shop." Usually means, "Do the weekly shop". Grammatically, going for a shop, is like going for a walk. "Walk" can be either a noun or a verb - "to walk", "the walk". When people say, "to go for a walk", what they mean is "to go walking" or to go on "the walk", or "the usual walk". Do people stop to consider...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
I think it has a different and specific meaning. "Do a shop" or "Do the shop" is a specific task, eg. the weekly trip to the supermarket for the big grocery shop. "Go shopping" is a more general, recreational, go out and look at the shops but with no specific aim. It's the same way that "load" is a verb or a noun. S...
"Do a shop" is no more or less "correct" than other slang, e.g., "Let's do lunch", "Let's take a meeting", and "**Enhance** your manhood by 3 inches instantly!" It's what people say. If they say it, and if other people understand what they mean, what on Earth does it matter?
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If you don't use this phrase, you may not know that it carries some precision. If I say that after I do X, I think I will have time to go shopping, you don't know if I just intend to randomly browse, get birthday presents, or buy the weekly groceries. If I say I think I will have time to shop, then the random browsing ...
I think it has a different and specific meaning. "Do a shop" or "Do the shop" is a specific task, eg. the weekly trip to the supermarket for the big grocery shop. "Go shopping" is a more general, recreational, go out and look at the shops but with no specific aim. It's the same way that "load" is a verb or a noun. S...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If the noun *a shop* is taken to mean *the act of shopping* then *do a shop* is the same grammatical construction as phrases like *do a backflip*. I don't know where it came from but it is certainly common idiomatic usage here in the UK. As @BarrieEngland states it is most often used with an adjective (big, weekly, etc...
I think it has a different and specific meaning. "Do a shop" or "Do the shop" is a specific task, eg. the weekly trip to the supermarket for the big grocery shop. "Go shopping" is a more general, recreational, go out and look at the shops but with no specific aim. It's the same way that "load" is a verb or a noun. S...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
The OED’s definition 2e for *shop* is ‘An act of shopping for purchases’ and it is described as colloquial. The earliest citation in this sense is from 1960: *You should find it possible to have one big ‘shop’ a week with a small mid-week ‘shop’ for perishables.* Once we see *shop* used as a noun in this way, any gramm...
"Do the shop." Usually means, "Do the weekly shop". Grammatically, going for a shop, is like going for a walk. "Walk" can be either a noun or a verb - "to walk", "the walk". When people say, "to go for a walk", what they mean is "to go walking" or to go on "the walk", or "the usual walk". Do people stop to consider...
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If you don't use this phrase, you may not know that it carries some precision. If I say that after I do X, I think I will have time to go shopping, you don't know if I just intend to randomly browse, get birthday presents, or buy the weekly groceries. If I say I think I will have time to shop, then the random browsing ...
"Do a shop" is no more or less "correct" than other slang, e.g., "Let's do lunch", "Let's take a meeting", and "**Enhance** your manhood by 3 inches instantly!" It's what people say. If they say it, and if other people understand what they mean, what on Earth does it matter?
80,698
This has puzzled me for a few years now. When preceded by *'a'*, *shop* becomes a noun. Does "do a shop" even make sense then? The correct phrase for me was always "go shopping", or similar. Can anyone tell me where "do a shop" came from and whether it's grammatical? Take the article in the following link, from an I...
2012/09/05
[ "https://english.stackexchange.com/questions/80698", "https://english.stackexchange.com", "https://english.stackexchange.com/users/25703/" ]
If the noun *a shop* is taken to mean *the act of shopping* then *do a shop* is the same grammatical construction as phrases like *do a backflip*. I don't know where it came from but it is certainly common idiomatic usage here in the UK. As @BarrieEngland states it is most often used with an adjective (big, weekly, etc...
"Do the shop." Usually means, "Do the weekly shop". Grammatically, going for a shop, is like going for a walk. "Walk" can be either a noun or a verb - "to walk", "the walk". When people say, "to go for a walk", what they mean is "to go walking" or to go on "the walk", or "the usual walk". Do people stop to consider...
19,619,669
I'm trying to send to a ArrayList Strings that come from the user input: ``` private static void adicionarReserva() { Scanner adiciona = new Scanner(System.in); System.out.println("Numero da pista: "); int nPista = adiciona.nextInt(); System.out.println("Numero de jogadores: "); int nJogado...
2013/10/27
[ "https://Stackoverflow.com/questions/19619669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2721043/" ]
It's very meaningful error you're getting. This is your `ArrayList`: ``` ArrayList<Jogadores> nome_jogador = new ArrayList(); ↑ ``` What are you trying to insert to it? a `String`, but it suppose to have `Jogadores` in it. Now look at your `addJogadores` method signature: ``` public void addJogadores(J...
You have to pass an instance of class `Jogadores`, if `Jogadores` has a constructor which accepts a `String` then: ``` nome_jogador.add(new Jogadores(nome)); ```
19,619,669
I'm trying to send to a ArrayList Strings that come from the user input: ``` private static void adicionarReserva() { Scanner adiciona = new Scanner(System.in); System.out.println("Numero da pista: "); int nPista = adiciona.nextInt(); System.out.println("Numero de jogadores: "); int nJogado...
2013/10/27
[ "https://Stackoverflow.com/questions/19619669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2721043/" ]
It's very meaningful error you're getting. This is your `ArrayList`: ``` ArrayList<Jogadores> nome_jogador = new ArrayList(); ↑ ``` What are you trying to insert to it? a `String`, but it suppose to have `Jogadores` in it. Now look at your `addJogadores` method signature: ``` public void addJogadores(J...
``` ArrayList<Jogadores> nome_jogador = new ArrayList(); ``` You are only allowed to add objects that are an instance of `Jogadores` and because you are trying to add a `String` (which is obviously not an instance of `Jogadores`) it gives you an error.
19,619,669
I'm trying to send to a ArrayList Strings that come from the user input: ``` private static void adicionarReserva() { Scanner adiciona = new Scanner(System.in); System.out.println("Numero da pista: "); int nPista = adiciona.nextInt(); System.out.println("Numero de jogadores: "); int nJogado...
2013/10/27
[ "https://Stackoverflow.com/questions/19619669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2721043/" ]
It's very meaningful error you're getting. This is your `ArrayList`: ``` ArrayList<Jogadores> nome_jogador = new ArrayList(); ↑ ``` What are you trying to insert to it? a `String`, but it suppose to have `Jogadores` in it. Now look at your `addJogadores` method signature: ``` public void addJogadores(J...
``` private static void adicionarReserva() { Scanner adiciona = new Scanner(System.in); System.out.println("Numero da pista: "); int nPista = adiciona.nextInt(); System.out.println("Numero de jogadores: "); int nJogadores = adiciona.nextInt(); System.out.println("Data Inicio: "); ...
12,459,177
If I want to list some items from a database, do I need to add a `UIView` and a `UITableView` to my ViewController? or just add the `UITableView` to my `ViewController`?
2012/09/17
[ "https://Stackoverflow.com/questions/12459177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672352/" ]
You must already be having a `UIView` as part of your `ViewController`, Just add `UITableView` as a subview to your `UIView`. The `UIView` of a `ViewController` can be accessed as `[self.view];`. So what you need to do is `[self.view addSubview:yourTableView];`. Using `setFrame` properly sets it in the x,y,width,heigh...
Just add the `UITableView` cause you are already have a `UIView`, Please check this [tutorial](http://www.iosdevnotes.com/2011/10/uitableview-tutorial/) on how to use `UITableView`.
12,459,177
If I want to list some items from a database, do I need to add a `UIView` and a `UITableView` to my ViewController? or just add the `UITableView` to my `ViewController`?
2012/09/17
[ "https://Stackoverflow.com/questions/12459177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672352/" ]
You must already be having a `UIView` as part of your `ViewController`, Just add `UITableView` as a subview to your `UIView`. The `UIView` of a `ViewController` can be accessed as `[self.view];`. So what you need to do is `[self.view addSubview:yourTableView];`. Using `setFrame` properly sets it in the x,y,width,heigh...
its just depend on your project layout if you want to add tableview then you can use predefined function like didselectrow,moverow,editingrow,willdisplay etc...it totally depend on your need and layout specification and last thing tableview is better than using view instead on another view.
10,991,341
Trying get my head around the texture wrapper in (the awesome) LibGDX framework and I need help. I would like to bind a texture (according to [Mesh, Color & Texture](https://github.com/libgdx/libgdx/wiki/Mesh%2C-color-%26-texture)) that is extracted from a TextureAtlas packed with the TexturePacker. The texture is bin...
2012/06/12
[ "https://Stackoverflow.com/questions/10991341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1450458/" ]
### Create the TextureRegion First, you create a `TextureAtlas` object by pointing at the text file that describes your atlas (the tool that creates the atlas will create two files: an image and a text file describing its contents): ``` TextureAtlas myTextures = new TextureAtlas("images/packed.txt"); ``` Then you c...
Got it to work using the above explanation. I can't believe so few are people are running asking this question as it seems like something that others would want to do. From the accepted solution I created a function that also does the math for the new UV position. Tested, and it works for me but please review as i'...
52,016,479
While calculating the edit distance nltk does not seem to consider the changes correctly. For e.g. ``` edit_distance(('paravati', 'selke', 'vital'), ('paravati', 'selke', 'vital'), transpositions=True) ``` This returns 0 because the string match. ``` edit_distance(('paravati', 'selke', 'vital'), ('selke', 'paravati...
2018/08/25
[ "https://Stackoverflow.com/questions/52016479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139150/" ]
S3 Bucket ACL permission are set after the bucket is created - I achieved a public file read bucket using this command `aws s3api put-bucket-acl --bucket ${SITE_NAME} --acl public-read` After creating the bucket: `aws s3api create-bucket --bucket ${SITE_NAME} --region ap-southeast-2 --create-bucket-configuration Loc...
Hope the below command will help you to make the s3 object public through the AWS CLI command. `aws s3api put-object-acl --bucket <bucketname> --key <object name with extension> --grant-read uri=http://acs.amazonaws.com/groups/global/AllUsers`
34,534,947
I'm building an Annotation Processor for Android (for the sake of future explanations, let's call it `TestProcessor`). The plan is for the processor to operate in two modes: * **`Mode 1`**: Generation of the code **`A`** * **`Mode 2`**: Generation of the code **`A`** and **`B`** --- **`Mode 2`** should be only sel...
2015/12/30
[ "https://Stackoverflow.com/questions/34534947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1993204/" ]
You could do a check for one of the `ButterKnife` classes in the classpath of the application. Then perform your logic based on the check's result. ``` Class butterKnifeClass = null; try { butterKnifeClass = Class.forName("butterknife.ButterKnife"); } catch (ClassNotFoundException e) { // no butterknife presen...
You could use this code to find out if a class is present in the annotation processing environment. ``` TypeElement typeElement = processingEnvironment.getElementUtils(). getTypeElement("com.squareup.picasso.Picasso"); ``` I didn't have success using the `Elements.getPackageElement()` method because it returned ...
34,534,947
I'm building an Annotation Processor for Android (for the sake of future explanations, let's call it `TestProcessor`). The plan is for the processor to operate in two modes: * **`Mode 1`**: Generation of the code **`A`** * **`Mode 2`**: Generation of the code **`A`** and **`B`** --- **`Mode 2`** should be only sel...
2015/12/30
[ "https://Stackoverflow.com/questions/34534947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1993204/" ]
You could do a check for one of the `ButterKnife` classes in the classpath of the application. Then perform your logic based on the check's result. ``` Class butterKnifeClass = null; try { butterKnifeClass = Class.forName("butterknife.ButterKnife"); } catch (ClassNotFoundException e) { // no butterknife presen...
In addition to the solution JBirdVegas suggested; This function can be used to check **whether a package exists in the external libraries** at runtime. ``` public static boolean packageExists(String packagePath) { return Thread.currentThread().getContextClassLoader().getResource(packagePath) != null; } ``` Usage ...
34,534,947
I'm building an Annotation Processor for Android (for the sake of future explanations, let's call it `TestProcessor`). The plan is for the processor to operate in two modes: * **`Mode 1`**: Generation of the code **`A`** * **`Mode 2`**: Generation of the code **`A`** and **`B`** --- **`Mode 2`** should be only sel...
2015/12/30
[ "https://Stackoverflow.com/questions/34534947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1993204/" ]
You could use this code to find out if a class is present in the annotation processing environment. ``` TypeElement typeElement = processingEnvironment.getElementUtils(). getTypeElement("com.squareup.picasso.Picasso"); ``` I didn't have success using the `Elements.getPackageElement()` method because it returned ...
In addition to the solution JBirdVegas suggested; This function can be used to check **whether a package exists in the external libraries** at runtime. ``` public static boolean packageExists(String packagePath) { return Thread.currentThread().getContextClassLoader().getResource(packagePath) != null; } ``` Usage ...
26,265,174
I am trying to use Google map in my application, but it crashes with strange error. I extends my class from `ActionBarActivity` maybe the reason is that? How I can fix this? ### Layout FIle ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.c...
2014/10/08
[ "https://Stackoverflow.com/questions/26265174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/612606/" ]
Instead of using an old type of map fragment use the newer type of fragment called support map fragment to support any type of devices **sample** ``` <fragment class="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent"/> ```
Have your referenced Google play service to your applciation and added necessary permission and meta data values in your ManifestFiles ? Because as the exception says it is not able to find the Maps class in your application. Have a look at this example <http://www.tutorialspoint.com/android/android_google_maps.htm>
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
there is not that I know a backend-agnostic way to do this, but definitely it is possible to do it for some common backends, e.g., WX, tkagg etc. ``` import matplotlib matplotlib.use("wx") from pylab import * figure(1) plot([1,2,3,4,5]) thismanager = get_current_fig_manager() thismanager.window.SetPosition((500, 0)) s...
How about defining a function to raise the window to the top level and move it toward the top-left corner (for example) like this: ``` def topfig(): figmgr = get_current_fig_manager() figmgr.canvas.manager.window.raise_() geom = figmgr.window.geometry() x,y,dx,dy = geom.getRect() figmgr.window.setG...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
For Qt4Agg, this worked for me. ``` fig = figure() fig.canvas.manager.window.move(0,0) ``` Tested on Win7, mpl version 1.4.2, python 2.7.5
This also works: ``` fig = figure() fig.canvas.manager.window.Move(100,400) ``` If you want to send a plot to an image and have it open with the default image manager (which likely remembers position) use this from [here](http://www.pythonware.com/library/pil/handbook/image.htm): ``` fig.savefig('abc.png') from PIL...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
FINALLY found the solution for QT backend: ``` import matplotlib.pyplot as plt fig, ax = plt.subplots() mngr = plt.get_current_fig_manager() # to put it into the upper left corner for example: mngr.window.setGeometry(50,100,640, 545) ``` If one doesn't know the x- and y-width one can read them out first, like so: ...
there is not that I know a backend-agnostic way to do this, but definitely it is possible to do it for some common backends, e.g., WX, tkagg etc. ``` import matplotlib matplotlib.use("wx") from pylab import * figure(1) plot([1,2,3,4,5]) thismanager = get_current_fig_manager() thismanager.window.SetPosition((500, 0)) s...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
FINALLY found the solution for QT backend: ``` import matplotlib.pyplot as plt fig, ax = plt.subplots() mngr = plt.get_current_fig_manager() # to put it into the upper left corner for example: mngr.window.setGeometry(50,100,640, 545) ``` If one doesn't know the x- and y-width one can read them out first, like so: ...
For Qt4Agg, this worked for me. ``` fig = figure() fig.canvas.manager.window.move(0,0) ``` Tested on Win7, mpl version 1.4.2, python 2.7.5
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
With help from the answers thus far and some tinkering on my own, here's a solution that checks for the current backend and uses the correct syntax. ``` import matplotlib import matplotlib.pyplot as plt def move_figure(f, x, y): """Move figure's upper left corner to pixel (x, y)""" backend = matplotlib.get_ba...
The following worked for me. ``` import matplotlib matplotlib.use("TkAgg") # set the backend if backend == 'TkAgg': f.canvas.manager.window.wm_geometry("+%d+%d" % (x, y)) ```
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
Inspired by @theo answer, I wrote a script to move and resize a window to a specific standard position on the screen. This was tested with the Qt4Agg backend: ``` import matplotlib.pyplot as plt def move_figure(position="top-right"): ''' Move and resize a window to a set of standard positions on the screen. ...
The following worked for me. ``` import matplotlib matplotlib.use("TkAgg") # set the backend if backend == 'TkAgg': f.canvas.manager.window.wm_geometry("+%d+%d" % (x, y)) ```
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
With help from the answers thus far and some tinkering on my own, here's a solution that checks for the current backend and uses the correct syntax. ``` import matplotlib import matplotlib.pyplot as plt def move_figure(f, x, y): """Move figure's upper left corner to pixel (x, y)""" backend = matplotlib.get_ba...
Inspired by @theo answer, I wrote a script to move and resize a window to a specific standard position on the screen. This was tested with the Qt4Agg backend: ``` import matplotlib.pyplot as plt def move_figure(position="top-right"): ''' Move and resize a window to a set of standard positions on the screen. ...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
For Qt4Agg, this worked for me. ``` fig = figure() fig.canvas.manager.window.move(0,0) ``` Tested on Win7, mpl version 1.4.2, python 2.7.5
``` '''This is a way to resize the window to a given fraction of the screen. It uses the screenSize in pixels. User specifies the fx and fy fraction of the sreen or just a fraction. Couldn't fine how to really position the window though. No hints in the current figmanager could be found. But of course, this could be co...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
``` def show_img(img, title=""): plt.imshow(img) plt.title(title) thismanager = plt.get_current_fig_manager() thismanager.window.wm_geometry("+100+100") plt.show() ```
How about defining a function to raise the window to the top level and move it toward the top-left corner (for example) like this: ``` def topfig(): figmgr = get_current_fig_manager() figmgr.canvas.manager.window.raise_() geom = figmgr.window.geometry() x,y,dx,dy = geom.getRect() figmgr.window.setG...
7,449,585
I'm writing a simple Python application that uses matplotlib to display a few figures on screen. The number of figures generated is based on user input and changes throughout the application's life. The user has the ability to issue a "plot" command to generate a new figure window with the selected data series. In orde...
2011/09/16
[ "https://Stackoverflow.com/questions/7449585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/919747/" ]
With help from the answers thus far and some tinkering on my own, here's a solution that checks for the current backend and uses the correct syntax. ``` import matplotlib import matplotlib.pyplot as plt def move_figure(f, x, y): """Move figure's upper left corner to pixel (x, y)""" backend = matplotlib.get_ba...
This also works: ``` fig = figure() fig.canvas.manager.window.Move(100,400) ``` If you want to send a plot to an image and have it open with the default image manager (which likely remembers position) use this from [here](http://www.pythonware.com/library/pil/handbook/image.htm): ``` fig.savefig('abc.png') from PIL...
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
This ``` var verificaHorario = $("#tbIntervalos").find("#" + horaInicial); ``` will find you the td that needs to be blocked. Actually this will also do: ``` var verificaHorario = $("#" + horaInicial); ``` Testing for the size() of the wrapped set will answer your question regarding the existence of the id.
As all html ids are unique in a valid html document why not search for the ID directly? If you're concerned if they type in an id that isn't a table then you can inspect the tag type that way? Just an idea! S
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
If you're trying to find an element by id, you don't need to search the table only - it should be unique on the page, and so you should be able to use: ``` var verificaHorario = $('#' + horaInicial); ``` If you need to search only in the table for whatever reason, you can use: ``` var verificaHorario = $("#tbInterv...
As all html ids are unique in a valid html document why not search for the ID directly? If you're concerned if they type in an id that isn't a table then you can inspect the tag type that way? Just an idea! S
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
I don't know if this solves your problem but instead of: ``` $("#tbIntervalos").find("td").attr("id", horaInicial); ``` you can just do: ``` $("#tbIntervalos td#" + horaInicial); ```
As all html ids are unique in a valid html document why not search for the ID directly? If you're concerned if they type in an id that isn't a table then you can inspect the tag type that way? Just an idea! S
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
This is one more option to find the element for above question `$("#tbIntervalos").find('td[id="'+horaInicial+'"]')`
As all html ids are unique in a valid html document why not search for the ID directly? If you're concerned if they type in an id that isn't a table then you can inspect the tag type that way? Just an idea! S
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
If you're trying to find an element by id, you don't need to search the table only - it should be unique on the page, and so you should be able to use: ``` var verificaHorario = $('#' + horaInicial); ``` If you need to search only in the table for whatever reason, you can use: ``` var verificaHorario = $("#tbInterv...
This ``` var verificaHorario = $("#tbIntervalos").find("#" + horaInicial); ``` will find you the td that needs to be blocked. Actually this will also do: ``` var verificaHorario = $("#" + horaInicial); ``` Testing for the size() of the wrapped set will answer your question regarding the existence of the id.
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
I don't know if this solves your problem but instead of: ``` $("#tbIntervalos").find("td").attr("id", horaInicial); ``` you can just do: ``` $("#tbIntervalos td#" + horaInicial); ```
This ``` var verificaHorario = $("#tbIntervalos").find("#" + horaInicial); ``` will find you the td that needs to be blocked. Actually this will also do: ``` var verificaHorario = $("#" + horaInicial); ``` Testing for the size() of the wrapped set will answer your question regarding the existence of the id.
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
If you're trying to find an element by id, you don't need to search the table only - it should be unique on the page, and so you should be able to use: ``` var verificaHorario = $('#' + horaInicial); ``` If you need to search only in the table for whatever reason, you can use: ``` var verificaHorario = $("#tbInterv...
I don't know if this solves your problem but instead of: ``` $("#tbIntervalos").find("td").attr("id", horaInicial); ``` you can just do: ``` $("#tbIntervalos td#" + horaInicial); ```
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
If you're trying to find an element by id, you don't need to search the table only - it should be unique on the page, and so you should be able to use: ``` var verificaHorario = $('#' + horaInicial); ``` If you need to search only in the table for whatever reason, you can use: ``` var verificaHorario = $("#tbInterv...
This is one more option to find the element for above question `$("#tbIntervalos").find('td[id="'+horaInicial+'"]')`
638,471
I have a table and each of its `td` has a **unique id** that corresponds to some time intervals (`0800` til `0830`... `0830` til `0900` and so on). I have an input text where the user will type the time intervals they want to block. If they type an interval that doesn't exist in my table, in other words, if they ty...
2009/03/12
[ "https://Stackoverflow.com/questions/638471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60286/" ]
I don't know if this solves your problem but instead of: ``` $("#tbIntervalos").find("td").attr("id", horaInicial); ``` you can just do: ``` $("#tbIntervalos td#" + horaInicial); ```
This is one more option to find the element for above question `$("#tbIntervalos").find('td[id="'+horaInicial+'"]')`
6,803,823
``` Foo a; ... Date b = a.getDate(); Date c = new Date(b.getTime()); if (b.equals(c)) System.out.println("equal"); else System.out.println("not equal"); System.out.println(b.toString()); System.out.println(b.getTime()); System.out.println(c.toString()); System.out.println(c.getTime()); ``` The above prints: ``` no...
2011/07/23
[ "https://Stackoverflow.com/questions/6803823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95281/" ]
`a.getDate()` obviously returns `java.sql.Timestamp` `java.sql.Timestamp` has different equals method than `java.uti.Date` which is basically `return obj instanceof Date && getTime() == ((Date) obj).getTime();` `Timestamp` however is more sophisticated and it requires the target to be `Timestamp` too. ```java if (...
`a.getDate()` might not return `java.util.Date` but something else, which extends it. This would explain weird `b.toString()` and `b.equals(c)` behaviour.
6,803,823
``` Foo a; ... Date b = a.getDate(); Date c = new Date(b.getTime()); if (b.equals(c)) System.out.println("equal"); else System.out.println("not equal"); System.out.println(b.toString()); System.out.println(b.getTime()); System.out.println(c.toString()); System.out.println(c.getTime()); ``` The above prints: ``` no...
2011/07/23
[ "https://Stackoverflow.com/questions/6803823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95281/" ]
`a.getDate()` obviously returns `java.sql.Timestamp` `java.sql.Timestamp` has different equals method than `java.uti.Date` which is basically `return obj instanceof Date && getTime() == ((Date) obj).getTime();` `Timestamp` however is more sophisticated and it requires the target to be `Timestamp` too. ```java if (...
This is only possible if `a.getDate()` returns a subclass of `Date`, such as `java.sql.Date`.
28,968,041
How would I achieve a grid layout similar to the one below through the use of CSS and HTML? I've attempted the use of floating and margins, but that's only allowed me to replicate the first row. ![Div grid](https://i.stack.imgur.com/Q3fk5.jpg) Current HTML ``` <div id="lens_logo"><img src="images/about-lens.png"></di...
2015/03/10
[ "https://Stackoverflow.com/questions/28968041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423819/" ]
`__mro__` is only defined for [new-style classes](https://stackoverflow.com/questions/54867/what-is-the-difference-between-old-style-and-new-style-classes-in-python). In Python 2, a class is only new-style if it inherits from `object` (or from a built in type, which in turn inherits from `object`), while all classes in...
The `__mro__` is only defined for *new style classes*, those that inherit from Python `object`. In Python 3, *all* classes are new-style classes. They inherit from `object` implicitly. In other words, old-style Python 2 classes have been removed from the language.
23,324,483
I am a beginner in Objective-C and do struggle a bit with dictionaries and arrays. My goal is to create a table view where every cell contains a picture from a server. The url for the pic comes from a JSON call. I downloaded the example from Apple called "lazy table view" and tried to merge it with the one I found ins...
2014/04/27
[ "https://Stackoverflow.com/questions/23324483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547262/" ]
The code pad allows you to run some code and instantiate objects. It is helpful for testing small bits of code, but not the type of tool that allows for complete methods as far as I understand. The code pad can be accessed under View -> Show code pad.
Sorry, I'm not able to comment on answers yet - you can write as much code in the code pad as you want, really, probably including full methods if you really wanted to - the only differences between the code pad and regular coding are 1. You don't need to write any 'boilerplate', ie code does not have to be in a method...
32,684,757
So I am trying to do something like this: ``` Class myClass <T> { T connection; public myClass(T conn) { this.connection = conn; } public void close() { connection.close() } } ``` Knowing that T will only be either Socket or BluetoothSocket (both has.close() method). Is i...
2015/09/20
[ "https://Stackoverflow.com/questions/32684757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4462975/" ]
Since [Socket](http://developer.android.com/reference/java/net/Socket.html) and [BluetoothSocket](http://developer.android.com/reference/android/bluetooth/BluetoothSocket.html) both implement [Closeable](http://developer.android.com/reference/java/io/Closeable.html), you can: ``` class myClass<T extends Closeable> imp...
I'm pretty sure you just oversaw the obvious error you made. The code should be: `connection.close()`, since this is how you called the member. :)
38,675,411
I read an answer from [What conditions should cluster deploy mode be used instead of client?](https://stackoverflow.com/questions/28807490/what-conditions-should-cluster-deploy-mode-be-used-instead-of-client), > > (In client mode) You could run spark-submit on your laptop, and the Driver Program would run on your la...
2016/07/30
[ "https://Stackoverflow.com/questions/38675411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3741571/" ]
Yes, the driver can run on your laptop. Keep in mind though: * The Spark driver will need the Hadoop configuration to be able to talk to YARN and HDFS. You could copy it from the cluster and point to it via `HADOOP_CONF_DIR`. * The Spark driver will listen on a lot of ports and expect the executors to be able to conne...
Yes, I'm running spark-submit jobs over the LAN using option --deploy-mode cluster. Currently running into [this](https://stackoverflow.com/questions/38866211/spark-monitoring-a-cluster-mode-application) issue however: the server response (json object) isn't very descriptive.
425,858
I'm aware that with an inkjet printer, printing a higher dpi image will require a huge amount of additional ink. However I was wondering in the case of a **color laser printer**, do we need more toner to print a higher dpi image? For example, printing a full-page photo in 300-dpi on a 8.27 \* 11.69 paper would cost 8...
2012/05/17
[ "https://superuser.com/questions/425858", "https://superuser.com", "https://superuser.com/users/78897/" ]
There are 2 factors here: the dpi of the image and the dpi used to print. The dpi of the image does not affect the printing cost at all, a higher dpi just means the print will take longer as the PC (and possibly the printer) has more processing to do. As far as I know there are no lasers that print 2400 dpi. Some ver...
The major cost of ink and toner is simply how much of the page is filled. Changing the resolution only changes that slightly. On ink jet printers, smaller dots tends to have a bit more overlap and less empty space at the edges. This results in about a 10% increase of ink used per doubling of resolution *on the same pr...
677,562
[![enter image description here](https://i.stack.imgur.com/r18K6.jpg)](https://i.stack.imgur.com/r18K6.jpg) This is an open circuit. Now, a chemical reaction happens in the cell which makes the current to flow in the wire. Then, the current has no other place to go, so it just gets grounded. It is similar to if I was ...
2021/11/17
[ "https://physics.stackexchange.com/questions/677562", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/287551/" ]
*Why is it said that I = 0 in open circuit . . .* This is a steady state condition assuming that the resistance of the open circuit is infinite (very, very high). The processes occurring in a cell are very complex. There is an electro-chemical reaction which results in charges being migrating from one electrode to...
A current is created due to the potential difference in a circuit (which means when one side of the circuit has more + charges than the other side (and vice-versa for the other side))), this causes a charge to flow from one side to the other(current). When its open due you think it will ever reach the other side? And e...
677,562
[![enter image description here](https://i.stack.imgur.com/r18K6.jpg)](https://i.stack.imgur.com/r18K6.jpg) This is an open circuit. Now, a chemical reaction happens in the cell which makes the current to flow in the wire. Then, the current has no other place to go, so it just gets grounded. It is similar to if I was ...
2021/11/17
[ "https://physics.stackexchange.com/questions/677562", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/287551/" ]
In simple terms initially there is a potential difference across the wires, current flows, due to the high resistance of air, charges will accummalate on the end of the wires, this charge accumulation creates a potential difference to counteract the batteries potential, once they are equal, no current flows
A current is created due to the potential difference in a circuit (which means when one side of the circuit has more + charges than the other side (and vice-versa for the other side))), this causes a charge to flow from one side to the other(current). When its open due you think it will ever reach the other side? And e...
677,562
[![enter image description here](https://i.stack.imgur.com/r18K6.jpg)](https://i.stack.imgur.com/r18K6.jpg) This is an open circuit. Now, a chemical reaction happens in the cell which makes the current to flow in the wire. Then, the current has no other place to go, so it just gets grounded. It is similar to if I was ...
2021/11/17
[ "https://physics.stackexchange.com/questions/677562", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/287551/" ]
*Why is it said that I = 0 in open circuit . . .* This is a steady state condition assuming that the resistance of the open circuit is infinite (very, very high). The processes occurring in a cell are very complex. There is an electro-chemical reaction which results in charges being migrating from one electrode to...
There is indeed [a very brief moment](https://physics.stackexchange.com/questions/531183/does-an-electric-current-flow-in-an-open-circuit) when the wires are attached to the terminals when a current flows, during which the wires are brought to the potential of the terminal. There is no current otherwise, because as yo...
677,562
[![enter image description here](https://i.stack.imgur.com/r18K6.jpg)](https://i.stack.imgur.com/r18K6.jpg) This is an open circuit. Now, a chemical reaction happens in the cell which makes the current to flow in the wire. Then, the current has no other place to go, so it just gets grounded. It is similar to if I was ...
2021/11/17
[ "https://physics.stackexchange.com/questions/677562", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/287551/" ]
In simple terms initially there is a potential difference across the wires, current flows, due to the high resistance of air, charges will accummalate on the end of the wires, this charge accumulation creates a potential difference to counteract the batteries potential, once they are equal, no current flows
There is indeed [a very brief moment](https://physics.stackexchange.com/questions/531183/does-an-electric-current-flow-in-an-open-circuit) when the wires are attached to the terminals when a current flows, during which the wires are brought to the potential of the terminal. There is no current otherwise, because as yo...
32,173,901
Suppose I have a function in R that takes multiple arguments, and I'd like to reduce it to a function of fewer arguments by setting some of the arguments to pre-specified values. I'm trying to figure out what is the best way to do this is in R. For example, suppose I have a function ``` f <- function(a,b,c,d){a+b+c+d...
2015/08/24
[ "https://Stackoverflow.com/questions/32173901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468291/" ]
You could roll your own without too much coding using `do.call`: ``` partial <- function(f, ...) { l <- list(...) function(...) { do.call(f, c(l, list(...))) } } ``` Basically `partial` returns a function that stores `f` as well as the originally provided arguments (stored in list `l`). When this function ...
You have also `Curry` from package `functional`: ``` library(functional) f <- function(a, b, c, d) a+b+c+d ff = Curry(f, a=2, c=10) ff(1,5) #[1] 18 ff(b=1,d=5) #[1] 18 ```
32,173,901
Suppose I have a function in R that takes multiple arguments, and I'd like to reduce it to a function of fewer arguments by setting some of the arguments to pre-specified values. I'm trying to figure out what is the best way to do this is in R. For example, suppose I have a function ``` f <- function(a,b,c,d){a+b+c+d...
2015/08/24
[ "https://Stackoverflow.com/questions/32173901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4468291/" ]
There are functions in the `pryr` package that can handle this, namely `partial()` ``` f <- function(a, b, c, d) a + b + c + d pryr::partial(f, a = 1, c = 2) # function (...) # f(a = 1, c = 2, ...) ``` So you can use it like this - ``` new_fun <- pryr::partial(f, a = 1, c = 2) new_fun(b = 2, d = 5) # [1] 10 ## ...
You have also `Curry` from package `functional`: ``` library(functional) f <- function(a, b, c, d) a+b+c+d ff = Curry(f, a=2, c=10) ff(1,5) #[1] 18 ff(b=1,d=5) #[1] 18 ```
46,310,138
I have two ndarrays. First ndarray has string in one column and float values in another column. Second ndarray contains only a column of string values. For eg: ``` Array1 Array2 "abc" 1.000 "abc" "fsfds" -5.000 "qw" "svs" 2.094 "svs" "dfdsge" 3.348 "dd" ...
2017/09/19
[ "https://Stackoverflow.com/questions/46310138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4380718/" ]
The easiest way to turn your example into arrays is to copy-n-paste it as a multiline string and use `genfromtxt` to parse it: ``` In [344]: txt=b'''"abc" 1.000 "abc" ...: "fsfds" -5.000 "qw" ...: "svs" 2.094 "svs" ...: "dfdsge" 3.348 "dd" ''' In [346]: np...
You can use array comparison as your index for the first dimension to select the rows you want. I'm not sure exactly how you have an ndarray containing both strings and floats, but here's an example where we set it so the first and last rows have the same value in the first column. ``` import numpy as np array_1 = np...
46,310,138
I have two ndarrays. First ndarray has string in one column and float values in another column. Second ndarray contains only a column of string values. For eg: ``` Array1 Array2 "abc" 1.000 "abc" "fsfds" -5.000 "qw" "svs" 2.094 "svs" "dfdsge" 3.348 "dd" ...
2017/09/19
[ "https://Stackoverflow.com/questions/46310138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4380718/" ]
The easiest way to turn your example into arrays is to copy-n-paste it as a multiline string and use `genfromtxt` to parse it: ``` In [344]: txt=b'''"abc" 1.000 "abc" ...: "fsfds" -5.000 "qw" ...: "svs" 2.094 "svs" ...: "dfdsge" 3.348 "dd" ''' In [346]: np...
I think that list comprehension can do the trick here: ``` Output=[i[1] for i in Array1 if i[0] in Array2] ```
44,666,608
In Pandas I have a series and a multi-index: ``` s = pd.Series([1,2,3,4], index=['w', 'x', 'y', 'z']) idx = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']]) ``` What is the best way for me to create a DataFrame that has idx as index, and s as value for each row, preserving the index in S as columns? ``` df = ...
2017/06/21
[ "https://Stackoverflow.com/questions/44666608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/291877/" ]
Use the `pd.DataFrame` constructor followed by `assign` ``` pd.DataFrame(index=idx).assign(**s) w x y z a c 1 2 3 4 d 1 2 3 4 b c 1 2 3 4 d 1 2 3 4 ```
Use [s]\*len(s) as data, idx as index and s.index as column to reconstruct a df. ``` pd.DataFrame([s]*len(s),idx,s.index) Out[56]: w x y z a c 1 2 3 4 d 1 2 3 4 b c 1 2 3 4 d 1 2 3 4 ```
44,666,608
In Pandas I have a series and a multi-index: ``` s = pd.Series([1,2,3,4], index=['w', 'x', 'y', 'z']) idx = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']]) ``` What is the best way for me to create a DataFrame that has idx as index, and s as value for each row, preserving the index in S as columns? ``` df = ...
2017/06/21
[ "https://Stackoverflow.com/questions/44666608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/291877/" ]
Use the `pd.DataFrame` constructor followed by `assign` ``` pd.DataFrame(index=idx).assign(**s) w x y z a c 1 2 3 4 d 1 2 3 4 b c 1 2 3 4 d 1 2 3 4 ```
You can use [`numpy.repeat`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.repeat.html) with [`numpy.ndarray.reshape`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.reshape.html) for duplicate data and last `DataFrame` constructor: ``` arr = np.repeat(s.values, len(idx)).reshape(-1, l...
44,666,608
In Pandas I have a series and a multi-index: ``` s = pd.Series([1,2,3,4], index=['w', 'x', 'y', 'z']) idx = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']]) ``` What is the best way for me to create a DataFrame that has idx as index, and s as value for each row, preserving the index in S as columns? ``` df = ...
2017/06/21
[ "https://Stackoverflow.com/questions/44666608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/291877/" ]
You can use [`numpy.repeat`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.repeat.html) with [`numpy.ndarray.reshape`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.reshape.html) for duplicate data and last `DataFrame` constructor: ``` arr = np.repeat(s.values, len(idx)).reshape(-1, l...
Use [s]\*len(s) as data, idx as index and s.index as column to reconstruct a df. ``` pd.DataFrame([s]*len(s),idx,s.index) Out[56]: w x y z a c 1 2 3 4 d 1 2 3 4 b c 1 2 3 4 d 1 2 3 4 ```
39,182,063
I have tried to insert data into database in android. This one works: ``` public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL( "create table study " + "(percentage integer primary key,videoDuration text,totalTime text,date text)" ); } pu...
2016/08/27
[ "https://Stackoverflow.com/questions/39182063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6764729/" ]
Serial column accept only unique value. **Just update** ``` db.execSQL("create table study (serial integer,percentage text,videoDuration text,totalTime text,date text)"); ```
Percentage cannot be used a primary key, like the error suggested it should be unique, recommended approach is to add `id` field. ``` db.execSQL( "create table study " + "(id integer primary key, percentage,videoDuration text,totalTime text,date text)" ); ```
39,182,063
I have tried to insert data into database in android. This one works: ``` public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL( "create table study " + "(percentage integer primary key,videoDuration text,totalTime text,date text)" ); } pu...
2016/08/27
[ "https://Stackoverflow.com/questions/39182063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6764729/" ]
Serial column accept only unique value. **Just update** ``` db.execSQL("create table study (serial integer,percentage text,videoDuration text,totalTime text,date text)"); ```
While creating the table take id and it as make Primary key Auto-increment : ``` db.execSQL("create table study (id integer primary key autoincrement, serial integer,percentage text,videoDuration text,totalTime text,date text)" ); ```
39,182,063
I have tried to insert data into database in android. This one works: ``` public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL( "create table study " + "(percentage integer primary key,videoDuration text,totalTime text,date text)" ); } pu...
2016/08/27
[ "https://Stackoverflow.com/questions/39182063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6764729/" ]
Try it, adding autoincrement and removing the setting of the id manually: ``` db.execSQL( "create table study " + "(serial integer primary key AUTOINCREMENT ,percentage text,videoDuration text,totalTime text,date text)" ); public boolean insertStudy(String percentage, String videoDuration, Str...
Percentage cannot be used a primary key, like the error suggested it should be unique, recommended approach is to add `id` field. ``` db.execSQL( "create table study " + "(id integer primary key, percentage,videoDuration text,totalTime text,date text)" ); ```
39,182,063
I have tried to insert data into database in android. This one works: ``` public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL( "create table study " + "(percentage integer primary key,videoDuration text,totalTime text,date text)" ); } pu...
2016/08/27
[ "https://Stackoverflow.com/questions/39182063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6764729/" ]
Try it, adding autoincrement and removing the setting of the id manually: ``` db.execSQL( "create table study " + "(serial integer primary key AUTOINCREMENT ,percentage text,videoDuration text,totalTime text,date text)" ); public boolean insertStudy(String percentage, String videoDuration, Str...
While creating the table take id and it as make Primary key Auto-increment : ``` db.execSQL("create table study (id integer primary key autoincrement, serial integer,percentage text,videoDuration text,totalTime text,date text)" ); ```
34,769,002
I have an apk file. Now i need to fetch package-name as well as launcher activity from apk so that i can install apk and launch app from my test cases.
2016/01/13
[ "https://Stackoverflow.com/questions/34769002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5784604/" ]
Android Aapt provides this feature. Use below commands a)package : ``` D:\Android\sdk\build-tools\23.0.2>aapt d badging Apk-path\apk-name.apk |grep package ``` b)launchable-activity: ``` aapt d badging Apk-path\apk-name.apk |grep launchable-activity ```
You can also use the following steps: 1. Connect device to your computer 2. Open any IDE Android studio or eclipse 3. Look at the logs of the device 4. Filter the logs by using your app name 5. open the app on your device and you would be able to see package name and launcher activity in the logs.
34,769,002
I have an apk file. Now i need to fetch package-name as well as launcher activity from apk so that i can install apk and launch app from my test cases.
2016/01/13
[ "https://Stackoverflow.com/questions/34769002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5784604/" ]
You can take a look at [link](http://qahumor.blogspot.in/2015/06/appium-how-to-get-package-name-of.html) There are multiple ways in which we can obtain the package name of Android .apk file. Here are the some quick ways to get the package name. **Step 1** : If its public app and available in <https://play.google.com...
You can also use the following steps: 1. Connect device to your computer 2. Open any IDE Android studio or eclipse 3. Look at the logs of the device 4. Filter the logs by using your app name 5. open the app on your device and you would be able to see package name and launcher activity in the logs.
28,809,148
I am trying to collect information on the amount of space left on different servers. So when I execute `df -k` i get output as: ``` Filesystem 1024-blocks Used Avail Capacity Mounted on /dev/ad1s1f 125925198 2568970 113282214 2% /builds ``` And sometimes the output comes as : ``` Filesystem ...
2015/03/02
[ "https://Stackoverflow.com/questions/28809148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1957847/" ]
You can for example say: ``` df --output=source,avail ``` Or as commented by [Tim Bunce](https://stackoverflow.com/questions/19703621/get-free-disk-space-with-df-to-just-display-free-space-in-kb/19703644#comment43896106_19703644), you can use `--direct` to prevent the long filesystem name make the line split in two....
fedorqui's solution is cleaner, but only works for df A more general approach is to collapse multiple spaces to a single space using `sed 's/ \+/ /g'` or `tr -s ' '`, then use `cut` with spaces as delimiters: `cut -d" " -f 4` So the command is: ``` df -k | tr -s ' ' | cut -d" " -f 4 ``` Which results in something l...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
You can also use an `in` command ``` db.zips.aggregate([ { $project: { first_char: { $substr : ["$city",0,1] }, "_id":"$_id" } }, { $match: { first_char: { $in: ["0","1","2","3","4","5","6","7"...
With the mongodb **4.4** (upcoming), You can use [**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) pipeline operator to check whether the expression is integer or other BSON type. ``` db.zips.find({ "$expr": { "$anyElementTrue": { "$isNumber": "$city" }}}) ``` [**`$isNumber`...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
you can also try like the following, using regular expression without using $regex ``` db.zips.aggregate([ {$project : { city : { $substr : ["$city",0,1] } }}, {$sort : {city : 1}}, {$match: { city:/[0-9]/}} ]) ```
With the mongodb **4.4** (upcoming), You can use [**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) pipeline operator to check whether the expression is integer or other BSON type. ``` db.zips.find({ "$expr": { "$anyElementTrue": { "$isNumber": "$city" }}}) ``` [**`$isNumber`...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]},pop:1}}, {$group:{_id:"$city",sumPop:{$sum:"$pop"}}}, {$sort : {_id : 1}}, {$match:{_id : {$regex:/\d/}} }, {$group:{_id:"id",sumPop:{$sum:"$sumPop"}}}, ]); ```
With the mongodb **4.4** (upcoming), You can use [**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) pipeline operator to check whether the expression is integer or other BSON type. ``` db.zips.find({ "$expr": { "$anyElementTrue": { "$isNumber": "$city" }}}) ``` [**`$isNumber`...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
Why not to use $regex? ``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city:{$regex:'[0-9]'}}} ]) ```
You can also use an `in` command ``` db.zips.aggregate([ { $project: { first_char: { $substr : ["$city",0,1] }, "_id":"$_id" } }, { $match: { first_char: { $in: ["0","1","2","3","4","5","6","7"...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
An easier way to match all docs where `city` is a numeric string is using the property `'0' <= city <= '9'` i.e. your aggregation query becomes: ``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city: {$gte: '0', $lte: '9'}}} ]); ``` When using JohnnyHK...
With the mongodb **4.4** (upcoming), You can use [**`$isNumber`**](https://docs.mongodb.com/master/reference/operator/aggregation/isNumber/) pipeline operator to check whether the expression is integer or other BSON type. ``` db.zips.find({ "$expr": { "$anyElementTrue": { "$isNumber": "$city" }}}) ``` [**`$isNumber`...
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
Use the [`$type`](http://docs.mongodb.org/manual/reference/operator/type/) operator in your `$match`: ```javascript db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city: {$type: 16}}} // city is a 32-bit integer ]); ``` There isn't a single type valu...
Simply use: ``` db.zips.aggregate([ {$match: { 'city': { $regex: '^[0-9].*'} }}]) ``` This work fine for me!
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
An easier way to match all docs where `city` is a numeric string is using the property `'0' <= city <= '9'` i.e. your aggregation query becomes: ``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city: {$gte: '0', $lte: '9'}}} ]); ``` When using JohnnyHK...
you can also try like the following, using regular expression without using $regex ``` db.zips.aggregate([ {$project : { city : { $substr : ["$city",0,1] } }}, {$sort : {city : 1}}, {$match: { city:/[0-9]/}} ]) ```
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
Use the [`$type`](http://docs.mongodb.org/manual/reference/operator/type/) operator in your `$match`: ```javascript db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city: {$type: 16}}} // city is a 32-bit integer ]); ``` There isn't a single type valu...
Why not to use $regex? ``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city:{$regex:'[0-9]'}}} ]) ```
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
Use the [`$type`](http://docs.mongodb.org/manual/reference/operator/type/) operator in your `$match`: ```javascript db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]}}}, {$sort : {city : 1}}, {$match: {city: {$type: 16}}} // city is a 32-bit integer ]); ``` There isn't a single type valu...
``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]},pop:1}}, {$group:{_id:"$city",sumPop:{$sum:"$pop"}}}, {$sort : {_id : 1}}, {$match:{_id : {$regex:/\d/}} }, {$group:{_id:"id",sumPop:{$sum:"$sumPop"}}}, ]); ```
13,409,386
So I have a field called 'city' in my results...the results are corrupted, some times it's an actual name, sometimes it's a number. The following code displays all the records... ``` db.zips.aggregate([{$project : {city:{$substr:["$city",0,1]}}},{$sort : {city : 1}} ]) ``` I need to modify this line to display only ...
2012/11/16
[ "https://Stackoverflow.com/questions/13409386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369854/" ]
Simply use: ``` db.zips.aggregate([ {$match: { 'city': { $regex: '^[0-9].*'} }}]) ``` This work fine for me!
``` db.zips.aggregate([ {$project : {city:{$substr:["$city",0,1]},pop:1}}, {$group:{_id:"$city",sumPop:{$sum:"$pop"}}}, {$sort : {_id : 1}}, {$match:{_id : {$regex:/\d/}} }, {$group:{_id:"id",sumPop:{$sum:"$sumPop"}}}, ]); ```
7,020,523
I keep getting this error: 'str' object has no attribute 'resolve' when trying to accessing the django admin site and I can't figure out why. I have apps within my project that have their own admin.py files. Could this cause it? here is my urls.py: ``` from django.conf.urls.defaults import * import settings from djan...
2011/08/11
[ "https://Stackoverflow.com/questions/7020523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/828824/" ]
According to excellent answer posted here: <http://redsymbol.net/articles/django-attributeerror-str-object-no-attribute-resolve/> There are generally several sources of this error: 1. You missed 'pattern keyword': ``` urlpatterns = ('', (r'^$', direct_to_template, {'template' : 'a.html'}), # ... ``` this should be...
For me, this caused the problem: ``` urlpatterns = patterns('', url(r'^all/$', 'album.views.albums'), """ url(r'^create/$', 'album.views.create'), url(r'^get/(?P<album_id>\d+)/$', 'album.views.album'), url(r'^like/(?P<album_id>\d+)/$', 'album.views.like_album'), """ ) ``` and this solved it: ```...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
I have a lot of understanding for your users. You are doing a fundamental error of system administration: You create a solution that is easy for the sysadmins, but forget the needs and requirements of the users. 200mb per user is simply insane, and it is a limitation that causes problems for them, as they have to bothe...
PST files get a bad wrap and sometimes it's overblown and unwarranted. If my company uses Microsoft Exchange server then using PST files is generally frowned upon. If my company uses an external email provider that supports only POP then there's almost no alternative to using PST files. It's not that PST files themselv...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
I have a lot of understanding for your users. You are doing a fundamental error of system administration: You create a solution that is easy for the sysadmins, but forget the needs and requirements of the users. 200mb per user is simply insane, and it is a limitation that causes problems for them, as they have to bothe...
I am one of those users that uses Lotus Notes and have been restricted to 200MB. 1. I know you're talking about Outlook and not Notes, but I need to vent and say that Lotus Notes is horrible (please never implement this); it's horrible to open, use, navigate, and script for. So this is more a precautionary statement, ...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
I have a lot of understanding for your users. You are doing a fundamental error of system administration: You create a solution that is easy for the sysadmins, but forget the needs and requirements of the users. 200mb per user is simply insane, and it is a limitation that causes problems for them, as they have to bothe...
The best way to encourage users to take up a new service, is to make sure that it is better than what you currently provide, otherwise what's the point. I would make sure they have the ability to store more than 200mb, or are trained in how to prune their mailboxes of large attachments, although lets be honest, who rea...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
I have a lot of understanding for your users. You are doing a fundamental error of system administration: You create a solution that is easy for the sysadmins, but forget the needs and requirements of the users. 200mb per user is simply insane, and it is a limitation that causes problems for them, as they have to bothe...
The key stakeholders on the business side of the house need to understand why IT wants to banish PST files. The means folks in the trenches as well as the executive type people. PSTs to the users aren't "bad" or "evil" -- they are an essential tool that allows them to get work done. Most folks aren't aware of the risk...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
I have a lot of understanding for your users. You are doing a fundamental error of system administration: You create a solution that is easy for the sysadmins, but forget the needs and requirements of the users. 200mb per user is simply insane, and it is a limitation that causes problems for them, as they have to bothe...
It's really easy. Well it's easy to say and easy to understand. Might be difficult to do, however. Simply put, you need to understand your users problems, and then you need to solve *their* problems, not the *IT Department's* problems. If they are using PST files then find out why and address that. If they are relucta...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
The best way to encourage users to take up a new service, is to make sure that it is better than what you currently provide, otherwise what's the point. I would make sure they have the ability to store more than 200mb, or are trained in how to prune their mailboxes of large attachments, although lets be honest, who rea...
PST files get a bad wrap and sometimes it's overblown and unwarranted. If my company uses Microsoft Exchange server then using PST files is generally frowned upon. If my company uses an external email provider that supports only POP then there's almost no alternative to using PST files. It's not that PST files themselv...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
The best way to encourage users to take up a new service, is to make sure that it is better than what you currently provide, otherwise what's the point. I would make sure they have the ability to store more than 200mb, or are trained in how to prune their mailboxes of large attachments, although lets be honest, who rea...
I am one of those users that uses Lotus Notes and have been restricted to 200MB. 1. I know you're talking about Outlook and not Notes, but I need to vent and say that Lotus Notes is horrible (please never implement this); it's horrible to open, use, navigate, and script for. So this is more a precautionary statement, ...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
The best way to encourage users to take up a new service, is to make sure that it is better than what you currently provide, otherwise what's the point. I would make sure they have the ability to store more than 200mb, or are trained in how to prune their mailboxes of large attachments, although lets be honest, who rea...
The key stakeholders on the business side of the house need to understand why IT wants to banish PST files. The means folks in the trenches as well as the executive type people. PSTs to the users aren't "bad" or "evil" -- they are an essential tool that allows them to get work done. Most folks aren't aware of the risk...
234,936
Server using Apache and Plesk 9. I have set-up multiple domains each with its own IP for SSL. Each domain has its own SSL config file **/var/www/vhosts/mydomain/conf/vhost\_ssl.conf** I have disabled SSLv2 in **/etc/httpd/conf.d/ssl.conf** and checked it with `openssl s_client –ssl2 –connect localhost:443` result ...
2011/02/13
[ "https://serverfault.com/questions/234936", "https://serverfault.com", "https://serverfault.com/users/70581/" ]
The best way to encourage users to take up a new service, is to make sure that it is better than what you currently provide, otherwise what's the point. I would make sure they have the ability to store more than 200mb, or are trained in how to prune their mailboxes of large attachments, although lets be honest, who rea...
It's really easy. Well it's easy to say and easy to understand. Might be difficult to do, however. Simply put, you need to understand your users problems, and then you need to solve *their* problems, not the *IT Department's* problems. If they are using PST files then find out why and address that. If they are relucta...
26,354
Does anyone know how to print a barcode to the Intermec PB20 bluetooth printer from a Windows Compact Framework application? We are currently using the Intermec LinePrinter API but have been unable to find a way to print a barcode. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
2008/08/25
[ "https://Stackoverflow.com/questions/26354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/620435/" ]
Thank you all for your thoughts. Printing directly to the serial port is likely the most flexible method. In this case we didn't want to replicate all of the work that was already built into the Intermec dll for handling the port, printer errors, etc. We were able to get this working by sending the printer the appropri...
Last time I had to print Barcode (despite the printer or framework) I resorted to use a True Type font with the Barcode I needed. (In my case was EAN-13 something), an european barcode. There are fonts where you simply write numbers (and/or letters when supported) and you get a perfect barcode any scanner can read :) ...