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
4,082,537
I am kind of stuck with a simple type check on a generic helper class I am writing. The idea will be clear if you take a look at the source code. It works nice for normal things, like DateTime and bool, but I got a problem with generics. How do I check for e.g. ObservableCollection < **something** > and count it. I do...
2010/11/02
[ "https://Stackoverflow.com/questions/4082537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109646/" ]
Is it necessary to go this route? ``` if (parent is DateTime) return new TextBlock() { Text = ((DateTime)parent).ToShortTimeString() }; if (parent is ICollection) return new TextBlock() { Text = ((ICollection)parent).Count }; if (parent is IEnumerable) return new TextBlock() { Text = ((IEnumerable)parent).C...
I think you have your IsAssignablefrom method call backwards. I think you need to say `typeof(IList).IsAssignableFrom(propertyInfo.PropertyType)` Regardless, I would retrieve the object directly and reflect on it, rather than reflecting on the type of the property. This way, if you have a property of type object, that...
4,082,537
I am kind of stuck with a simple type check on a generic helper class I am writing. The idea will be clear if you take a look at the source code. It works nice for normal things, like DateTime and bool, but I got a problem with generics. How do I check for e.g. ObservableCollection < **something** > and count it. I do...
2010/11/02
[ "https://Stackoverflow.com/questions/4082537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/109646/" ]
``` propertyInfo.PropertyType.IsAssignableFrom(typeof(IList)) ``` This is a classic mistake (I think it's so common because of the `value is IList` syntax). What you actually want is: ``` typeof(IList).IsAssignableFrom(propertyInfo.PropertyType) ``` There are other issues to consider, such as whether you want to s...
I think you have your IsAssignablefrom method call backwards. I think you need to say `typeof(IList).IsAssignableFrom(propertyInfo.PropertyType)` Regardless, I would retrieve the object directly and reflect on it, rather than reflecting on the type of the property. This way, if you have a property of type object, that...
34,876,623
I got part of a sentence in my database like : ``` beautiful house close to the beach this peaceful touristic area under a beautiful tree behind the property ``` I would like to select sentence that does not contain a list of word like 'to','a' Wanted result: ``` this peaceful touristic area behind the property ...
2016/01/19
[ "https://Stackoverflow.com/questions/34876623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5809722/" ]
You can use *word boundaries* applied to the *group* of two alternatives listed after `|` operator: ``` WHERE semi_sentence NOT RLIKE '[[:<:]](to|a)[[:>:]]' ``` See [what this regex matches](https://regex101.com/r/vA5dB1/1) (you will get those that do not match since you are using `NOT`, and `\b` is used in PCRE ins...
1. you can try `'.*?\sto\s.*'` and `'.*?\sa\s.*'`. 2. or add `?` after the first `.*` in you sentence. thanks.
47,724,573
I have: ``` myColCI<-function(colName){ predictorvariable <- glm(death180 ~ nepalData[,colName], data=nepalData, family="binomial") summary(predictorvariable) confint(predictorvariable) } ``` One of the names of the column is parity so when after making my function, when I put `myColCI(parity)`, it says the ...
2017/12/09
[ "https://Stackoverflow.com/questions/47724573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9075008/" ]
Your formula is wrong here, hence you are getting the error, The right hand side after tilda side shouldn't be a reference to a dataframe. It should be column names separated by plus signs : From the documentation of `?formula` > > The models fit by, e.g., the lm and glm functions are specified in a > compact symbo...
This is what you have to do ``` myColCI("parity") ``` This should give you the answer. I don't think your code is wrong. You are trying to subset a column of a data frame using the column name. In R, when you do this, you have to pass the name as a string. eg ``` dataframe[,"column_name"] ``` For your function, ...
51,374,752
Trying to deal with CORS set up a simple Node / Express server like so: ``` const express = require('express'); var cors = require('cors'); const app = express(); const port = process.env.PORT || 3000; app.use(cors()); app.use(express.static('public')); app.listen(port, () => { console.log('Server active on port...
2018/07/17
[ "https://Stackoverflow.com/questions/51374752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4750401/" ]
You may try setting the options to be passed to your `cors` package, like this, ``` const corsOptions = { origin: process.env.CORS_ALLOW_ORIGIN || '*', methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS'], allowedHeaders: ['Content-Type', 'Authorization'] }; app.use(cors(corsOptions)); ``` Hope this he...
You can use a cors middleware like this ``` const corsMiddleware = (req: Request, res: Response, next: NextFunction) => { logger.debug(req.method + " at " + req.url); res.setHeader("Access-Control-Allow-Origin", "*"); // you can optionally replace * with your server address res.setHeader("Access-Control-Allow-C...
264,238
I was making some changes to a remote file in vi using the terminal when I accidently pressed `Ctrl`+`S` instead of `:wq`. Now everything got hanged. I tried `Escape,:q!` and all sorts of vi commans but nothing is responding. The Terminal Screen is stuck. I can't close the Terminal session as of now as it will lead to...
2013/03/05
[ "https://askubuntu.com/questions/264238", "https://askubuntu.com", "https://askubuntu.com/users/86687/" ]
`Ctrl`+`Q` will undo `Ctrl`+`S`. These are ancient control codes to stop and resume output to a terminal. They can still be useful, for instance when you are `tailf`-ing a log file and something interesting scrolls by, but this era of unlimited scrollback buffers has really obsoleted them.
I would like to complement [zwets' accepted answer](https://askubuntu.com/a/264253/22949). You can see the meaning of special keypresses by issuing the commands `stty -a` and [`man stty`](http://manpages.ubuntu.com/manpages/bionic/en/man1/stty.1.html). `stty -a` prints all current settings of the terminal. The result...
14,085,881
I would like to implement a simple authentication in an JSF/Primefaces application. I have tried lots of different things, e.g. [Dialog - Login Demo](http://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml) makes a simple test on a dialog, but it does not login a user or? I also have taken a look at Java ...
2012/12/29
[ "https://Stackoverflow.com/questions/14085881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1936452/" ]
> > Is there a way to authenticate a user without defining something in the application server? > > > This is a long and *very* thorny story. It often comes up as one the main points of criticism against Java EE. The core of the story is that traditionally Java EE applications are supposed to be deployed with "un...
I have found a for me suitable and easy solution by simply using Web Filters. I have added a filter to web.xml like ``` <!-- Authentication Filter --> <filter> <filter-name>AuthenticationFilter</filter-name> <filter-class>org.example.filters.AuthenticationFilter</filter-class> </filter> <filter-mapping> <f...
620,445
I am using a very simple model to show the unity gainbandwidth of a closed loop sample and hold with a closed loop gain of 2. One would expect an ideal OTA to have a GBW independent of rout as GBW is just \$ \frac{g\_m\*r\_{out}}{r\_{out}\*C\_L} \$ or \$GBW = g\_m/C\_L (\frac {rad}{s}).\$ Yet, the simulation I contriv...
2022/05/20
[ "https://electronics.stackexchange.com/questions/620445", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/11779/" ]
If it helps anyone, I figured out (through a fairly tedious analysis) that it's more complicated than the numerous texts, literature, and theses using sample and hold and multiplying dac calculations make it out to be (it can be quite sensitive to low feedback factor and output impedance for example). I found an [exce...
I tried this circuit, but as soon as I run the simulator, it gives an error (logical). This error is dependent on the two capacitors. The midpoint has no DC path to the ground. If one adds paralleled resistors, behavior change immediately. Here is a simulation where (my) R1 and C2 are stepped logs (x10). O...
5,847,598
i heard that domain driven design pattern but do not know what it is exactly. is it design pattern? if so then how it is different from mvc or mvp. please discuss this. how to implement domain driven design pattern with c#.
2011/05/01
[ "https://Stackoverflow.com/questions/5847598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/728750/" ]
In short: It's not a design pattern. You can see it as **set of patterns** and **principles** where you write code that reflects real life objects and concepts in a specific domain (problem area): From the StackOverflow tag: > > Domain-driven design (DDD) is an > approach to developing software for > complex needs...
I believe this link should get you started and more.. <http://www.infoq.com/articles/ddd-in-practice> The example in the article is not terrific (see the comments). Nonetheless, it contains some decent material on the ideas. Also, Google search on "anemic domain models" will return some relevant results. To read abo...
5,847,598
i heard that domain driven design pattern but do not know what it is exactly. is it design pattern? if so then how it is different from mvc or mvp. please discuss this. how to implement domain driven design pattern with c#.
2011/05/01
[ "https://Stackoverflow.com/questions/5847598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/728750/" ]
In short: It's not a design pattern. You can see it as **set of patterns** and **principles** where you write code that reflects real life objects and concepts in a specific domain (problem area): From the StackOverflow tag: > > Domain-driven design (DDD) is an > approach to developing software for > complex needs...
For DDD in the C# world, please look at [Applying Domain-Driven Design and Patterns: With Examples in C# and .NET](https://rads.stackoverflow.com/amzn/click/com/0321268202) . Jimmy Nilsson (the author) is a recognised leader in DDD using a C# slant.
5,847,598
i heard that domain driven design pattern but do not know what it is exactly. is it design pattern? if so then how it is different from mvc or mvp. please discuss this. how to implement domain driven design pattern with c#.
2011/05/01
[ "https://Stackoverflow.com/questions/5847598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/728750/" ]
I believe this link should get you started and more.. <http://www.infoq.com/articles/ddd-in-practice> The example in the article is not terrific (see the comments). Nonetheless, it contains some decent material on the ideas. Also, Google search on "anemic domain models" will return some relevant results. To read abo...
For DDD in the C# world, please look at [Applying Domain-Driven Design and Patterns: With Examples in C# and .NET](https://rads.stackoverflow.com/amzn/click/com/0321268202) . Jimmy Nilsson (the author) is a recognised leader in DDD using a C# slant.
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
In pseudo-assembly language, ```none li #0, r0 test r1 beq L1 li #1, r0 L1: ``` *may or may not* be faster than ```none test r1 beq L1 li #1, r0 bra L2 L1: li #0, r0 L2: ``` depending on how sophisticated the actual CPU is. Going from simplest to fanciest: ...
What would make you think any of them even the one liner is faster or slower? ``` unsigned int fun0 ( unsigned int condition, unsigned int value ) { value = 5; if (condition) { value = 6; } return(value); } unsigned int fun1 ( unsigned int condition, unsigned int value ) { if (condition) ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
The answer from [CompuChip](https://stackoverflow.com/a/43202221/2805305) shows that for `int` they both are optimized to the same assembly, so it doesn't matter. > > What if value is a matrix ? > > > I will interpret this in a more general way, i.e. what if `value` is of a type whose constructions and assignment...
In unoptimised code, the first example assigns a variable always once and sometimes twice. The second example only ever assigns a variable once. The conditional is the same on both code paths, so that shouldn't matter. In optimised code, it depends on the compiler. As always, if you are that concerned, generate the as...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
What would make you think any of them even the one liner is faster or slower? ``` unsigned int fun0 ( unsigned int condition, unsigned int value ) { value = 5; if (condition) { value = 6; } return(value); } unsigned int fun1 ( unsigned int condition, unsigned int value ) { if (condition) ...
Ok, since assembly is one of the tags, I will just assume your code is pseudo code (and not necessarily c) and translate it by human into 6502 assembly. 1st Option (without else) ``` ldy #$00 lda #$05 dey bmi false lda #$06 false brk ``` 2nd Option (with else) ``` ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
**TL;DR:** In unoptimized code, `if` without `else` seems irrelevantly more efficient but with even the most basic level of optimization enabled the code is basically rewritten to `value = condition + 5`. --- I [gave it a try](https://gcc.godbolt.org/) and generated the assembly for the following code: ``` int ifonl...
In unoptimised code, the first example assigns a variable always once and sometimes twice. The second example only ever assigns a variable once. The conditional is the same on both code paths, so that shouldn't matter. In optimised code, it depends on the compiler. As always, if you are that concerned, generate the as...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
In pseudo-assembly language, ```none li #0, r0 test r1 beq L1 li #1, r0 L1: ``` *may or may not* be faster than ```none test r1 beq L1 li #1, r0 bra L2 L1: li #0, r0 L2: ``` depending on how sophisticated the actual CPU is. Going from simplest to fanciest: ...
In unoptimised code, the first example assigns a variable always once and sometimes twice. The second example only ever assigns a variable once. The conditional is the same on both code paths, so that shouldn't matter. In optimised code, it depends on the compiler. As always, if you are that concerned, generate the as...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
The answer from [CompuChip](https://stackoverflow.com/a/43202221/2805305) shows that for `int` they both are optimized to the same assembly, so it doesn't matter. > > What if value is a matrix ? > > > I will interpret this in a more general way, i.e. what if `value` is of a type whose constructions and assignment...
Ok, since assembly is one of the tags, I will just assume your code is pseudo code (and not necessarily c) and translate it by human into 6502 assembly. 1st Option (without else) ``` ldy #$00 lda #$05 dey bmi false lda #$06 false brk ``` 2nd Option (with else) ``` ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
**TL;DR:** In unoptimized code, `if` without `else` seems irrelevantly more efficient but with even the most basic level of optimization enabled the code is basically rewritten to `value = condition + 5`. --- I [gave it a try](https://gcc.godbolt.org/) and generated the assembly for the following code: ``` int ifonl...
What would make you think any of them even the one liner is faster or slower? ``` unsigned int fun0 ( unsigned int condition, unsigned int value ) { value = 5; if (condition) { value = 6; } return(value); } unsigned int fun1 ( unsigned int condition, unsigned int value ) { if (condition) ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
In unoptimised code, the first example assigns a variable always once and sometimes twice. The second example only ever assigns a variable once. The conditional is the same on both code paths, so that shouldn't matter. In optimised code, it depends on the compiler. As always, if you are that concerned, generate the as...
Ok, since assembly is one of the tags, I will just assume your code is pseudo code (and not necessarily c) and translate it by human into 6502 assembly. 1st Option (without else) ``` ldy #$00 lda #$05 dey bmi false lda #$06 false brk ``` 2nd Option (with else) ``` ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
The answer from [CompuChip](https://stackoverflow.com/a/43202221/2805305) shows that for `int` they both are optimized to the same assembly, so it doesn't matter. > > What if value is a matrix ? > > > I will interpret this in a more general way, i.e. what if `value` is of a type whose constructions and assignment...
In pseudo-assembly language, ```none li #0, r0 test r1 beq L1 li #1, r0 L1: ``` *may or may not* be faster than ```none test r1 beq L1 li #1, r0 bra L2 L1: li #0, r0 L2: ``` depending on how sophisticated the actual CPU is. Going from simplest to fanciest: ...
43,202,012
I argued with a friend the other day about those two snippets. Which is faster and why ? ``` value = 5; if (condition) { value = 6; } ``` and: ``` if (condition) { value = 6; } else { value = 5; } ``` What if `value` is a matrix ? Note: I know that `value = condition ? 6 : 5;` exists and I expect it ...
2017/04/04
[ "https://Stackoverflow.com/questions/43202012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3439945/" ]
**TL;DR:** In unoptimized code, `if` without `else` seems irrelevantly more efficient but with even the most basic level of optimization enabled the code is basically rewritten to `value = condition + 5`. --- I [gave it a try](https://gcc.godbolt.org/) and generated the assembly for the following code: ``` int ifonl...
In pseudo-assembly language, ```none li #0, r0 test r1 beq L1 li #1, r0 L1: ``` *may or may not* be faster than ```none test r1 beq L1 li #1, r0 bra L2 L1: li #0, r0 L2: ``` depending on how sophisticated the actual CPU is. Going from simplest to fanciest: ...
155,428
Our Wordpress website was hacked. I couldn't find anything intelligible from my limited experience from the limited logs my hosting gives. However, browsing in the FTP files I found a post.php file in the root and two more themes. Nothing strange in the DB, nor a new user. In the index I found the string "Silence is go...
2017/03/31
[ "https://security.stackexchange.com/questions/155428", "https://security.stackexchange.com", "https://security.stackexchange.com/users/143619/" ]
the entry points for attacker can include: outdated - PHP, themes, plugins, weak passwords, misconfigured php.ini file that can lead to issues. Please check if any of these have been overlooked.
The best practise to put in place is to ensure that your wordpress and its plugins are updated at a regular interval , i prefer to check for update every 10 days. Given the scenario there do not seem to be any APPgini based exploits available publically and my guess would be a vulnerability in the plugins that might ha...
155,428
Our Wordpress website was hacked. I couldn't find anything intelligible from my limited experience from the limited logs my hosting gives. However, browsing in the FTP files I found a post.php file in the root and two more themes. Nothing strange in the DB, nor a new user. In the index I found the string "Silence is go...
2017/03/31
[ "https://security.stackexchange.com/questions/155428", "https://security.stackexchange.com", "https://security.stackexchange.com/users/143619/" ]
the entry points for attacker can include: outdated - PHP, themes, plugins, weak passwords, misconfigured php.ini file that can lead to issues. Please check if any of these have been overlooked.
found the complete Log in another Post of you. Here is what I read from it: The GET Request for the Files wp-login.php from 91.210.145.98 (Windows 10 64Bit, with probably Mozilla Firefox 50) is 200 200 = HTTP Statuscode = OK which means successfull. The POST of the Login Data was successfull. (A interesting thing i...
155,428
Our Wordpress website was hacked. I couldn't find anything intelligible from my limited experience from the limited logs my hosting gives. However, browsing in the FTP files I found a post.php file in the root and two more themes. Nothing strange in the DB, nor a new user. In the index I found the string "Silence is go...
2017/03/31
[ "https://security.stackexchange.com/questions/155428", "https://security.stackexchange.com", "https://security.stackexchange.com/users/143619/" ]
Sure, if there is a PHP script which allows code execution - eg via command injection, file upload, etc - on the same server then an attacker can use that to gain access to the WordPress installation. The same is true for directory traversal vulnerabilities. (Assuming that you do not take any measure to separate differ...
The best practise to put in place is to ensure that your wordpress and its plugins are updated at a regular interval , i prefer to check for update every 10 days. Given the scenario there do not seem to be any APPgini based exploits available publically and my guess would be a vulnerability in the plugins that might ha...
155,428
Our Wordpress website was hacked. I couldn't find anything intelligible from my limited experience from the limited logs my hosting gives. However, browsing in the FTP files I found a post.php file in the root and two more themes. Nothing strange in the DB, nor a new user. In the index I found the string "Silence is go...
2017/03/31
[ "https://security.stackexchange.com/questions/155428", "https://security.stackexchange.com", "https://security.stackexchange.com/users/143619/" ]
Sure, if there is a PHP script which allows code execution - eg via command injection, file upload, etc - on the same server then an attacker can use that to gain access to the WordPress installation. The same is true for directory traversal vulnerabilities. (Assuming that you do not take any measure to separate differ...
found the complete Log in another Post of you. Here is what I read from it: The GET Request for the Files wp-login.php from 91.210.145.98 (Windows 10 64Bit, with probably Mozilla Firefox 50) is 200 200 = HTTP Statuscode = OK which means successfull. The POST of the Login Data was successfull. (A interesting thing i...
6,662,087
I'm making an flight search app with Sencha Touch and have encountered a small problem. I want to create a textfield for all the airports and need autocomplete functionality for in order to make it easy for the user to choose departure airport and return airport. How can i implement this? The airports will be loaded ...
2011/07/12
[ "https://Stackoverflow.com/questions/6662087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618162/" ]
Since there were no custom components out there and I needed something like this myself as well, I smashed it together. So, here it is. **Sencha Touch 2 Autocomplete Textfield component:** <https://github.com/martintajur/sencha-touch-2-autocomplete-textfield> It currently uses AJAX request response for populating the...
I think you should use a searchfield instead of textfield as suggested by @Ismailp, Then you should create a popup(a panel) in its keyup event, which should contain a list of Airports. Go through the hidden folder list-search in the example folder in downloaded sencha framework.It shows how to search through a list.
5,209,031
I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.) One class looks like the programmer was trying to get around c's lack of dynamic typing: ``` class Item{ private: enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_A...
2011/03/06
[ "https://Stackoverflow.com/questions/5209031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/360886/" ]
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like ...
Order of n means you traverse the string only once or some lesser multiple of n ,where n is number of characters in the string. So your solution to store the String and number of its occurences is O(n) , order of n, as you loop through the complete string only once. However it uses extra space in form of the list you c...
5,209,031
I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.) One class looks like the programmer was trying to get around c's lack of dynamic typing: ``` class Item{ private: enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_A...
2011/03/06
[ "https://Stackoverflow.com/questions/5209031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/360886/" ]
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like ...
Order N refers to the Big O computational complexity analysis where you get a good upper bound on algorithms. It is a theory we cover early in a Data Structures class, so we can torment, I mean help the student gain facility with it as we traverse in a balanced way, heaps of different trees of knowledge, all different....
5,209,031
I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.) One class looks like the programmer was trying to get around c's lack of dynamic typing: ``` class Item{ private: enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_A...
2011/03/06
[ "https://Stackoverflow.com/questions/5209031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/360886/" ]
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like ...
It's a reference to [Big O notation](https://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o). Basically the interviewer means that you have to complete the task with an O(N) algorithm.
5,209,031
I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.) One class looks like the programmer was trying to get around c's lack of dynamic typing: ``` class Item{ private: enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_A...
2011/03/06
[ "https://Stackoverflow.com/questions/5209031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/360886/" ]
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like ...
"Order n" is referring to [Big O notation](http://en.wikipedia.org/wiki/Big_O_notation). Big O is a way for mathematicians and computer scientists to describe the behavior of a function. When someone specifies searching a string "in order n", that means that the time it takes for the function to execute grows linearly ...
5,209,031
I'm trying to make a C++ library available as a Python module. It seems SIP is the best tool for the job. (If wrong, please correct me.) One class looks like the programmer was trying to get around c's lack of dynamic typing: ``` class Item{ private: enum ITEMTYPE{TYPE_INT,TYPE_FLOAT,TYPE_INT_ARRAY,TYPE_FLOAT_A...
2011/03/06
[ "https://Stackoverflow.com/questions/5209031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/360886/" ]
There are 26 characters, So you can use [`counting sort`](http://en.wikipedia.org/wiki/Counting_sort) to sort them, in your counting sort you can have an index which determines when specific character visited first time to save order of occurrence. [They can be sorted by their count and their occurrence with sort like ...
One possible method is to traverse the string linearly. Then create a hash and list. The idea is to use the word as the hash key and increment the value for each occurance. If the value is non-existent in the hash, add the word to the end of the list. After traversing the string, go through the list in order using the ...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
This substitute command should do it: ``` :%s#\($\n\s*\)\+\%$## ``` Note that this removes all trailing lines that contain only whitespace. To remove only truly "empty" lines, remove the `\s*` from the above command. **EDIT** Explanation: * `\(` ..... Start a match group * `$\n` ... Match a new line (end-of-line ...
I found the previous answers using substitute caused trouble when operating on very large files and polluted my registers. Here's a function I came up with which performs better for me, and avoids polluting registers: ``` " Strip trailing empty newlines function TrimTrailingLines() let lastLine = line('$') let las...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
You can put this into your vimrc ``` au BufWritePre *.txt $put _ | $;?\(^\s*$\)\@!?+1,$d ``` (replace `*.txt` with whatever globbing pattern you want) Detail: * `BufWritePre` is the event before writing a buffer to a file. * `$put _` appends a blank line at file end (from the always-empty register) * `|` chains Ex...
Inspired by solution from @Prince Goulash, add the following to your `~/.vimrc` to remove trailing blank lines for every save for Ruby and Python files: ``` autocmd FileType ruby,python autocmd BufWritePre <buffer> :%s/\($\n\s*\)\+\%$//e ```
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
This substitute command should do it: ``` :%s#\($\n\s*\)\+\%$## ``` Note that this removes all trailing lines that contain only whitespace. To remove only truly "empty" lines, remove the `\s*` from the above command. **EDIT** Explanation: * `\(` ..... Start a match group * `$\n` ... Match a new line (end-of-line ...
I have a separated function called *Preserve* which I can call from other functions, It makes easy to use Preserve to do other stuff: ``` " remove consecutive blank lines " see Preserve function definition " another way to remove blank lines :g/^$/,/./-j " Reference: https://stackoverflow.com/a/7496112/2571881 if !exi...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
**1.** An elegant solution can be based on the `:vglobal` command (or, which is the same thing, on the `:global` with `!` modifier): ``` :v/\_s*\S/d ``` This command executes `:delete` on every line that does not have non-whitespace characters in it, as well as after it in the remaining text to the end of buffer (se...
You can put this into your vimrc ``` au BufWritePre *.txt $put _ | $;?\(^\s*$\)\@!?+1,$d ``` (replace `*.txt` with whatever globbing pattern you want) Detail: * `BufWritePre` is the event before writing a buffer to a file. * `$put _` appends a blank line at file end (from the always-empty register) * `|` chains Ex...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
**1.** An elegant solution can be based on the `:vglobal` command (or, which is the same thing, on the `:global` with `!` modifier): ``` :v/\_s*\S/d ``` This command executes `:delete` on every line that does not have non-whitespace characters in it, as well as after it in the remaining text to the end of buffer (se...
I have a separated function called *Preserve* which I can call from other functions, It makes easy to use Preserve to do other stuff: ``` " remove consecutive blank lines " see Preserve function definition " another way to remove blank lines :g/^$/,/./-j " Reference: https://stackoverflow.com/a/7496112/2571881 if !exi...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
**1.** An elegant solution can be based on the `:vglobal` command (or, which is the same thing, on the `:global` with `!` modifier): ``` :v/\_s*\S/d ``` This command executes `:delete` on every line that does not have non-whitespace characters in it, as well as after it in the remaining text to the end of buffer (se...
Inspired by solution from @Prince Goulash, add the following to your `~/.vimrc` to remove trailing blank lines for every save for Ruby and Python files: ``` autocmd FileType ruby,python autocmd BufWritePre <buffer> :%s/\($\n\s*\)\+\%$//e ```
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
**1.** An elegant solution can be based on the `:vglobal` command (or, which is the same thing, on the `:global` with `!` modifier): ``` :v/\_s*\S/d ``` This command executes `:delete` on every line that does not have non-whitespace characters in it, as well as after it in the remaining text to the end of buffer (se...
I found the previous answers using substitute caused trouble when operating on very large files and polluted my registers. Here's a function I came up with which performs better for me, and avoids polluting registers: ``` " Strip trailing empty newlines function TrimTrailingLines() let lastLine = line('$') let las...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
You can put this into your vimrc ``` au BufWritePre *.txt $put _ | $;?\(^\s*$\)\@!?+1,$d ``` (replace `*.txt` with whatever globbing pattern you want) Detail: * `BufWritePre` is the event before writing a buffer to a file. * `$put _` appends a blank line at file end (from the always-empty register) * `|` chains Ex...
I have a separated function called *Preserve* which I can call from other functions, It makes easy to use Preserve to do other stuff: ``` " remove consecutive blank lines " see Preserve function definition " another way to remove blank lines :g/^$/,/./-j " Reference: https://stackoverflow.com/a/7496112/2571881 if !exi...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
This substitute command should do it: ``` :%s#\($\n\s*\)\+\%$## ``` Note that this removes all trailing lines that contain only whitespace. To remove only truly "empty" lines, remove the `\s*` from the above command. **EDIT** Explanation: * `\(` ..... Start a match group * `$\n` ... Match a new line (end-of-line ...
**1.** An elegant solution can be based on the `:vglobal` command (or, which is the same thing, on the `:global` with `!` modifier): ``` :v/\_s*\S/d ``` This command executes `:delete` on every line that does not have non-whitespace characters in it, as well as after it in the remaining text to the end of buffer (se...
7,495,932
Sometimes I accidentally leave blank lines at the end of the file I am editing. How can I trim them on saving in Vim? ### Update Thanks guys, all solutions seem to work. Unfortunately, they all reset current cursor position, so I wrote the following function. ``` function TrimEndLines() let save_cursor = g...
2011/09/21
[ "https://Stackoverflow.com/questions/7495932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/423585/" ]
This substitute command should do it: ``` :%s#\($\n\s*\)\+\%$## ``` Note that this removes all trailing lines that contain only whitespace. To remove only truly "empty" lines, remove the `\s*` from the above command. **EDIT** Explanation: * `\(` ..... Start a match group * `$\n` ... Match a new line (end-of-line ...
You can put this into your vimrc ``` au BufWritePre *.txt $put _ | $;?\(^\s*$\)\@!?+1,$d ``` (replace `*.txt` with whatever globbing pattern you want) Detail: * `BufWritePre` is the event before writing a buffer to a file. * `$put _` appends a blank line at file end (from the always-empty register) * `|` chains Ex...
2,893,751
Here's a problem from Cohn's *Measure Theory*. > > [Cohn, 2.1.3] Let $f$ and $g$ be continuous real-valued functions on $\mathbb{R}$. Show that if $f =g$ for $\lambda$-almost every $x$, then $f = g$ everywhere. > > > Here $\lambda$ denotes Lebesgue measure. Here's what I do. Let $h: \mathbb{R} \to \mathbb{R...
2018/08/25
[ "https://math.stackexchange.com/questions/2893751", "https://math.stackexchange.com", "https://math.stackexchange.com/users/503984/" ]
I would say that $\{x:h(x)\ne0\}$ is an open set in $\Bbb R$. (Since it is the inverse image of the open set $\Bbb R\setminus\{0\}$ under the continuous function $h$). Each nonempty open set contains a nonempty open interval, which has positive Lebesgue measure. So if $h$ is continuous, and not identically zero, then i...
(For completeness, following Lord Shark the Unknown's advice.) Let $h: \mathbb{R} \to \mathbb{R}$ be a continuous function. Suppose that $h \neq 0$. Thus, the set $\{h \neq 0\}$ is nonempty and open, and hence has positive Lebesgue measure. Taking the contrapositive, if $h$ is a continuous real-valued function on $\ma...
123,917
I've been trying to train a model that predicts an individual's survival time. My training set is an unbalanced panel; it has multiple observations per individual and thus time varying covariates. Every individual is observed from start to finish so no censoring. As a test, I used a plain random forest regression (no...
2014/11/13
[ "https://stats.stackexchange.com/questions/123917", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/32018/" ]
Although there is structure to your data, it may be that the variation in baseline risk does not vary substantially enough among your subjects to cause a model without a frailty term to form poor predictions. Of course, it's perfectly possible that a model with a frailty term would perform better than the pooled random...
I am just starting to work with Random Forest but I believe it is mainly the bagging that needs to be iid for each tree and the subset of features selection at each node. I am unaware of any formal constraints on the data itself. Why it works so well on your data I can not say until I have investigated your data. But ...
37,252,793
I have the following ARM assembly code: ``` mov r0, SP mov r1, LR bl func ``` Is there a way of calling the function func using C code? something like `func(SP, LR)` Thanks!
2016/05/16
[ "https://Stackoverflow.com/questions/37252793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6340494/" ]
Depends on what exactly you want to do and what compiler you use. With `gcc` something like this could work: ``` extern void func(void*, void*); void foo() { int dummy[4]; func(&dummy, __builtin_return_address(0)); } ``` This might not always give you the exact stack pointer, though. As per [godbolt](https:/...
Use output registers to place `LR` and `SP` in variables: ``` void *lr, *sp; asm ("mov %0, sp" : "=r" (sp)); asm ("mov %0, lr" : "=r" (lr)); func(lr, sp); ```
18,786
> > **मानुष्यं च समासाद्य स्वर्गमोक्षप्रसाधनम्।** > > **नाचरत्यात्मनः श्रेयः स मृतः शोचते चिरम्॥३०॥** > > > The human body is the means for achieving of the heaven and moksa and even after achieving the same, he does not do good to himself. After death he keeps on thinking for a long time. > > > > > > I...
2017/06/09
[ "https://hinduism.stackexchange.com/questions/18786", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/-1/" ]
We all live in Mrityu Lok or Karma Lok. It is called karma lok because we do Karma in this world/lok and get karma phal in return. Whatever deeds we do, we will surely get Karma phal of that deed in return. The grief or joy we experience in life is nothing but result of our karma referred as karma phal. If we do good ...
Everything and everyone is Brahman. When you harm others you are harming yourself. There are people in this world who bring great pains to animal and human life, ie they destroy themselves according to karmic laws. just like an alcoholic do not understand at the time that he is destroying his liver, the evil doer does...
18,786
> > **मानुष्यं च समासाद्य स्वर्गमोक्षप्रसाधनम्।** > > **नाचरत्यात्मनः श्रेयः स मृतः शोचते चिरम्॥३०॥** > > > The human body is the means for achieving of the heaven and moksa and even after achieving the same, he does not do good to himself. After death he keeps on thinking for a long time. > > > > > > I...
2017/06/09
[ "https://hinduism.stackexchange.com/questions/18786", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/-1/" ]
Human birth is result of accumulation in Manas of a Jeeva. After death, the impressions on Manas if are in resonance with human birth, the Jeeva will appear in human womb. From Chapter 1 of Shiv Rahasya, we find. > > 62. Verily from lack of Awareness, there arises Self-forgetfulness. From that springs wrong knowledg...
Everything and everyone is Brahman. When you harm others you are harming yourself. There are people in this world who bring great pains to animal and human life, ie they destroy themselves according to karmic laws. just like an alcoholic do not understand at the time that he is destroying his liver, the evil doer does...
18,786
> > **मानुष्यं च समासाद्य स्वर्गमोक्षप्रसाधनम्।** > > **नाचरत्यात्मनः श्रेयः स मृतः शोचते चिरम्॥३०॥** > > > The human body is the means for achieving of the heaven and moksa and even after achieving the same, he does not do good to himself. After death he keeps on thinking for a long time. > > > > > > I...
2017/06/09
[ "https://hinduism.stackexchange.com/questions/18786", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/-1/" ]
Well, we do bad karmas & we face the consequences, we do good karmas & we reap the benefits. So, why are you bringing in God into all this? The diseases from which we suffer in our lifetime are nothing but signs of our bad karmas or crimes done in our previous lives. This has been explicitly stated in many scriptures....
Everything and everyone is Brahman. When you harm others you are harming yourself. There are people in this world who bring great pains to animal and human life, ie they destroy themselves according to karmic laws. just like an alcoholic do not understand at the time that he is destroying his liver, the evil doer does...
71,996,211
I'm only learning Java and Spring and after several projects/tutorials went well I'm stuck with this error on a new project: > > org.springframework.beans.factory.BeanCreationException: Error > creating bean with name 'entityManagerFactory' defined in class path > resource > [org/springframework/boot/autoconfigure/or...
2022/04/25
[ "https://Stackoverflow.com/questions/71996211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13447185/" ]
So to fetch all the unused docker images without actually pruning them, you could do the following 1. Fetch all the images belonging to the running containers(which are not stopped or exited) 2. Fetch all the images on the machine 3. Then filter the images in step 1 from step 2 Below are the shell commands ``` runni...
you can use this command to show all of images: ``` docker images -a ``` You can find unused images using the command: ``` docker images -f dangling=true ``` and just a list of their IDs: ``` docker images -q -f dangling=true ``` In case you want to delete them: ``` docker rmi $(docker images -q -f dangling=t...
3,220,890
`DataServiceRequestException` was unhandled by user code. An error occurred while processing this request. This is in relation to the previous post I added ``` public void AddEmailAddress(EmailAddressEntity emailAddressTobeAdded) { AddObject("EmailAddress", emailAddressTobeAdded); SaveChanges(); } ``` Agai...
2010/07/10
[ "https://Stackoverflow.com/questions/3220890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/388592/" ]
I was looking into implementing something like this a few month ago. Since GWT compiles your code to JavaScript there is no way for you to do that on the client side, JavaScript can't access the file system. So you would need to upload the file to the server first and do the conversion on the server side and send...
GWT is mostly a client side toolkit. Are you trying to make a tool that does all the conversion on the client side, with no help from the server? In that case, you should be looking for JavaScript libraries that can read/convert all those formats. If you are planning to have the user upload their files to the server, t...
3,220,890
`DataServiceRequestException` was unhandled by user code. An error occurred while processing this request. This is in relation to the previous post I added ``` public void AddEmailAddress(EmailAddressEntity emailAddressTobeAdded) { AddObject("EmailAddress", emailAddressTobeAdded); SaveChanges(); } ``` Agai...
2010/07/10
[ "https://Stackoverflow.com/questions/3220890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/388592/" ]
It sounds like JOD Converter is precisely what you need since you're looking at multi format conversions from Java. You would install OpenOffice on your server and link it up with JOD Converter. When a document is uploaded, your application would call JOD Converter to perform the conversion and stream the converted doc...
GWT is mostly a client side toolkit. Are you trying to make a tool that does all the conversion on the client side, with no help from the server? In that case, you should be looking for JavaScript libraries that can read/convert all those formats. If you are planning to have the user upload their files to the server, t...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
If you are not bound to [`expl3`](https://www.ctan.org/pkg/expl3) (in which case you “just” need to implement the algorithm): ``` \documentclass{scrartcl} \usepackage{xintgcd,xintfrac} \newcommand*\reducedfrac[2] {\begingroup \edef\gcd{\xintGCD{#1}{#2}}% \frac{\xintNum{\xintDiv{#1}{\gcd}}}{\xintNum{\xintD...
There's already another LuaTeX answer, but IMO it doesn't handle properly with locality and integer division. So here, and taking advantage of the fact Lua 5.3+ [includes bitwise operators](https://www.lua.org/manual/5.3/manual.html#3.4.2), a different approach using a [binary GCD algorithm](https://xlinux.nist.gov/dad...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
An [`expl3`](https://ctan.org/pkg/expl3) implementation: ``` \nonstopmode \input expl3-generic \relax \ExplSyntaxOn % -*- expl3 -*- \cs_new:Nn \svend_gcd:nn { \int_compare:nNnTF {#2} = { 0 } {#1} { \svend_gcd:ff {#2} { \int_mod:nn {#1} {#2} } } } \cs_generate_variant:Nn \svend_gcd:nn { ff } \int_new:N ...
There's already another LuaTeX answer, but IMO it doesn't handle properly with locality and integer division. So here, and taking advantage of the fact Lua 5.3+ [includes bitwise operators](https://www.lua.org/manual/5.3/manual.html#3.4.2), a different approach using a [binary GCD algorithm](https://xlinux.nist.gov/dad...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
If you are not bound to [`expl3`](https://www.ctan.org/pkg/expl3) (in which case you “just” need to implement the algorithm): ``` \documentclass{scrartcl} \usepackage{xintgcd,xintfrac} \newcommand*\reducedfrac[2] {\begingroup \edef\gcd{\xintGCD{#1}{#2}}% \frac{\xintNum{\xintDiv{#1}{\gcd}}}{\xintNum{\xintD...
Here is a solution using **R** for the computations and the R-package `knitr` to link back to the LaTeX file. ``` \documentclass{article} \begin{document} Using R with the package 'knitr' to reduce the fraction and then get both the reduced fraction but also the components of the fraction. Note: This is a quick de...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
Here is a flat LaTeX2e implementation. ``` \documentclass{article} \usepackage{amsmath} \newcount{\numerator} \newcount{\denominator} \newcount{\gcd} % compute \gcd and returns reduced \numerator and \denominator \newcommand{\reduce}[2]% #1=numerator, #2=denominator {\numerator=#1\relax \denominator=#2\relax \loop...
There's already another LuaTeX answer, but IMO it doesn't handle properly with locality and integer division. So here, and taking advantage of the fact Lua 5.3+ [includes bitwise operators](https://www.lua.org/manual/5.3/manual.html#3.4.2), a different approach using a [binary GCD algorithm](https://xlinux.nist.gov/dad...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
If you are not bound to [`expl3`](https://www.ctan.org/pkg/expl3) (in which case you “just” need to implement the algorithm): ``` \documentclass{scrartcl} \usepackage{xintgcd,xintfrac} \newcommand*\reducedfrac[2] {\begingroup \edef\gcd{\xintGCD{#1}{#2}}% \frac{\xintNum{\xintDiv{#1}{\gcd}}}{\xintNum{\xintD...
If you are an Emacs user, just call Calc embedded (C-x \* e) while the point is on ``` \[ \frac{278922}{74088} \] ``` and the expression is transformed to ``` \[ \frac{6641}{1764} \] ``` `C-x \* e' a second time to come back to latex-mode. Similarly Emacs Calc can perform reduction for rational fractions, for e...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
Here is a flat LaTeX2e implementation. ``` \documentclass{article} \usepackage{amsmath} \newcount{\numerator} \newcount{\denominator} \newcount{\gcd} % compute \gcd and returns reduced \numerator and \denominator \newcommand{\reduce}[2]% #1=numerator, #2=denominator {\numerator=#1\relax \denominator=#2\relax \loop...
If you are an Emacs user, just call Calc embedded (C-x \* e) while the point is on ``` \[ \frac{278922}{74088} \] ``` and the expression is transformed to ``` \[ \frac{6641}{1764} \] ``` `C-x \* e' a second time to come back to latex-mode. Similarly Emacs Calc can perform reduction for rational fractions, for e...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
An option using Lua+LaTeX. Made small improvement. Made a Lua function to be called as a LaTeX command, with the numerator and denominator passed as arguments, instead of hardcoding the values in as before. The command is `\simplify{a}{b}`: ``` \documentclass{article} \usepackage{luacode} \usepackage{amsmath} %--...
There's already another LuaTeX answer, but IMO it doesn't handle properly with locality and integer division. So here, and taking advantage of the fact Lua 5.3+ [includes bitwise operators](https://www.lua.org/manual/5.3/manual.html#3.4.2), a different approach using a [binary GCD algorithm](https://xlinux.nist.gov/dad...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
Here is a solution using **R** for the computations and the R-package `knitr` to link back to the LaTeX file. ``` \documentclass{article} \begin{document} Using R with the package 'knitr' to reduce the fraction and then get both the reduced fraction but also the components of the fraction. Note: This is a quick de...
There's already another LuaTeX answer, but IMO it doesn't handle properly with locality and integer division. So here, and taking advantage of the fact Lua 5.3+ [includes bitwise operators](https://www.lua.org/manual/5.3/manual.html#3.4.2), a different approach using a [binary GCD algorithm](https://xlinux.nist.gov/dad...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
An [`expl3`](https://ctan.org/pkg/expl3) implementation: ``` \nonstopmode \input expl3-generic \relax \ExplSyntaxOn % -*- expl3 -*- \cs_new:Nn \svend_gcd:nn { \int_compare:nNnTF {#2} = { 0 } {#1} { \svend_gcd:ff {#2} { \int_mod:nn {#1} {#2} } } } \cs_generate_variant:Nn \svend_gcd:nn { ff } \int_new:N ...
Here is a solution using **R** for the computations and the R-package `knitr` to link back to the LaTeX file. ``` \documentclass{article} \begin{document} Using R with the package 'knitr' to reduce the fraction and then get both the reduced fraction but also the components of the fraction. Note: This is a quick de...
253,693
Consider the following code: ``` \documentclass{article} \begin{document} \noindent Can I make \LaTeX{} reduce a fraction automatically?\\[\baselineskip] For example, I would like the fraction \[ \frac{278\,922}{74\,088} \] to be reduced to \[ \frac{6641}{1764} \] \end{document} ``` ![output](https://i.stack.imgu...
2015/07/04
[ "https://tex.stackexchange.com/questions/253693", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/15874/" ]
An [`expl3`](https://ctan.org/pkg/expl3) implementation: ``` \nonstopmode \input expl3-generic \relax \ExplSyntaxOn % -*- expl3 -*- \cs_new:Nn \svend_gcd:nn { \int_compare:nNnTF {#2} = { 0 } {#1} { \svend_gcd:ff {#2} { \int_mod:nn {#1} {#2} } } } \cs_generate_variant:Nn \svend_gcd:nn { ff } \int_new:N ...
Here is a flat LaTeX2e implementation. ``` \documentclass{article} \usepackage{amsmath} \newcount{\numerator} \newcount{\denominator} \newcount{\gcd} % compute \gcd and returns reduced \numerator and \denominator \newcommand{\reduce}[2]% #1=numerator, #2=denominator {\numerator=#1\relax \denominator=#2\relax \loop...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Im geschriebenen Deutsch würde ich immer eher eine Formulierung im Passiv erwarten, die ohne Pronomen auskommt: > > * Wenn das so ist, *wird* keine Regierung mehr *gebraucht*. (*benötigt*) > * *Wird* die EU noch *gebraucht*? (*benötigt*) > * In dieser Region *wird* dringend mehr Regen *gebraucht*. (*benötigt*) > > ...
Als jemand aus dem (Süd-) Westen Bayerns, kurz vor der Sprachgrenze zum Schwäbischen, kommt mir *es braucht* überhaupt nicht seltsam vor. Ich bin allerdings auch noch relativ jung, kann also nicht sagen, inwiefern es sich um eine neuartige Entwicklung handelt. In einem Kommentar hat TvF schön den Unterschied zwischen ...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Im geschriebenen Deutsch würde ich immer eher eine Formulierung im Passiv erwarten, die ohne Pronomen auskommt: > > * Wenn das so ist, *wird* keine Regierung mehr *gebraucht*. (*benötigt*) > * *Wird* die EU noch *gebraucht*? (*benötigt*) > * In dieser Region *wird* dringend mehr Regen *gebraucht*. (*benötigt*) > > ...
Komme aus Südbaden, nahe der Grenze zur Schweiz. Für mich ist "es braucht" ganz natürlich. Bin noch jünger, kann daher zur Historie nicht so viel beitragen. Mir schwätzet hier alemannische Dialekt (alemannisch bezeichnet nicht nur den Dialekt in Südbaden, sondern ist auch der Oberbegriff für Schweizerdeutsch, Schwäbisc...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Es scheit so, also ob diese Formulierung im südlichen und südwestlichen Sprachraum schon seit langer Zeit verwendet würde: ``` Der Rhein, ist seitwärts Hinweggegangen. Umsonst nicht gehn Im Trocknen die Ströme. Aber wie? Ein Zeichen braucht es, Nichts anderes, schlecht und recht, damit es Sonn Und Mond trag im Gemü...
"Es braucht" war vor 20 Jahren in Österreich völlig ungebräuchlich, hat sich seither aber epidemieartig ausgebreitet. Meine Theorie ist, dass MAN im Zuge der Suche nach einer "geschlechtsneutralen" Alternative für das ach so maskuline "man" in den alemannischen Dialektraum geschielt hat, wo "es braucht" in seiner Verwa...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Im geschriebenen Deutsch würde ich immer eher eine Formulierung im Passiv erwarten, die ohne Pronomen auskommt: > > * Wenn das so ist, *wird* keine Regierung mehr *gebraucht*. (*benötigt*) > * *Wird* die EU noch *gebraucht*? (*benötigt*) > * In dieser Region *wird* dringend mehr Regen *gebraucht*. (*benötigt*) > > ...
Ich habe die Hälfte meines Lebens (66) an unterschiedlichen Orten in Deutschland gelebt, Süd wie Nord, auch nahe an der Grenze zur Schweiz und zu Österreich. "Es braucht" ist mir dort bis vor rund 15 bis 20 Jahren nicht begegnet. Auch nicht in den jeweiligen Mundarten. Meine Theorie ist, dass "es braucht" ein Anglizism...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Als jemand aus dem (Süd-) Westen Bayerns, kurz vor der Sprachgrenze zum Schwäbischen, kommt mir *es braucht* überhaupt nicht seltsam vor. Ich bin allerdings auch noch relativ jung, kann also nicht sagen, inwiefern es sich um eine neuartige Entwicklung handelt. In einem Kommentar hat TvF schön den Unterschied zwischen ...
Komme aus Südbaden, nahe der Grenze zur Schweiz. Für mich ist "es braucht" ganz natürlich. Bin noch jünger, kann daher zur Historie nicht so viel beitragen. Mir schwätzet hier alemannische Dialekt (alemannisch bezeichnet nicht nur den Dialekt in Südbaden, sondern ist auch der Oberbegriff für Schweizerdeutsch, Schwäbisc...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Im geschriebenen Deutsch würde ich immer eher eine Formulierung im Passiv erwarten, die ohne Pronomen auskommt: > > * Wenn das so ist, *wird* keine Regierung mehr *gebraucht*. (*benötigt*) > * *Wird* die EU noch *gebraucht*? (*benötigt*) > * In dieser Region *wird* dringend mehr Regen *gebraucht*. (*benötigt*) > > ...
Es scheit so, also ob diese Formulierung im südlichen und südwestlichen Sprachraum schon seit langer Zeit verwendet würde: ``` Der Rhein, ist seitwärts Hinweggegangen. Umsonst nicht gehn Im Trocknen die Ströme. Aber wie? Ein Zeichen braucht es, Nichts anderes, schlecht und recht, damit es Sonn Und Mond trag im Gemü...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Es scheit so, also ob diese Formulierung im südlichen und südwestlichen Sprachraum schon seit langer Zeit verwendet würde: ``` Der Rhein, ist seitwärts Hinweggegangen. Umsonst nicht gehn Im Trocknen die Ströme. Aber wie? Ein Zeichen braucht es, Nichts anderes, schlecht und recht, damit es Sonn Und Mond trag im Gemü...
Ich habe die Hälfte meines Lebens (66) an unterschiedlichen Orten in Deutschland gelebt, Süd wie Nord, auch nahe an der Grenze zur Schweiz und zu Österreich. "Es braucht" ist mir dort bis vor rund 15 bis 20 Jahren nicht begegnet. Auch nicht in den jeweiligen Mundarten. Meine Theorie ist, dass "es braucht" ein Anglizism...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Komme aus Südbaden, nahe der Grenze zur Schweiz. Für mich ist "es braucht" ganz natürlich. Bin noch jünger, kann daher zur Historie nicht so viel beitragen. Mir schwätzet hier alemannische Dialekt (alemannisch bezeichnet nicht nur den Dialekt in Südbaden, sondern ist auch der Oberbegriff für Schweizerdeutsch, Schwäbisc...
"Es braucht" war vor 20 Jahren in Österreich völlig ungebräuchlich, hat sich seither aber epidemieartig ausgebreitet. Meine Theorie ist, dass MAN im Zuge der Suche nach einer "geschlechtsneutralen" Alternative für das ach so maskuline "man" in den alemannischen Dialektraum geschielt hat, wo "es braucht" in seiner Verwa...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
"Es braucht" war vor 20 Jahren in Österreich völlig ungebräuchlich, hat sich seither aber epidemieartig ausgebreitet. Meine Theorie ist, dass MAN im Zuge der Suche nach einer "geschlechtsneutralen" Alternative für das ach so maskuline "man" in den alemannischen Dialektraum geschielt hat, wo "es braucht" in seiner Verwa...
Ich habe die Hälfte meines Lebens (66) an unterschiedlichen Orten in Deutschland gelebt, Süd wie Nord, auch nahe an der Grenze zur Schweiz und zu Österreich. "Es braucht" ist mir dort bis vor rund 15 bis 20 Jahren nicht begegnet. Auch nicht in den jeweiligen Mundarten. Meine Theorie ist, dass "es braucht" ein Anglizism...
34,520
In den letzten Wochen fällt mir immer öfter auf, dass in Sätzen, in denen früher »man braucht« gesagt wurde, seit neuestem »es braucht« verwendet wird. > > früher: »Wenn das so ist, dann braucht *man* keine Regierung mehr. > > heute: »Wenn das so ist, dann braucht *es* keine Regierung mehr. > > > (Soeben in ...
2017/01/25
[ "https://german.stackexchange.com/questions/34520", "https://german.stackexchange.com", "https://german.stackexchange.com/users/1487/" ]
Als jemand aus dem (Süd-) Westen Bayerns, kurz vor der Sprachgrenze zum Schwäbischen, kommt mir *es braucht* überhaupt nicht seltsam vor. Ich bin allerdings auch noch relativ jung, kann also nicht sagen, inwiefern es sich um eine neuartige Entwicklung handelt. In einem Kommentar hat TvF schön den Unterschied zwischen ...
Ich habe die Hälfte meines Lebens (66) an unterschiedlichen Orten in Deutschland gelebt, Süd wie Nord, auch nahe an der Grenze zur Schweiz und zu Österreich. "Es braucht" ist mir dort bis vor rund 15 bis 20 Jahren nicht begegnet. Auch nicht in den jeweiligen Mundarten. Meine Theorie ist, dass "es braucht" ein Anglizism...
55,275,032
I am new in PL/SQL for this reason sorry for easy question.I hope you will help me. My goal is add values to table with for loop.If you have a question please replay I will answer as soon as posible. This is my code which do not work. ``` declare cursor c_exam_info is select result1 from exam_info; begin for ...
2019/03/21
[ "https://Stackoverflow.com/questions/55275032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11075976/" ]
I can't view images. Anyway: `INSERT` seems to be inappropriate - wouldn't `UPDATE` be a better choice? Something like this: ``` begin for i IN (select id, result1 from exam_info) loop update exam_info set result_type = case when c_exam_info.result1 > 60 then 'pass' else '...
Given that the `result1` column appears to be completely computed data, I might even recommend here that you just use a view: ``` CREATE VIEW your_view AS ( SELECT t.*, CASE WHEN t.result1 > 60 THEN 'pass' ELSE 'fail' END AS result1 FROM exam_info t ) ``` Then, select from this view whenever you want...
38,680
I'm trying to find an efficient way to compute maximum of a signal using its DFT. More formally: $$\max\left\{ \mathcal F^{-1}\left(X\_k\right)\right\}, X\_k\text{ is the DFT of the signal and } \mathcal F^{-1} \text{ is the IDFT}$$ The original signal $x(n)$ is real, and it has some noise when sometimes there are wi...
2017/03/27
[ "https://dsp.stackexchange.com/questions/38680", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/25521/" ]
There is no way to compute the (exact) maximum of the time domain signal directly from its DFT (without doing an IDFT first). Without any further knowledge, the best you can do is $$|x[n]|=\left|\frac{1}{N}\sum\_{k=0}^{N-1}X[k]e^{j2\pi nk/N}\right|\le\frac{1}{N}\sum\_{k=0}^{N-1}|X[k]| $$ which gives you an upper boun...
Generally: There can be no shortcut here – every single element of the (inverse or forward, doesn't matter) DFT needs every element of the input. So, the FFT is already pretty much as fast as you can go. However, you say: > > The original signal $x(n)$ is real, and it has some noise when sometimes there are wide pe...
38,680
I'm trying to find an efficient way to compute maximum of a signal using its DFT. More formally: $$\max\left\{ \mathcal F^{-1}\left(X\_k\right)\right\}, X\_k\text{ is the DFT of the signal and } \mathcal F^{-1} \text{ is the IDFT}$$ The original signal $x(n)$ is real, and it has some noise when sometimes there are wi...
2017/03/27
[ "https://dsp.stackexchange.com/questions/38680", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/25521/" ]
This sounds like a good candidate for the Sparse Fast Fourier Transform (sFFT). Have a look at H. Hassanieh, P. Indyk, D. Katabi, and E. Price, **[sFFT: Sparse Fast Fourier Transform](http://groups.csail.mit.edu/netmit/sFFT/)**, 2012. I don't know details of the algorithm. You have the domains swapped, which should be ...
There is no way to compute the (exact) maximum of the time domain signal directly from its DFT (without doing an IDFT first). Without any further knowledge, the best you can do is $$|x[n]|=\left|\frac{1}{N}\sum\_{k=0}^{N-1}X[k]e^{j2\pi nk/N}\right|\le\frac{1}{N}\sum\_{k=0}^{N-1}|X[k]| $$ which gives you an upper boun...
38,680
I'm trying to find an efficient way to compute maximum of a signal using its DFT. More formally: $$\max\left\{ \mathcal F^{-1}\left(X\_k\right)\right\}, X\_k\text{ is the DFT of the signal and } \mathcal F^{-1} \text{ is the IDFT}$$ The original signal $x(n)$ is real, and it has some noise when sometimes there are wi...
2017/03/27
[ "https://dsp.stackexchange.com/questions/38680", "https://dsp.stackexchange.com", "https://dsp.stackexchange.com/users/25521/" ]
This sounds like a good candidate for the Sparse Fast Fourier Transform (sFFT). Have a look at H. Hassanieh, P. Indyk, D. Katabi, and E. Price, **[sFFT: Sparse Fast Fourier Transform](http://groups.csail.mit.edu/netmit/sFFT/)**, 2012. I don't know details of the algorithm. You have the domains swapped, which should be ...
Generally: There can be no shortcut here – every single element of the (inverse or forward, doesn't matter) DFT needs every element of the input. So, the FFT is already pretty much as fast as you can go. However, you say: > > The original signal $x(n)$ is real, and it has some noise when sometimes there are wide pe...
37,441,689
I am working on a simple app for Android. I am having some trouble using the Firebase database since it uses JSON objects and I am used to relational databases. My data will consists of two users that share a value. In relational databases this would be represented in a table like this: ``` **uname1** **uname2** sh...
2016/05/25
[ "https://Stackoverflow.com/questions/37441689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973615/" ]
Is there a reason why you don't invert this? How about a collection like: ``` { "_id": 2, "usernames":[ "Bob", "Alice"]} { "_id": 4, "usernames":[ "Bob", "Cece"]} ``` If you need all the values for "Bob", then index on "usernames". EDIT: If you need the two usernames to be a unique key, then do something like this...
To create a tree-like structure, the best way is to create an "ancestors" array that stores all the ancestors of a particular entry. That way you can query for either ancestors or descendants and all documents that are related to a particular value in the tree. Using your example, you would be able to search for all de...
37,441,689
I am working on a simple app for Android. I am having some trouble using the Firebase database since it uses JSON objects and I am used to relational databases. My data will consists of two users that share a value. In relational databases this would be represented in a table like this: ``` **uname1** **uname2** sh...
2016/05/25
[ "https://Stackoverflow.com/questions/37441689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973615/" ]
Is there a reason why you don't invert this? How about a collection like: ``` { "_id": 2, "usernames":[ "Bob", "Alice"]} { "_id": 4, "usernames":[ "Bob", "Cece"]} ``` If you need all the values for "Bob", then index on "usernames". EDIT: If you need the two usernames to be a unique key, then do something like this...
You can still have old structure: ``` [ { username: 'Bob', username2: 'Alice', value: 2 }, { username: 'Cece', username2: 'Bob', value: 4 }, ] ``` You may want to create indexes on 'username' and 'username2' for performance. And then just do the same union.
37,441,689
I am working on a simple app for Android. I am having some trouble using the Firebase database since it uses JSON objects and I am used to relational databases. My data will consists of two users that share a value. In relational databases this would be represented in a table like this: ``` **uname1** **uname2** sh...
2016/05/25
[ "https://Stackoverflow.com/questions/37441689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973615/" ]
You can still have old structure: ``` [ { username: 'Bob', username2: 'Alice', value: 2 }, { username: 'Cece', username2: 'Bob', value: 4 }, ] ``` You may want to create indexes on 'username' and 'username2' for performance. And then just do the same union.
To create a tree-like structure, the best way is to create an "ancestors" array that stores all the ancestors of a particular entry. That way you can query for either ancestors or descendants and all documents that are related to a particular value in the tree. Using your example, you would be able to search for all de...
21,272,847
I have got a terminal app that gets user input stores it in a string then converts it into a int. The problem is if the user inputs anything that is not a number the conversion fails and the script continues without any indication that the string has not converted. Is there a way to check of the string contains any non...
2014/01/22
[ "https://Stackoverflow.com/questions/21272847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2558108/" ]
You can find out if a read of an `int` has been successful or not by checking the `fail()` bit of your input stream: ``` getline (cin,mystr); //gets user input stringstream priceStream(mystr); priceStream >> price; if (priceStream.fail()) { cerr << "The price you have entered is not a valid number." << endl; } ``...
If your want to check if the price user inputs is a float, you can use `boost::lexical_cast<double>(mystr);`, if it throws an exception then your string is not a float.
21,272,847
I have got a terminal app that gets user input stores it in a string then converts it into a int. The problem is if the user inputs anything that is not a number the conversion fails and the script continues without any indication that the string has not converted. Is there a way to check of the string contains any non...
2014/01/22
[ "https://Stackoverflow.com/questions/21272847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2558108/" ]
You can find out if a read of an `int` has been successful or not by checking the `fail()` bit of your input stream: ``` getline (cin,mystr); //gets user input stringstream priceStream(mystr); priceStream >> price; if (priceStream.fail()) { cerr << "The price you have entered is not a valid number." << endl; } ``...
It's going to add a bit to your code, but you can parse mystr with isdigit from cctype. The library's functions are [here](http://www.cplusplus.com/reference/cctype/). isdigit(mystr[index]) will return a false if that character in the string isn't a number.
22,492,338
I am working on a Chrome extension that will add content to a particular set of pages. From my research, it sounds like what I want is a [content script](https://developer.chrome.com/extensions/content_scripts) that will execute for the appropriate pages. I can specify the "appropriate pages" using the `content_script....
2014/03/18
[ "https://Stackoverflow.com/questions/22492338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450668/" ]
By far the best choice is to rename the function parameter so it does not conflict with the global variable, so there is no need for circumventions. Assuming the rename option is not acceptable, use `::foo` to refer to `foo` at the global scope: ``` #include <iostream> int foo = 100; int bar(int foo) { int sum ...
Use `::foo` - but REALLY don't do that. It will confuse everyone, and you really shouldn't do those sort things. Instead, rename one or the other variable. It's a TERRIBLE idea to use the `::` prefix to solve this problem.
22,492,338
I am working on a Chrome extension that will add content to a particular set of pages. From my research, it sounds like what I want is a [content script](https://developer.chrome.com/extensions/content_scripts) that will execute for the appropriate pages. I can specify the "appropriate pages" using the `content_script....
2014/03/18
[ "https://Stackoverflow.com/questions/22492338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450668/" ]
Use `::foo` - but REALLY don't do that. It will confuse everyone, and you really shouldn't do those sort things. Instead, rename one or the other variable. It's a TERRIBLE idea to use the `::` prefix to solve this problem.
Best practice is to always name global variables with a leading lower case "g" as in gX gY. It is never clear what you should name your variables at the beginning though. ::foo . That's a cool trick.
22,492,338
I am working on a Chrome extension that will add content to a particular set of pages. From my research, it sounds like what I want is a [content script](https://developer.chrome.com/extensions/content_scripts) that will execute for the appropriate pages. I can specify the "appropriate pages" using the `content_script....
2014/03/18
[ "https://Stackoverflow.com/questions/22492338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450668/" ]
By far the best choice is to rename the function parameter so it does not conflict with the global variable, so there is no need for circumventions. Assuming the rename option is not acceptable, use `::foo` to refer to `foo` at the global scope: ``` #include <iostream> int foo = 100; int bar(int foo) { int sum ...
Best practice is to always name global variables with a leading lower case "g" as in gX gY. It is never clear what you should name your variables at the beginning though. ::foo . That's a cool trick.
31,306,027
I'm working on an FAQ type project using AngularJS. I have a number of questions and answers I need to import into the page and thought it would be a good idea to use a service/directive to load the content in dynamically from JSON. The text strings are quite unwieldily (639+ characters) and the overall hesitation I h...
2015/07/09
[ "https://Stackoverflow.com/questions/31306027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4933483/" ]
I replaced ``` var listeRef = from r in db.refAnomalies select r; ``` with ``` String sql = @"select * from refAnomalie"; List<refAnomalie> listeRefference = new List<refAnomalie>(); var con = new SqlConnection("data source=(LocalDb)\\MSSQLLocalDB;initial catalog=Banque;integra...
The error message is quite clear: EF evidently generates a query simliar to... ``` select ..., rapportAnomalie_code_rapport, ... from refAnomalie ``` ...and the error tells you that there is no `rapportAnomalie_code_rapport` column in `refAnomalie`. You need to take a look at the class that EF generates for `refAno...
31,306,027
I'm working on an FAQ type project using AngularJS. I have a number of questions and answers I need to import into the page and thought it would be a good idea to use a service/directive to load the content in dynamically from JSON. The text strings are quite unwieldily (639+ characters) and the overall hesitation I h...
2015/07/09
[ "https://Stackoverflow.com/questions/31306027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4933483/" ]
I replaced ``` var listeRef = from r in db.refAnomalies select r; ``` with ``` String sql = @"select * from refAnomalie"; List<refAnomalie> listeRefference = new List<refAnomalie>(); var con = new SqlConnection("data source=(LocalDb)\\MSSQLLocalDB;initial catalog=Banque;integra...
@Omar, Changing the complete approach is not the solution of the problem. The way I see this problem is you're having naming convention issue with Navigation properties. Which sometime confuses the EF and results in generating a "Guessed" column name which doesn't exist. I would recommend to thoroughly go through thi...
29,042,618
The app has a controller, that uses a service to create an instance of video player. The video player triggers events to show progress every few seconds. When the video reaches to a certain point, I want to show a widget on top of the video player. The view has the widget wrapped in ng-show directive. It takes more t...
2015/03/13
[ "https://Stackoverflow.com/questions/29042618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/979535/" ]
Solved it! $scope.$apply() did the trick. My guess is, due to other complex logic ad bindings inside the app, there was a delay in computing the change by angular the default way. @floribon Thanks for the subtle hint about "complex angular stuff". The code inside the service function changed to: ``` function showWi...
Do you have complex angular stuff within your hidden view? You should try to use `ng-if` instead of `ng-show`, the difference being that when the condition is false, `ng-if` will remove the element from the DOM instead of just hidding it (which is also what you do in vanilla JS). When the view is simply hidden using ...
19,291,746
I have a string: `{2013/05/01},{2013/05/02},{2013/05/03}` I want to append a { at the beginning and a } at the end. The output should be: `{{2013/05/01},{2013/05/02},{2013/05/03}}` However, in my shell script when I concatenate the curly braces to the beginning and end of the string, the output is as follows: `{20...
2013/10/10
[ "https://Stackoverflow.com/questions/19291746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2844037/" ]
The problem is that when you have a list in braces outside quotes, the shell performs [Brace Expansion](http://www.gnu.org/software/bash/manual/bash.html#Brace-Expansion) (`bash` manual, but [`ksh`](http://www2.research.att.com/sw/download/man/man1/ksh.html) will be similar). Since the 'outside quotes' bit is important...
You can say: ``` finalDates=$'{'"$valid_data_range"$'}' ```
19,291,746
I have a string: `{2013/05/01},{2013/05/02},{2013/05/03}` I want to append a { at the beginning and a } at the end. The output should be: `{{2013/05/01},{2013/05/02},{2013/05/03}}` However, in my shell script when I concatenate the curly braces to the beginning and end of the string, the output is as follows: `{20...
2013/10/10
[ "https://Stackoverflow.com/questions/19291746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2844037/" ]
The problem is that when you have a list in braces outside quotes, the shell performs [Brace Expansion](http://www.gnu.org/software/bash/manual/bash.html#Brace-Expansion) (`bash` manual, but [`ksh`](http://www2.research.att.com/sw/download/man/man1/ksh.html) will be similar). Since the 'outside quotes' bit is important...
The problem is that the shell is performing brace expansion. This allows you to generate a series of similar strings: ``` $ echo {a,b,c} a b c ``` That's not very impressive, but consider ``` $ echo a{b,c,d}e abc ace ade ``` In order to suppress brace expansion, you can use the `set` command to turn it off tempor...
7,056,634
I'd like to read and write window registry in **window xp and 7** by using **vb6**. I'm not much strong in vb6. I tried this below ``` Dim str As String str = GetSetting("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines", "Text", "ImportMixedTypes") ``` My coding doesn't work. Please point out my missing.
2011/08/14
[ "https://Stackoverflow.com/questions/7056634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305732/" ]
You can't use `GetSetting` for that setting. That method is only for reading/writing configuration settings for your own application. If you want to read anywhere in the registry you have to use the Windows API function [RegOpenKeyEx](http://msdn.microsoft.com/en-us/library/ms724897%28v=vs.85%29.aspx) and friends. Her...
HKEY\_LOCAL\_MACHINE can cause permission problems. described in these article [Microsoft API article](https://support.microsoft.com/ru-ru/kb/145679) procedures works well if you will change HKEY\_LOCAL\_MACHINE to CURRENT\_USER.
74,514,734
I want to fit parent div height to fit it's child that means I want height of parent div to fit red color and green part will hide <https://jsfiddle.net/zfpwb54L/> ``` <style> .container { margin-left: auto; margin-right: auto; padding-left: 15px; padding-right: 15px; width: 100%; } .section { padding: ...
2022/11/21
[ "https://Stackoverflow.com/questions/74514734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9779942/" ]
For testing your agent in a custom environment alter the endpoint URL to `https://dialogflow.googleapis.com/v2/projects/my-project-id/agent/environments/<env-name>/users/-/sessions/123456789:detectIntent` curl command: ``` curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-go...
Like [@SakshiGat](https://stackoverflow.com/users/15750473/sakshi-gatyan) mentioned, the curl URL was invalid. Invalid URL: "https://dialogflow.googleapis.com/v2/projects/<project\_name>/agent/environments/DEV/sessions/<session\_id>:detectIntent" Valid URL: "https://dialogflow.googleapis.com/v2/projects/**<project\_i...
20,365
I cannot open a SQLConnection to a SQL vectorwise database and I assume the JDBC driver is the problem. A JAR file was provided to me - the only info additionally provided to me was the java class: **com.ingres.jdbc.IngresDriver** What would I have to do to add it to the JDBCDrivers that Mathematica can use? Hope thi...
2013/02/27
[ "https://mathematica.stackexchange.com/questions/20365", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/5797/" ]
Finally found the answer on how to connect MM to Actian vectorwise via SQL :) ``` Needs["JLink`"] AddToClassPath["C:\\Users\\Desktop\\iijdbc.jar"]; Needs["DatabaseLink`"]; OpenSQLConnection[ JDBC["com.ingres.jdbc.IngresDriver", "jdbc:ingres://HOST:VW7/DATABASE;user=xxx;password=yyy"]] ``` Feeling good! Pat
In the case where you want to use an *updated* driver in preference to an older one shipped with Mathematica, `AddToClassPath[ ...path..., Prepend -> True]`. For instance to use xerial's up-to-date SQLite driver: ``` Needs["JLink`"]; Needs["DatabaseLink`"]; ReinstallJava[]; jdbcdriver = FindFile["my-path-to/sqlite-j...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
There is no point in doing this. IDs from deleted records are not re-used on purpose - to make sure that references from other tables to previously deleted records don't suddenly point to the *wrong* record, for example. It is not a good idea to try to change this. If you want a numbered list that has no holes, creat...
I'd advise against messing with your PKs unless you really have no choice, it can cause breakage all over the place when that id column is referred by other tables. If the PK really tolerates no gaps, maybe the choice of PK was not ideal... If you really think you should do this (and are sure nothing will break in ot...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Not sure about one command, but you can do it in four commands: ``` CREATE TABLE `temp` SELECT * FROM `orig_tbl`; TRUNCATE `orig_tbl`; -- counter doesn't reset in some old versions ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; -- now we omit primary key column to let it seal the holes INSERT INTO `orig_tbl` (`col1`, `co...
There is no point in doing this. IDs from deleted records are not re-used on purpose - to make sure that references from other tables to previously deleted records don't suddenly point to the *wrong* record, for example. It is not a good idea to try to change this. If you want a numbered list that has no holes, creat...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Try this: ``` SET @var:=0; UPDATE `table` SET `id`=(@var:=@var+1); ALTER TABLE `table` AUTO_INCREMENT=1; ```
There is no point in doing this. IDs from deleted records are not re-used on purpose - to make sure that references from other tables to previously deleted records don't suddenly point to the *wrong* record, for example. It is not a good idea to try to change this. If you want a numbered list that has no holes, creat...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
There is no point in doing this. IDs from deleted records are not re-used on purpose - to make sure that references from other tables to previously deleted records don't suddenly point to the *wrong* record, for example. It is not a good idea to try to change this. If you want a numbered list that has no holes, creat...
Another way, without truncating whole table: ``` -- Make Backup of original table's content CREATE TABLE `orig_tbl_backup` SELECT * FROM `orig_tbl`; -- Drop needed column. ALTER TABLE `orig_tbl` DROP `id`; -- Re-create it ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; ALTER TABLE `orig_tbl` ADD `id` int UNSIGNED NOT NULL...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Not sure about one command, but you can do it in four commands: ``` CREATE TABLE `temp` SELECT * FROM `orig_tbl`; TRUNCATE `orig_tbl`; -- counter doesn't reset in some old versions ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; -- now we omit primary key column to let it seal the holes INSERT INTO `orig_tbl` (`col1`, `co...
I'd advise against messing with your PKs unless you really have no choice, it can cause breakage all over the place when that id column is referred by other tables. If the PK really tolerates no gaps, maybe the choice of PK was not ideal... If you really think you should do this (and are sure nothing will break in ot...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Try this: ``` SET @var:=0; UPDATE `table` SET `id`=(@var:=@var+1); ALTER TABLE `table` AUTO_INCREMENT=1; ```
I'd advise against messing with your PKs unless you really have no choice, it can cause breakage all over the place when that id column is referred by other tables. If the PK really tolerates no gaps, maybe the choice of PK was not ideal... If you really think you should do this (and are sure nothing will break in ot...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Try this: ``` SET @var:=0; UPDATE `table` SET `id`=(@var:=@var+1); ALTER TABLE `table` AUTO_INCREMENT=1; ```
Not sure about one command, but you can do it in four commands: ``` CREATE TABLE `temp` SELECT * FROM `orig_tbl`; TRUNCATE `orig_tbl`; -- counter doesn't reset in some old versions ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; -- now we omit primary key column to let it seal the holes INSERT INTO `orig_tbl` (`col1`, `co...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Not sure about one command, but you can do it in four commands: ``` CREATE TABLE `temp` SELECT * FROM `orig_tbl`; TRUNCATE `orig_tbl`; -- counter doesn't reset in some old versions ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; -- now we omit primary key column to let it seal the holes INSERT INTO `orig_tbl` (`col1`, `co...
Another way, without truncating whole table: ``` -- Make Backup of original table's content CREATE TABLE `orig_tbl_backup` SELECT * FROM `orig_tbl`; -- Drop needed column. ALTER TABLE `orig_tbl` DROP `id`; -- Re-create it ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; ALTER TABLE `orig_tbl` ADD `id` int UNSIGNED NOT NULL...
7,377,628
I have a table of 5700 records. The primary key is an integer. Now I noticed that some values are missing. Like this: ``` 100 data 101 data 102 data 104 data ``` `103` is missing. How I can update all the rows so that the order becomes correct (`104` becomes `103` in my example) in one SQL command?
2011/09/11
[ "https://Stackoverflow.com/questions/7377628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/616129/" ]
Try this: ``` SET @var:=0; UPDATE `table` SET `id`=(@var:=@var+1); ALTER TABLE `table` AUTO_INCREMENT=1; ```
Another way, without truncating whole table: ``` -- Make Backup of original table's content CREATE TABLE `orig_tbl_backup` SELECT * FROM `orig_tbl`; -- Drop needed column. ALTER TABLE `orig_tbl` DROP `id`; -- Re-create it ALTER TABLE `orig_tbl` AUTO_INCREMENT = 1; ALTER TABLE `orig_tbl` ADD `id` int UNSIGNED NOT NULL...
44,811,928
I'm looking to make a method which detects if the following value in an array is a duplicate, and deletes it if so. It should work for both strings and integers. For example, given the Array: ``` arr = ["A", "B", "B", "C", "c", "A", "D", "D"] ``` Return: ``` arr = ["A", "B", "C", "c", "A", "D"] ``` I tried crea...
2017/06/28
[ "https://Stackoverflow.com/questions/44811928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6831572/" ]
First at all, here is simpler solution: ``` > arr.delete_if.with_index { |e, ind| e == arr[ind+1] } #=> ["A", "B", "C", "c", "A", "D"] ``` But, this solution will mutate `arr`. Here are one-line solutions without mutates: ``` arr.each_with_index.with_object([]) { |(e, ind), res| res << e if e != arr[ind+1] } arr.ea...
I would use [select](https://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-select), so you could do something like: ``` a = ["A", "B", "B", "C", "c", "A", "D", "D"] # without mutation b = a.select.with_index { |e, i| a[i+1] != e } a #=> ["A", "B", "B", "C", "c", "A", "D", "D"] b #=> ["A", "B", "C", "c", "A", "D"] ...