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
7,710,639
I am modifying a regex validator control. The regex at the moment looks like this: ``` (\d*\,?\d{2}?){1}$ ``` As I can understand it allows for a number with 2 decimal places. I need to modify it like this: * The number must range from 0 - 1.000.000. (Zero to one million). * The number may or may not have 2 deci...
2011/10/10
[ "https://Stackoverflow.com/questions/7710639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/817455/" ]
Try this regex: ``` ^(((0|[1-9]\d{0,5})(\,\d{2})?)|(1000000(\,00)?))$ ``` It accepts numbers like: `"4", "4,23", "123456", "1000000", "1000000,00"`, but don't accepts: `",23", "4,7", "1000001", "4,234", "1000000,55"`. If you want accept only numbers with exactly two decimals, use this regex: ``` ^(((0|[1-9]\d{0,...
What about this one ``` ^(?:\d{1,6}(?:\,\d{2})?|1000000)$ ``` See it [here on Regexr](http://regexr.com?2ut4u) It accepts between 1 and 6 digits and an optional fraction with 2 digits OR "1000000". And it allows the number to start with zeros! (001 would be accepted) `^` anchors the regex to the start of the stri...
7,710,639
I am modifying a regex validator control. The regex at the moment looks like this: ``` (\d*\,?\d{2}?){1}$ ``` As I can understand it allows for a number with 2 decimal places. I need to modify it like this: * The number must range from 0 - 1.000.000. (Zero to one million). * The number may or may not have 2 deci...
2011/10/10
[ "https://Stackoverflow.com/questions/7710639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/817455/" ]
Try this regex: ``` ^(((0|[1-9]\d{0,5})(\,\d{2})?)|(1000000(\,00)?))$ ``` It accepts numbers like: `"4", "4,23", "123456", "1000000", "1000000,00"`, but don't accepts: `",23", "4,7", "1000001", "4,234", "1000000,55"`. If you want accept only numbers with exactly two decimals, use this regex: ``` ^(((0|[1-9]\d{0,...
``` ^(([0-9]|([1-9][0-9]{1,5}))(\.[0-9]{1,2})?)|1000000$ ```
24,444,188
can someone please tell me what is going wrong? I am trying to create a basic login page and that opens only when a correct password is written ``` <html> <head> <script> function validateForm() { var x=document.forms["myForm"]["fname"].value; if (x==null || x=="") { alert("First name must be filled out"); retu...
2014/06/27
[ "https://Stackoverflow.com/questions/24444188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2771301/" ]
try this ``` BufferedWriter writer = new BufferedWriter(new FileWriter("result.txt")); for (String element : misspelledWords) { writer.write(element); writer.newLine(); } ``` Adding line separator at the end (like "\n") should work on most OS,but to be on safer side you should use **S...
Open your file in append mode like this `FileWriter(String fileName, boolean append)` when you want to make an object of class `FileWrite` in constructor. ``` File file = new File("C:\\Users\\Izak\\Documents\\NetBeansProjects\\addNewLinetoTxtFile\\src\\addnewlinetotxtfile\\a.txt"); try (Writer newLine = new Buf...
47,331,969
I'm trying to merge informations in two different data frames, but problem begins with uneven dimensions and trying to use not the column index but the information in the column. merge function in R or join's (dplyr) don't work with my data. I have to dataframes (One is subset of the others with updated info in the la...
2017/11/16
[ "https://Stackoverflow.com/questions/47331969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8609239/" ]
`%in%` from base-r is there to rescue. ``` df1=data.frame(Name = print(LETTERS[1:9]), val = seq(1:3), Case = c("NA","1","NA","NA","1","NA","1","NA","NA"), stringsAsFactors = F) df2 = data.frame(Name = c("A","D","H"), val = seq(1:3), Case = "1", stringsAsFactors = F) df1$Case <- ifelse(df1$Name %in% df2$N...
Here is what I would do using `dplyr`: ``` df1 %>% left_join(df2, by = c("Name")) %>% mutate(val = if_else(is.na(val.y), val.x, val.y), Case = if_else(is.na(Case.y), Case.x, Case.y)) %>% select(Name, val, Case) ```
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
I think you'll be better off trying to use one cursor for all of your executions, and close it at the end of your code. It's easier to work with, and it might have efficiency benefits as well (don't quote me on that one). ``` conn = MySQLdb.connect("host","user","pass","database") cursor = conn.cursor() cursor.execute...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Note: this answer is for [PyMySQL](https://github.com/PyMySQL/PyMySQL), which is a drop-in replacement for MySQLdb and effectively the latest version of MySQLdb since MySQLdb stopped being maintained. I believe everything here is *also* true of the legacy MySQLdb, but haven't checked. First of all, some facts: * Pyth...
I suggest to do it like php and mysql. Start i at the beginning of your code before printing of the first data. So if you get a connect error you can display a `50x`(Don't remember what internal error is) error message. And keep it open for the whole session and close it when you know you wont need it anymore.
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
I think you'll be better off trying to use one cursor for all of your executions, and close it at the end of your code. It's easier to work with, and it might have efficiency benefits as well (don't quote me on that one). ``` conn = MySQLdb.connect("host","user","pass","database") cursor = conn.cursor() cursor.execute...
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
I think you'll be better off trying to use one cursor for all of your executions, and close it at the end of your code. It's easier to work with, and it might have efficiency benefits as well (don't quote me on that one). ``` conn = MySQLdb.connect("host","user","pass","database") cursor = conn.cursor() cursor.execute...
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
It's better to rewrite it using 'with' keyword. 'With' will take care about closing cursor (it's important because it's unmanaged resource) automatically. The benefit is it will close cursor in case of exception too. ``` from contextlib import closing import MySQLdb ''' At the beginning you open a DB connection. Par...
Note: this answer is for [PyMySQL](https://github.com/PyMySQL/PyMySQL), which is a drop-in replacement for MySQLdb and effectively the latest version of MySQLdb since MySQLdb stopped being maintained. I believe everything here is *also* true of the legacy MySQLdb, but haven't checked. First of all, some facts: * Pyth...
5,669,878
I'm building a WSGI web app and I have a MySQL database. I'm using MySQLdb, which provides cursors for executing statements and getting results. **What is the standard practice for getting and closing cursors?** In particular, how long should my cursors last? Should I get a new cursor for each transaction? I believe y...
2011/04/14
[ "https://Stackoverflow.com/questions/5669878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/484488/" ]
Instead of asking what is standard practice, since that's often unclear and subjective, you might try looking to the module itself for guidance. In general, using the `with` keyword as another user suggested is a great idea, but in this specific circumstance it may not give you quite the functionality you expect. As o...
Note: this answer is for [PyMySQL](https://github.com/PyMySQL/PyMySQL), which is a drop-in replacement for MySQLdb and effectively the latest version of MySQLdb since MySQLdb stopped being maintained. I believe everything here is *also* true of the legacy MySQLdb, but haven't checked. First of all, some facts: * Pyth...
56,148,199
I am new to the Ruby on Rails ecosystem so might question might be really trivial. I have set up an Active Storage on one of my model ```rb class Sedcard < ApplicationRecord has_many_attached :photos end ``` And I simply want to seed data with `Faker` in it like so: ```rb require 'faker' Sedcard.destroy_all 20....
2019/05/15
[ "https://Stackoverflow.com/questions/56148199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2828594/" ]
I found the problem myself. I was using UUID as my model's primary key which is not natively compatible with ActiveStorage. Thus, I more or less followed the instructions [here](https://www.wrburgess.com/posts/2018-02-03-1.html)
You need to purge the attachments. Try adding this snippet before destroyingthe `Sedcard`'s ``` Sedcard.all.each{ |s| s.photos.purge } ``` Ref: <https://edgeguides.rubyonrails.org/active_storage_overview.html#removing-files>
199,883
Say I have an expansion of terms containing functions `y[j,t]` and its derivatives, indexed by `j` with the index beginning at 0 whose independent variable are `t`, like so: `Expr = y[0,t]^2 + D[y[0,t],t]*y[0,t] + y[0,t]*y[1,t] + y[0,t]*D[y[1,t],t] + (y[1,t])^2*y[0,t] +` ... etc. Now I wish to define new functions i...
2019/06/06
[ "https://mathematica.stackexchange.com/questions/199883", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/41975/" ]
Since [`Show`](http://reference.wolfram.com/language/ref/Show) uses the [`PlotRange`](http://reference.wolfram.com/language/ref/PlotRange) setting from the first plot, you can just set your plot range when defining the first plot: ``` p1=LogLogPlot[ RO, {t,0.00001,0.05}, PlotRange -> {{10^-5, 10^-4}, All},...
Your syntax is incorrect, it should be ``` Show[{p1,p2},PlotRange->{{x_min,x_max},{y_min,y_max}}] ``` If you want all in y, you can do: ``` Show[{p1,p2},PlotRange->{{10^(-5),10^(-4)},All}] ```
61,989,976
I am trying to perform JWT auth in spring boot and the request are getting stuck in redirect loop. **JWTAuthenticationProvider** ``` @Component public class JwtAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { @Autowired private JwtUtil jwtUtil; @Override public boolean supp...
2020/05/24
[ "https://Stackoverflow.com/questions/61989976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4457734/" ]
I believe the the reason for this is because you have not actually set the `AuthenticationSuccessHandler` for the bean `JwtAuthenticationFilter`, since it is not actually set it will keep looping around super and chain and later when the error needs to be sent since response is already written in `super()` `chain.doFil...
I solved this problem with another approach. In the JwtAuthenticationFilter class we need to set authentication object in context and call chain.doFilter. Calling super.successfulAuthentication can be skipped as we have overridden the implementation. ``` @Override protected void successfulAuthentication(HttpServle...
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
Use [`SimpleDateFormat`](http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy [`Date`](http://download.oracle.com/javase/6/docs/api/java/util/Date.html) and use another one to format the parsed `Date` to...
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
You can use SimpleDateFormat class to convert the string you have to a date object. The date format can be given in the constructor. The format method converts the string to a date object. After getting the date object, you can format it in the way you want.
One liner in java 8 and above. ``` String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy")); ```
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
Use [`SimpleDateFormat`](http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy [`Date`](http://download.oracle.com/javase/6/docs/api/java/util/Date.html) and use another one to format the parsed `Date` to...
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
One liner in java 8 and above. ``` String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy")); ```
``` Date d = new Date("Mon Sep 14 15:24:40 UTC 2009"); SimpleDateFormat f = new SimpleDateFormat("dd/M/yyyy"); String s = new String(f.format(d)); ```
4,177,291
I have the following string: ``` Mon Sep 14 15:24:40 UTC 2009 ``` I need to format it into a string like this: ``` 14/9/2009 ``` How do I do it in Java?
2010/11/14
[ "https://Stackoverflow.com/questions/4177291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264419/" ]
Use [`SimpleDateFormat`](http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy [`Date`](http://download.oracle.com/javase/6/docs/api/java/util/Date.html) and use another one to format the parsed `Date` to...
One liner in java 8 and above. ``` String localDateTime= LocalDateTime.parse("Mon Sep 14 15:24:40 UTC 2009", DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss z yyyy")).format(DateTimeFormatter.ofPattern("d/M/yyyy")); ```
44,169,413
[Error Message Picture](https://i.stack.imgur.com/kkbkN.png) I basically followed the instructions from the below link EXACTLY and I'm getting this damn error? I have no idea what I'm supposed to do, wtf? Do I need to create some kind of persisted method?? There were several other questions like this and after reading...
2017/05/24
[ "https://Stackoverflow.com/questions/44169413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6484371/" ]
Changed the bottom portion to: ``` def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.email = auth.info.email user.password = Devise.friendly_token[0,20] user.name = auth.info.name # assuming the user model has a name end end ``` ran rails g mig...
The persisted? method is checking whether or not the user exists thereby returning nil value if no such record exists and your user model is not creating new ones. So by uncommenting the code from the example to this: ``` def self.from_omniauth(access_token) data = access_token.info user = User.where(:email => dat...
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
I think the session items are client sided. You can create a query to count the open connections (hence you're working with a MySQL database.) Another option is to use external software (I use the tawk.to helpchat, which shows the amount of users visiting a page in realtime). You could maybe use that, making the suppor...
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
That is the problem that you cannot do it using *Session[]* variables. You need to be using a database (or a central data source to store the total number of active users). For example, you can see in your application, when the application starts there is no `Application["UsersOnline"]` variable, you create it at the v...
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Perhaps I am missing something, but why not something like this: ``` public void Session_OnStart() { Application.Lock(); if (Application["UsersOnline"] == null ) { Application["UsersOnline"] = 0 } Application["UsersOnline"] = (int)Application["UsersOnline"] + 1; Application.UnLock(); ``` }
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Maybe I'm missing something, but is there a reason you don't just want to use something like Google Analytics? Unless you're looking for more queryable data, in which case I'd suggest what others have; store the login count to a data store. Just keep in mind you also have to have something to decrement that counter wh...
29,130,635
I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this ``` def prep_matrix(N): I_N = np.identity(N) NV = zer...
2015/03/18
[ "https://Stackoverflow.com/questions/29130635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668777/" ]
Dirty, hacky, inefficient, solution (assumes use of forms authentication): ``` public void Global_BeginRequest(object sender, EventArgs e) { if( Context.User != null && !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && Context.Session != null && Context.Session["IAMTRACKE...
Try this. It may help you. ``` void Application_Start(object sender, EventArgs e) { Application["cnt"] = 0; Application["onlineusers"] = 0; // Code that runs on application startup } void Session_Start(object sender, EventArgs e) { Application.Lock(); Application["cnt"] = (int)Application["cnt"...
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
If using Rails 4.2, you can set the placeholder attribute to true: ``` = f.text_field :first_name, placeholder: true ``` and specify the placeholder text in the locale file like this: ``` en: helpers: placeholder: user: first_name: "Your name" ```
You can view the source on render at <http://rubydoc.info/docs/rails/ActionView/Helpers/Tags/Label> to see how Rails does it. It probably doesn't get a lot better than you have, but you could probably swipe some of Rail's logic and stick it in a helper, if you have a lot of them to do. Alternatively, you may consider u...
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
With Rails >= 4.2, you can set the placeholder attribute to true `= f.text_field :first_name, placeholder: true` and in your local file (e.g. en.yml): ``` ru: activerecord: attributes: user: first_name: Your name ``` otherwise (Rails >= 3.0) I think you can write something like this: ``` = f.t...
You can view the source on render at <http://rubydoc.info/docs/rails/ActionView/Helpers/Tags/Label> to see how Rails does it. It probably doesn't get a lot better than you have, but you could probably swipe some of Rail's logic and stick it in a helper, if you have a lot of them to do. Alternatively, you may consider u...
25,677,031
I want Rails to automatically translate placeholder text like it does with form labels. How can I do this? Form labels are translated automatically like this: ``` = f.text_field :first_name ``` This helper uses the locale file: ``` en: active_model: models: user: attributes: first_nam...
2014/09/05
[ "https://Stackoverflow.com/questions/25677031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2615384/" ]
If using Rails 4.2, you can set the placeholder attribute to true: ``` = f.text_field :first_name, placeholder: true ``` and specify the placeholder text in the locale file like this: ``` en: helpers: placeholder: user: first_name: "Your name" ```
With Rails >= 4.2, you can set the placeholder attribute to true `= f.text_field :first_name, placeholder: true` and in your local file (e.g. en.yml): ``` ru: activerecord: attributes: user: first_name: Your name ``` otherwise (Rails >= 3.0) I think you can write something like this: ``` = f.t...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
You can open the background page's console if you click on the "background.html" link in the extensions list. To access the background page that corresponds to your extensions open `Settings / Extensions` or open a new tab and enter `chrome://extensions`. You will see something like this screenshot. ![Chrome extensi...
To answer your question directly, when you call `console.log("something")` from the background, this message is logged, to the background page's console. To view it, you may go to `chrome://extensions/` and click on that `inspect view` under your extension. When you click the popup, it's loaded into the current page, ...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
The simplest solution would be to add the following code on the top of the file. And than you can use all full [Chrome console api](https://developers.google.com/chrome-developer-tools/docs/console-api) as you would normally. ``` console = chrome.extension.getBackgroundPage().console; // for instance, console.assert(...
In relation to the original question I'd like to add to the accepted answer by Mohamed Mansour that there is also a way to make this work the other way around: You can access other extension pages (i.e. options page, popup page) from *within the background page/script* with the `chrome.extension.getViews()` call. As d...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
You can still use console.log(), but it gets logged into a separate console. In order to view it - right click on the extension icon and select "Inspect popup".
To view console while debugging your chrome extension, you should use the `chrome.extension.getBackgroundPage();` API, after that you can use `console.log()` as usual: ``` chrome.extension.getBackgroundPage().console.log('Testing'); ``` This is good when you use multiple time, so for that you create custom function:...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
Curently with Manifest 3 and service worker, you just need to go to `Extensions Page / Details` and just click `Inspect Views / Service Worker`.
To view console while debugging your chrome extension, you should use the `chrome.extension.getBackgroundPage();` API, after that you can use `console.log()` as usual: ``` chrome.extension.getBackgroundPage().console.log('Testing'); ``` This is good when you use multiple time, so for that you create custom function:...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
``` const log = chrome.extension.getBackgroundPage().console.log; log('something') ``` Open log: * Open: chrome://extensions/ * Details > Background page
Curently with Manifest 3 and service worker, you just need to go to `Extensions Page / Details` and just click `Inspect Views / Service Worker`.
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
You can open the background page's console if you click on the "background.html" link in the extensions list. To access the background page that corresponds to your extensions open `Settings / Extensions` or open a new tab and enter `chrome://extensions`. You will see something like this screenshot. ![Chrome extensi...
You can still use console.log(), but it gets logged into a separate console. In order to view it - right click on the extension icon and select "Inspect popup".
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
Any *extension page* (except [content scripts](http://developer.chrome.com/extensions/content_scripts.html)) has direct access to the background page via [`chrome.extension.getBackgroundPage()`](http://developer.chrome.com/extensions/extension.html#method-getBackgroundPage). That means, within the [popup page](http://...
To get a console log from a background page you need to write the following code snippet in your background page background.js - ``` chrome.extension.getBackgroundPage().console.log('hello'); ``` Then load the extension and inspect its background page to see the console log. Go ahead!!
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
The simplest solution would be to add the following code on the top of the file. And than you can use all full [Chrome console api](https://developers.google.com/chrome-developer-tools/docs/console-api) as you would normally. ``` console = chrome.extension.getBackgroundPage().console; // for instance, console.assert(...
`chrome.extension.getBackgroundPage()` I get `null` and accrouding [documentation](https://developer.chrome.com/docs/extensions/mv3/mv3-migration-checklist/), > > Background pages are replaced by service workers in MV3. > > > * Replace `background.page` or `background.scripts` with `background.service_worker` in m...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
``` const log = chrome.extension.getBackgroundPage().console.log; log('something') ``` Open log: * Open: chrome://extensions/ * Details > Background page
In relation to the original question I'd like to add to the accepted answer by Mohamed Mansour that there is also a way to make this work the other way around: You can access other extension pages (i.e. options page, popup page) from *within the background page/script* with the `chrome.extension.getViews()` call. As d...
3,829,150
If I call `console.log('something');` from the popup page, or any script included off that it works fine. However as the background page is not directly run off the popup page it is not included in the console. Is there a way that I can get `console.log()`'s in the background page to show up in the console for the po...
2010/09/30
[ "https://Stackoverflow.com/questions/3829150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383759/" ]
Try this, if you want to log to the active page's console: ``` chrome.tabs.executeScript({ code: 'console.log("addd")' }); ```
To view console while debugging your chrome extension, you should use the `chrome.extension.getBackgroundPage();` API, after that you can use `console.log()` as usual: ``` chrome.extension.getBackgroundPage().console.log('Testing'); ``` This is good when you use multiple time, so for that you create custom function:...
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
In steps. First we do a rolling `diff` on your index, anything that is greater than 1 we code as True, we then apply a `cumsum` to create a new group per sequence. ``` 45 0 46 0 47 0 51 1 52 1 ``` --- Next, we use the `groupby` method with the new sequences to create your nested list inside a list c...
The issue is with this line ``` sequences[seq] = [index] ``` You are trying to assign the list an index which is not created. Instead do this. ``` sequences.append([index]) ```
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
You can use this: ``` s_index=df.index.to_series() l = s_index.groupby(s_index.diff().ne(1).cumsum()).agg(list).to_numpy() ``` Output: ``` l[0] [45, 46, 47] ``` and ``` l[1] [51, 52] ```
The issue is with this line ``` sequences[seq] = [index] ``` You are trying to assign the list an index which is not created. Instead do this. ``` sequences.append([index]) ```
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
The issue is with this line ``` sequences[seq] = [index] ``` You are trying to assign the list an index which is not created. Instead do this. ``` sequences.append([index]) ```
I use the diff to find when the index value diff changes greater than 1. I iterate the tuples and access by index their values. ``` index=[45,46,47,51,52] price=[3909.0,3908.75,3908.50,3907.75,3907.5] count=[8,8,8,8,8] df=pd.DataFrame({'index':index,'price':price,'count':count}) df['diff']=df['index'].diff().fillna(0...
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
You can use this: ``` s_index=df.index.to_series() l = s_index.groupby(s_index.diff().ne(1).cumsum()).agg(list).to_numpy() ``` Output: ``` l[0] [45, 46, 47] ``` and ``` l[1] [51, 52] ```
In steps. First we do a rolling `diff` on your index, anything that is greater than 1 we code as True, we then apply a `cumsum` to create a new group per sequence. ``` 45 0 46 0 47 0 51 1 52 1 ``` --- Next, we use the `groupby` method with the new sequences to create your nested list inside a list c...
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
In steps. First we do a rolling `diff` on your index, anything that is greater than 1 we code as True, we then apply a `cumsum` to create a new group per sequence. ``` 45 0 46 0 47 0 51 1 52 1 ``` --- Next, we use the `groupby` method with the new sequences to create your nested list inside a list c...
I use the diff to find when the index value diff changes greater than 1. I iterate the tuples and access by index their values. ``` index=[45,46,47,51,52] price=[3909.0,3908.75,3908.50,3907.75,3907.5] count=[8,8,8,8,8] df=pd.DataFrame({'index':index,'price':price,'count':count}) df['diff']=df['index'].diff().fillna(0...
66,233,268
I am working on a project where we frequently work with a list of usernames. We also have a function to take a username and return a dataframe with that user's data. E.g. ``` users = c("bob", "john", "michael") get_data_for_user = function(user) { data.frame(user=user, data=sample(10)) } ``` We often: 1. Iterate...
2021/02/16
[ "https://Stackoverflow.com/questions/66233268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2518602/" ]
You can use this: ``` s_index=df.index.to_series() l = s_index.groupby(s_index.diff().ne(1).cumsum()).agg(list).to_numpy() ``` Output: ``` l[0] [45, 46, 47] ``` and ``` l[1] [51, 52] ```
I use the diff to find when the index value diff changes greater than 1. I iterate the tuples and access by index their values. ``` index=[45,46,47,51,52] price=[3909.0,3908.75,3908.50,3907.75,3907.5] count=[8,8,8,8,8] df=pd.DataFrame({'index':index,'price':price,'count':count}) df['diff']=df['index'].diff().fillna(0...
6,677,308
I'm using jQuery Treeview. Is there's a way to populate a children node in a specific parent on onclick event? Please give me some advise or simple sample code to do this.
2011/07/13
[ "https://Stackoverflow.com/questions/6677308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/768789/" ]
You can trigger the change event yourself in the `inputvalue` function: ``` function inputvalue(){ $("#inputid").val("bla").change(); } ``` Also notice the correction of your syntax... in jQuery, `val` is a function that takes a string as a parameter. You can't assign to it as you are doing. Here is an [example ...
Your function has an error. Try this: ``` function inputvalue(){ $("#inputid").val()="bla" } ``` EDIT My function is also wrong as pointed in comments. The correct is: Using pure javascript ``` function inputvalue(){ document.getElementById("inputid").value ="bla"; } ``` Using jQuery ``` function ...
24,010
UPDATE Have included an image. As you can see, LED is ON when base is floating. This is a 2N222A transistor. ![enter image description here](https://i.stack.imgur.com/0x1RH.jpg) ![enter image description here](https://i.stack.imgur.com/C2V28.jpg) --- Playing with an NPN bipolar transistor. The Collector is connect...
2011/12/21
[ "https://electronics.stackexchange.com/questions/24010", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/4336/" ]
Okay, looking at the picture I think you may have the transistor the wrong way round. Try turning it round. See this picture for reference: ![enter image description here](https://i.stack.imgur.com/tDQzJ.png) As you can see the collector is on the right with the flat part facing you, so you have the collector con...
Please answer: * What colour LED are you using? * What is your transistor type. ? --- You should look at some of the 10's of thousands of diagrams available on the net before connecting a transistor to try to do this job and/or look at the transistor's data sheet. All transistors have a maximum Vbe rating and you ...
23,238,724
I have a layout as follows for mobile .. ``` +------------------------+ | (col-md-6) Div 1 | +------------------------+ | (col-md-6) Div 2 | +------------------------+ | (col-md-6) Div 3 | +------------------------+ | (col-md-6) Div 4 | +---------------------...
2014/04/23
[ "https://Stackoverflow.com/questions/23238724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/505055/" ]
The problem is not linked to data.frame, but simply that you cannot have in the same vector objects of class numeric and objects of class character. It is NOT possible. The person who started the project before you should not have used the string "Error" to indicate a missing data. Instead, you should use NA : ``` x=...
You could do this: ``` x <- 1 y <- c("Error","Error") df <- data.frame(c(list(), x, y), stringsAsFactors = FALSE) > str(df) 'data.frame': 1 obs. of 3 variables: $ X1 : num 1 $ X.Error. : chr "Error" $ X.Error..1: chr "Error" ``` You just have to set proper column names.
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
As mentioned in the comment, `True/False` values are also the instances of `int` in Python, so you can add one more condition to check if the value is not an instance of `bool`: ```py >>> lst = [True, 19, 19.5, False] >>> [x for x in lst if isinstance(x, int) and not isinstance(x, bool)] [19] ```
`bool` is a subclass of `int`, therefore `True` is an instance of `int`. * `False` equal to `0` * `True` equal to `1` you can use another check or `if type(i) is int`
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
As mentioned in the comment, `True/False` values are also the instances of `int` in Python, so you can add one more condition to check if the value is not an instance of `bool`: ```py >>> lst = [True, 19, 19.5, False] >>> [x for x in lst if isinstance(x, int) and not isinstance(x, bool)] [19] ```
Use `type` comparison instead: ``` _list = [i for i in _list if type(i) is int] ``` Side note: avoid using `list` as the variable name since it's the Python builtin name for the [`list`](https://docs.python.org/3/library/stdtypes.html#list) type.
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
As mentioned in the comment, `True/False` values are also the instances of `int` in Python, so you can add one more condition to check if the value is not an instance of `bool`: ```py >>> lst = [True, 19, 19.5, False] >>> [x for x in lst if isinstance(x, int) and not isinstance(x, bool)] [19] ```
You could try using a conditional statement within your code that checks for isinstance(i, int) and only appends i to the list if that condition is True.
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
Use `type` comparison instead: ``` _list = [i for i in _list if type(i) is int] ``` Side note: avoid using `list` as the variable name since it's the Python builtin name for the [`list`](https://docs.python.org/3/library/stdtypes.html#list) type.
`bool` is a subclass of `int`, therefore `True` is an instance of `int`. * `False` equal to `0` * `True` equal to `1` you can use another check or `if type(i) is int`
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
`bool` is a subclass of `int`, therefore `True` is an instance of `int`. * `False` equal to `0` * `True` equal to `1` you can use another check or `if type(i) is int`
You could try using a conditional statement within your code that checks for isinstance(i, int) and only appends i to the list if that condition is True.
74,081,278
I have a dataframe which looks like this: ``` val "ID: abc\nName: John\nLast name: Johnson\nAge: 27" "ID: igb1\nName: Mike\nLast name: Jackson\nPosition: CEO\nAge: 42" ... ``` I would like to extract Name, Position and Age from those values and turn them into separate columns to get dataframe which looks like this: ...
2022/10/15
[ "https://Stackoverflow.com/questions/74081278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378883/" ]
Use `type` comparison instead: ``` _list = [i for i in _list if type(i) is int] ``` Side note: avoid using `list` as the variable name since it's the Python builtin name for the [`list`](https://docs.python.org/3/library/stdtypes.html#list) type.
You could try using a conditional statement within your code that checks for isinstance(i, int) and only appends i to the list if that condition is True.
25,207,910
I'm adding a new model to rails\_admin. The list page displays datetime fields correctly, even without any configuration. But the detail (show) page for a given object does not display datetimes. How do I configure rails\_admin to show datetime fields on the show page? Model file: alert\_recording.rb: ``` class Alert...
2014/08/08
[ "https://Stackoverflow.com/questions/25207910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3923011/" ]
These fields are hidden by default as you can see here: <https://github.com/sferik/rails_admin/blob/ead1775c48754d6a99c25e4d74494a60aee9b4d1/lib/rails_admin/config.rb#L277> You can overwrite this setting on your config initializer, just open the file `config/initializers/rails_admin.rb` and add this line to it: `con...
What you have in there for `sent_at` and `acknowledged_at` should work. Make sure the records you are trying to "show" have dates present for these fields. For `created_at` and `updated_at`, try [this](https://github.com/sferik/rails_admin/issues/994): ``` config.model AlertRecording do field :created_at configur...
18,392,750
Trying to work out where I have screwed up with trying to create a count down timer which displays seconds and milliseconds. The idea is the timer displays the count down time to an NSString which updates a UILable. The code I currently have is ``` -(void)timerRun { if (self.timerPageView.startCountdown) { ...
2013/08/23
[ "https://Stackoverflow.com/questions/18392750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2556050/" ]
You have a timer that will execute roughly 100 times per second (interval of 0.01). You decrement a value by `1` each time. Therefore, your `self.timerPageView.sec` variable appears to be hundredths of a second. To get the number of seconds, you need to divide this value by 100. To get the number of milliseconds, you...
These calculations look pretty suspect: ``` seconds = (self.timerPageView.sec % 60) % 60 ; milliseconds = (self.timerPageView.sec % 60) % 1000; ``` You are using int type calculations (pretty sketchy in their implementation) on a float value for seconds. ``` NSUInteger seconds = (NSUInteger)(self.timerPageView.s...
18,392,750
Trying to work out where I have screwed up with trying to create a count down timer which displays seconds and milliseconds. The idea is the timer displays the count down time to an NSString which updates a UILable. The code I currently have is ``` -(void)timerRun { if (self.timerPageView.startCountdown) { ...
2013/08/23
[ "https://Stackoverflow.com/questions/18392750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2556050/" ]
You have a timer that will execute roughly 100 times per second (interval of 0.01). You decrement a value by `1` each time. Therefore, your `self.timerPageView.sec` variable appears to be hundredths of a second. To get the number of seconds, you need to divide this value by 100. To get the number of milliseconds, you...
You set a time interval of 0.01, which is every 10 milliseconds, 0.001 is every millisecond. Even so, NSTimer is not that accurate, you probably won't get it to work every 1 ms. It is fired from the run loop so there is latency and jitter.
4,882,465
I am quite a noob when it comes to deploying a Django project. I'd like to know what are the various methods to deploy Django project and which one is the most preferred.
2011/02/03
[ "https://Stackoverflow.com/questions/4882465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277848/" ]
Use the Nginx/Apache/mod-wsgi and you can't go wrong. If you prefer a simple alternative, just use Apache. There is a very good deployment document: <http://lethain.com/entry/2009/feb/13/the-django-and-ubuntu-intrepid-almanac/>
I myself have faced a lot of problems in deploying Django Projects and automating the deployment process. Apache and mod\_wsgi were like curse for Django Deployment. There are several tools like [Nginx](http://wiki.nginx.org/Main), [Gunicorn](http://gunicorn.org/), [SupervisorD](http://supervisord.org/) and Fabric whic...
4,882,465
I am quite a noob when it comes to deploying a Django project. I'd like to know what are the various methods to deploy Django project and which one is the most preferred.
2011/02/03
[ "https://Stackoverflow.com/questions/4882465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277848/" ]
The Django documentation lists Apache/mod\_wsgi, Apache/mod\_python and FastCGI etc. **mod\_python** is deprecated now, one should use mod\_wsgi instead. Django with **mod\_wsgi** is easy to setup, but: * you can only use one python version at a time [edit: you even can only use the python version mod\_wsgi was co...
I myself have faced a lot of problems in deploying Django Projects and automating the deployment process. Apache and mod\_wsgi were like curse for Django Deployment. There are several tools like [Nginx](http://wiki.nginx.org/Main), [Gunicorn](http://gunicorn.org/), [SupervisorD](http://supervisord.org/) and Fabric whic...
23,898,432
I have this source of a single file that is successfully compiled in C: ``` #include <stdio.h> int a; unsigned char b = 'A'; extern int alpha; int main() { extern unsigned char b; double a = 3.4; { extern a; printf("%d %d\n", b, a+1); } return 0; } ``` After running it, the outpu...
2014/05/27
[ "https://Stackoverflow.com/questions/23898432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2565010/" ]
The problem is here: ``` System.out.println("Average of column 1:" + (myTable [0][0] + myTable [0][1] + myTable [0][2] + myTable [0][3] + myTable [0][4]) / 4 ); ``` You're accessing to `myTable[0][4]`, when `myTable` is defined as `int[5][4]`. Fix this and your code will work. ``` System.out.println("Average of co...
Essentially, `myTable` is defined for values up to `[4][3]` which is fine, but in your output statements, you get the mixed, as if they went up to `[3][4]`. You need 5 not 4 lines and you need to remove `+ myTable [?][4]` in each of them.
2,884,715
I am currently investigating the specific square number $a^n+1$ and whether it can become a square. I know that $a^n+1$ cannot be a square if n is even because then I can write n=2x, and so $(a^n)^2$+1 is always smaller than $(a^n+1)^2$. But what about odd powers of n? Can they allow $a^n+1$ to become a square? Or a ...
2018/08/16
[ "https://math.stackexchange.com/questions/2884715", "https://math.stackexchange.com", "https://math.stackexchange.com/users/449771/" ]
To answer the question in the title: The next square after $n^2$ is $(n+1)^2=n^2+2n+1 > n^2+1$ if $n>0$. Therefore, $n^2+1$ is never a square, unless $n=0$.
Can $a^n+1$ ever be a square? PARTIAL ANSWER If $a^n+1=m^2$ then $a^n=(m^2-1)=(m+1)(m-1)$. If $a$ is odd, then both $(m+1)$ and $(m-1)$ are odd, and moreover, two sequential odd numbers have no factors in common. Thus $(m+1)=r^n$ and $(m-1)=s^n$, $\gcd{r,s}=1$, because the product of $(m+1)$ and $(m-1)$ must be an $n^...
4,623,475
The MySQL Stored Procedure was: ``` BEGIN set @sql=_sql; PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; set _ires=LAST_INSERT_ID(); END$$ ``` I tried to convert it to: ``` BEGIN EXECUTE _sql; SELECT INTO _ires CURRVAL('table_seq'); RETURN; ...
2011/01/07
[ "https://Stackoverflow.com/questions/4623475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/563296/" ]
You can add an option 'expression' to the configuration. Normally it gets a "$user" as argument. So you can do something like: ``` array('allow', 'actions'=>array('index','update', 'create', 'delete'), 'expression'=> '$user->isAdmin', ), ``` Note that I haven't tested this but I think it will work. Take a loo...
Well it won't work because it knows Yii::app()->user as a CWebUser Instance and you developed the UserIdentity class so it would say 'CWebUser and its behaviors do not have a method or closure named "isAdmin"'! To use expressions like $user->isAdmin your should set isAdmin property throw the setState command which woul...
3,988,620
This should be straight foreward, but I simply can't figure it out(!) I have a UIView 'filled with' a UIScrollView. Inside the scrollView I wan't to have a UITableView. I have hooked up both the scrollView and the tableView with IBOutlet's in IB and set the ViewController to be the delegate and datasource of the tabl...
2010/10/21
[ "https://Stackoverflow.com/questions/3988620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/463808/" ]
Personally, I would define the key-states as disjoint states and write a simple state-machine, thus: ``` enum keystate { inactive, firstPress, active }; keystate keystates[256]; Class::CalculateKeyStates() { for (int i = 0; i < 256; ++i) { keystate &k = keystates[i]; switch (k) ...
You are always setting `IsFirstPress` if the key is down, which might not be what you want.
3,988,620
This should be straight foreward, but I simply can't figure it out(!) I have a UIView 'filled with' a UIScrollView. Inside the scrollView I wan't to have a UITableView. I have hooked up both the scrollView and the tableView with IBOutlet's in IB and set the ViewController to be the delegate and datasource of the tabl...
2010/10/21
[ "https://Stackoverflow.com/questions/3988620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/463808/" ]
Personally, I would define the key-states as disjoint states and write a simple state-machine, thus: ``` enum keystate { inactive, firstPress, active }; keystate keystates[256]; Class::CalculateKeyStates() { for (int i = 0; i < 256; ++i) { keystate &k = keystates[i]; switch (k) ...
I'm not sure what you want to achieve with `IsFirstPress`, as the keystate cannot remember any previous presses anyways. If you want to mark with this bit, that it's the first time you recognized the key being down, then your logic is wrong in the corresponding `if` statement. `keystates[i] & WasHeldDown` evaluates to...
4,084,790
AFAIK GHC is the most common compiler today, but I also see, that some other ompilers are available too. Is GHC really the best choice for all purposes or may I use something else instead? For instance, I read that some compiler (forgot the name) does better on optimizations, but doesn't implements all extensions.
2010/11/03
[ "https://Stackoverflow.com/questions/4084790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/417501/" ]
GHC is by far the most widely used Haskell compiler, and it offers the most features. There are other options, though, which sometimes have some benefits over GHC. These are some of the more popular alternatives: [Hugs](http://www.haskell.org/hugs/) - Hugs is an interpreter (I don't think it includes a compiler) which...
ghc is a solid compiler. saying it is the best choice for all purposes is a very strong one. and looking for such a tool is futile. Use it, and if you really require something else then by that point you'll probably know what it is.
4,084,790
AFAIK GHC is the most common compiler today, but I also see, that some other ompilers are available too. Is GHC really the best choice for all purposes or may I use something else instead? For instance, I read that some compiler (forgot the name) does better on optimizations, but doesn't implements all extensions.
2010/11/03
[ "https://Stackoverflow.com/questions/4084790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/417501/" ]
GHC is by far the most widely used Haskell compiler, and it offers the most features. There are other options, though, which sometimes have some benefits over GHC. These are some of the more popular alternatives: [Hugs](http://www.haskell.org/hugs/) - Hugs is an interpreter (I don't think it includes a compiler) which...
I think it's also worth mentioning [nhc98](http://www.haskell.org/nhc98/). From the blurb on the homepage: > > nhc98 is a small, easy to install, > standards-compliant compiler for > Haskell 98, the lazy functional > programming language. It is very > portable, and aims to produce small > executables that run in...
4,084,790
AFAIK GHC is the most common compiler today, but I also see, that some other ompilers are available too. Is GHC really the best choice for all purposes or may I use something else instead? For instance, I read that some compiler (forgot the name) does better on optimizations, but doesn't implements all extensions.
2010/11/03
[ "https://Stackoverflow.com/questions/4084790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/417501/" ]
GHC is by far the most widely used Haskell compiler, and it offers the most features. There are other options, though, which sometimes have some benefits over GHC. These are some of the more popular alternatives: [Hugs](http://www.haskell.org/hugs/) - Hugs is an interpreter (I don't think it includes a compiler) which...
1. Haskell is informally defined as the language handled by GHC. 2. GHC is the compiler of the *Haskell platform*. 3. Trying to optimize your code with GHC may pay off more than switching to another compiler as you'll learn some optimization skills. 4. There are many *very* useful extensions in GHC. I just can't see ho...
4,084,790
AFAIK GHC is the most common compiler today, but I also see, that some other ompilers are available too. Is GHC really the best choice for all purposes or may I use something else instead? For instance, I read that some compiler (forgot the name) does better on optimizations, but doesn't implements all extensions.
2010/11/03
[ "https://Stackoverflow.com/questions/4084790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/417501/" ]
GHC is by far the most widely used Haskell compiler, and it offers the most features. There are other options, though, which sometimes have some benefits over GHC. These are some of the more popular alternatives: [Hugs](http://www.haskell.org/hugs/) - Hugs is an interpreter (I don't think it includes a compiler) which...
As of 2011, there's really no other choice than GHC for everyday programming. The HP team strongly encourages the use of GHC by all Haskell programmers. --- If you're a researcher, you might use be using UHC, if you're on a very strange system, you might have only Hugs or nhc98 available. If you're a retro-fan like m...
3,551
I have a chunk of text I need to paste into Illustrator. No matter what I do, I can't resize the text area without scaling the text. I want to resize the area and have the text wrap (font size to remain the same). How can I do this? I'm using CS5.1
2011/09/06
[ "https://graphicdesign.stackexchange.com/questions/3551", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/2357/" ]
Select your `Type` tool. Instead of clicking on your canvas, click and drag to draw a box. Put whatever copy you want inside the type box and when you resize the box it will reflow the text instead of changing the font. You can also link multiple type boxes together to flow text across multiple points on your artboard...
Here's a great article, **["Make Illustrator behave!"](http://www.creativepro.com/article/make-illustrator-behave-)** that explains it all in in full. Figuring out under what circumstances Illustrator scales the many types of text object and when it scales the bounding box, wrapping the text, is a common frustration....
3,551
I have a chunk of text I need to paste into Illustrator. No matter what I do, I can't resize the text area without scaling the text. I want to resize the area and have the text wrap (font size to remain the same). How can I do this? I'm using CS5.1
2011/09/06
[ "https://graphicdesign.stackexchange.com/questions/3551", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/2357/" ]
Select your `Type` tool. Instead of clicking on your canvas, click and drag to draw a box. Put whatever copy you want inside the type box and when you resize the box it will reflow the text instead of changing the font. You can also link multiple type boxes together to flow text across multiple points on your artboard...
OK, here goes. If you have already type some text using the type tool and selected this text using `Selection Tool`(the black arrow), you will see something like this ![enter image description here](https://i.stack.imgur.com/TM0x3.png) have you notice the rightmost circle? ![enter image description here](https://i...
3,551
I have a chunk of text I need to paste into Illustrator. No matter what I do, I can't resize the text area without scaling the text. I want to resize the area and have the text wrap (font size to remain the same). How can I do this? I'm using CS5.1
2011/09/06
[ "https://graphicdesign.stackexchange.com/questions/3551", "https://graphicdesign.stackexchange.com", "https://graphicdesign.stackexchange.com/users/2357/" ]
OK, here goes. If you have already type some text using the type tool and selected this text using `Selection Tool`(the black arrow), you will see something like this ![enter image description here](https://i.stack.imgur.com/TM0x3.png) have you notice the rightmost circle? ![enter image description here](https://i...
Here's a great article, **["Make Illustrator behave!"](http://www.creativepro.com/article/make-illustrator-behave-)** that explains it all in in full. Figuring out under what circumstances Illustrator scales the many types of text object and when it scales the bounding box, wrapping the text, is a common frustration....
21,816,154
I have a question about if a animation ends that it will like `gotoAndStop()` to another frame ``` if (bird.hitTestObject(pipe1)) { bird.gotoAndStop(3); //frame 3 = animation } ``` after it ends it will need to go the Game Over frame (frame 3) and I use the `Flash Timeline` not `.as` thanks!
2014/02/16
[ "https://Stackoverflow.com/questions/21816154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3316757/" ]
Java does not provide a convenient way to list the "files" in a "directory", when that directory is backed by a JAR file on the classpath (see [How do I list the files inside a JAR file?](https://stackoverflow.com/questions/1429172/how-do-i-list-the-files-inside-a-jar-file) for some work-arounds). I believe this is bec...
If you are still looking for an actual answer here is [mine](https://pastebin.com/R0jMh4ui) (it is kinda hacky but its work). To use it you simply have to call one of the 2 options below : ``` FileHandle[] fileList = JarUtils.listFromJarIfNecessary("Path/to/your/folder"); FileHandle[] fileList = JarUtils.listFromJa...
21,816,154
I have a question about if a animation ends that it will like `gotoAndStop()` to another frame ``` if (bird.hitTestObject(pipe1)) { bird.gotoAndStop(3); //frame 3 = animation } ``` after it ends it will need to go the Game Over frame (frame 3) and I use the `Flash Timeline` not `.as` thanks!
2014/02/16
[ "https://Stackoverflow.com/questions/21816154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3316757/" ]
Java does not provide a convenient way to list the "files" in a "directory", when that directory is backed by a JAR file on the classpath (see [How do I list the files inside a JAR file?](https://stackoverflow.com/questions/1429172/how-do-i-list-the-files-inside-a-jar-file) for some work-arounds). I believe this is bec...
What i do sometimes is to loop the "sounds" folder with a prefixed filename and a numbered suffix like this: ``` for(String snd_name : new String[]{"flesh_", "sword_", "shield_", "death_", "skating_", "fall_", "block_"}) { int idx = 0; FileHandle fh; while((fh = Gdx.files.internal("snd/" + (sn...
21,816,154
I have a question about if a animation ends that it will like `gotoAndStop()` to another frame ``` if (bird.hitTestObject(pipe1)) { bird.gotoAndStop(3); //frame 3 = animation } ``` after it ends it will need to go the Game Over frame (frame 3) and I use the `Flash Timeline` not `.as` thanks!
2014/02/16
[ "https://Stackoverflow.com/questions/21816154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3316757/" ]
If you are still looking for an actual answer here is [mine](https://pastebin.com/R0jMh4ui) (it is kinda hacky but its work). To use it you simply have to call one of the 2 options below : ``` FileHandle[] fileList = JarUtils.listFromJarIfNecessary("Path/to/your/folder"); FileHandle[] fileList = JarUtils.listFromJa...
What i do sometimes is to loop the "sounds" folder with a prefixed filename and a numbered suffix like this: ``` for(String snd_name : new String[]{"flesh_", "sword_", "shield_", "death_", "skating_", "fall_", "block_"}) { int idx = 0; FileHandle fh; while((fh = Gdx.files.internal("snd/" + (sn...
3,197,405
I got the following crash logs after my app crashes: ``` 0 libobjc.A.dylib 0x000034f4 objc_msgSend + 20 1 UIKit 0x000a9248 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 644 2 UIKit 0x000a8eac -[UITableView(...
2010/07/07
[ "https://Stackoverflow.com/questions/3197405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27404/" ]
My best guess would be that something isn't linking correctly in one of you .xib views. Another common cause of this is an object being called upon that's already been released from memory. Try tracing this with `NSZombieEnabled`
You're missing a connection between an xib and its controller.
22,953,075
I am using jQuery mobile 1.4.2. I need to shift the search icon from left to right and how can I avoid the clear button appearing. ``` <div data-role=page"> <form method="post"> <input name="search" id="search" value="" placeholder="Buscar" type="search" onfocus="this.placeholder = ''" onblur="this.placeho...
2014/04/09
[ "https://Stackoverflow.com/questions/22953075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3350169/" ]
The constructor is `new Rect(left,top,width,height)` Any fewer arguments will result in those many fields not being set. eg. `new Rect(1,2,3)` will return a Rect object with no height Screenshot here : <http://puu.sh/81KSa/e225064bec.png>
The `Rect` in your jsfiddle is **NOT** the Mozilla `Rect` object. [What is Rect function in Chrome/Firefox for?](https://stackoverflow.com/questions/18814683/what-is-rect-function-for-in-javascript) The Mozilla `Rect` is provided by <https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Geometry.jsm...
70,504,314
I have some code which captures a key. Now i have in event.code the real key-name and in event.key i get the key-char. To make an example: I press SHIFT and J, so i get: *event.code: SHIFT KEYJ* *event.key: J* So, i get in event.key the "interpreted key" from shift J. But now i need to convert the native key to a cha...
2021/12/28
[ "https://Stackoverflow.com/questions/70504314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17779252/" ]
Solution was the H2 version. We upgraded also H2 to 2.0 but that version is not compatible with Spring Batch 4.3.4. Downgrade to H2 version 1.4.200 solved the issue.
`MODE=LEGACY` will solve the issue on H2 2.x with Spring boot 2.6.x. (`nextval` support will be re-enabled) See the details: <https://github.com/spring-projects/spring-boot/issues/29034#issuecomment-1002641782>
11,240,180
I want to run a .exe file (or) any application from pen drive on insert in to pc. I dont want to use Autorun.inf file, as all anti virus software's blocks it. I have used portable application launcher also, that also using autorun only. so once again anti virus software blocks it. Is there any alternative option, such ...
2012/06/28
[ "https://Stackoverflow.com/questions/11240180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1487797/" ]
Anti-virus programs block autorun.inf on the solely purpose not to allow some .exe-s to start automatically on pen drive insert. So, basically, what you're asking is impossible.
I havent used Windows in a long time, but I am fairly sure there is a setting in Windows to enable/disable autorunning executeables on mounted drives. That and changing such setting in your antivirus application (or get a new, saner one) would be my best guess. Good luck!
1,712,401
Here is what I have so far: Let $\varepsilon > 0$ be given We want for all $n >N$, $|1/n! - 0|< \varepsilon$ We know $1/n <ε$ and $1/n! ≤ 1/n < ε$. I don't know how to solve for $n$, given $1/n!$. And this is where I get stuck in my proof, I cannot solve for $n$, and therefore cannot pick $N > \cdots$.
2016/03/25
[ "https://math.stackexchange.com/questions/1712401", "https://math.stackexchange.com", "https://math.stackexchange.com/users/325725/" ]
Since $0 < \frac{1}{n!} < \frac{1}{n}$, by the squeeze theorem... Without squeeze theorem: Let $\epsilon > 0$. Define $N = \epsilon^{-1}$. Then if $n > N$, $$\left|\frac{1}{n!}\right| = \frac{1}{n!} < \frac{1}{n} < \frac{1}{N} = \epsilon$$
You don't need to *solve for* $n$, just to find *some* $n$ that is large enough that $1/n!$ is smaller than $\varepsilon$. It doesn't matter if you find an $N$ that is much larger than it *needs to be*, as long as it is finite. By the hint that $1/n! \le 1/n$, therefore, it is enough to find an $N$ that is large enoug...
1,712,401
Here is what I have so far: Let $\varepsilon > 0$ be given We want for all $n >N$, $|1/n! - 0|< \varepsilon$ We know $1/n <ε$ and $1/n! ≤ 1/n < ε$. I don't know how to solve for $n$, given $1/n!$. And this is where I get stuck in my proof, I cannot solve for $n$, and therefore cannot pick $N > \cdots$.
2016/03/25
[ "https://math.stackexchange.com/questions/1712401", "https://math.stackexchange.com", "https://math.stackexchange.com/users/325725/" ]
Since $0 < \frac{1}{n!} < \frac{1}{n}$, by the squeeze theorem... Without squeeze theorem: Let $\epsilon > 0$. Define $N = \epsilon^{-1}$. Then if $n > N$, $$\left|\frac{1}{n!}\right| = \frac{1}{n!} < \frac{1}{n} < \frac{1}{N} = \epsilon$$
How about this one: $$\sum\_{n=0}^{\infty}\frac{1}{n!}=e^1=e.$$ Thus the series converges and therefore $$\lim\_{n\to \infty}\frac{1}{n!}=0.$$
5,637,808
I got my first android phone since two week And I'm starting my first real App. My phone is a LG Optimus 2X and one of the missing thing is a notification led for when there is a missed call, sms, email ect ... So I'm wondering what's the best way to do this. For know I've a broatcastreceiver for incoming sms, and th...
2011/04/12
[ "https://Stackoverflow.com/questions/5637808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/704403/" ]
``` UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(myCallback:)]; self.navigationItem.rightBarButtonItem = addButton; [addButton release]; ```
Yes, that `[+]` button is a default button, provided by Apple. It is the `UIBarButtonSystemItemAdd` identifier. Here's some code to get it working: ``` // Create the Add button UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(som...
151,322
Recently, I read a lot of good articles about how to do good encapsulation. And when I say "good encapsulation", I am not talking about hiding private fields with public properties; I am talking about preventing users of your API from doing wrong things. Here are two good articles about this subject: <http://blog.plo...
2012/06/02
[ "https://softwareengineering.stackexchange.com/questions/151322", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/44035/" ]
Answer: When you have your interface complete, then automatically you are done with encapsulation. It does not matter if implemenation or consumption part is incomplete, you are done since interface is accepted as final. **Proper development tools should reduce cost more than tools cost themself.** You suggest that i...
Encapsulation exists to protect your class invariants. This is the primary measure for 'how much is enough'. Any way to break invariants breaks class semantics and is bad (tm). A secondary concern is limiting visibility and as such the number of places that can/will access data and thus increase coupling and/or number...
151,322
Recently, I read a lot of good articles about how to do good encapsulation. And when I say "good encapsulation", I am not talking about hiding private fields with public properties; I am talking about preventing users of your API from doing wrong things. Here are two good articles about this subject: <http://blog.plo...
2012/06/02
[ "https://softwareengineering.stackexchange.com/questions/151322", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/44035/" ]
The fact that your code is not being written as a public API is not really the point--the maintainability you mention is. Yes, application development is a cost center, and the customer does not want to pay for unnecessary work. However, a badly designed or implemented application is going to cost the customer a lot m...
Encapsulation exists to protect your class invariants. This is the primary measure for 'how much is enough'. Any way to break invariants breaks class semantics and is bad (tm). A secondary concern is limiting visibility and as such the number of places that can/will access data and thus increase coupling and/or number...
14,790,045
I am trying to insert a new column into a CSV file after existing data. For example, my CSV file currently contains: ``` Heading 1 Heading 2 1 1 0 2 1 0 ``` I have a list of integers in format: ``` [1,0,1,2,1,2,1,1] ``` **How can i insert this list into the CSV file under 'Header 2'?** ...
2013/02/09
[ "https://Stackoverflow.com/questions/14790045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987845/" ]
I guess this question is already kind of old but I came across the same problem. Its not any "best practice" solution but here is what I do. In `twig` you can use this `{{ path('yourRouteName') }}` thing in a perfect way. So in my `twig` file I have a structure like that: ``` ... <a href="{{ path('myRoute') }}">...
Since this jQuery ajax function is placed on twig side and the url points to your application you can insert routing path ``` $.ajax({ url: '{{ path("your_ajax_routing") }}', data: "url="+urlinput, dataType: 'html', timeout: 5000, success: function(data, status){ // DO Stuff here } });...
14,790,045
I am trying to insert a new column into a CSV file after existing data. For example, my CSV file currently contains: ``` Heading 1 Heading 2 1 1 0 2 1 0 ``` I have a list of integers in format: ``` [1,0,1,2,1,2,1,1] ``` **How can i insert this list into the CSV file under 'Header 2'?** ...
2013/02/09
[ "https://Stackoverflow.com/questions/14790045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987845/" ]
I ended up using the jsrouting-bundle Once installed I could simply do the following: ``` $.ajax({ url: Routing.generate('urlgetter'), data: "url="+urlinput, dataType: 'html', timeout: 5000, success: function(data, status){ // DO Stuff here } }); ``` where urlgetter is a route defined ...
Since this jQuery ajax function is placed on twig side and the url points to your application you can insert routing path ``` $.ajax({ url: '{{ path("your_ajax_routing") }}', data: "url="+urlinput, dataType: 'html', timeout: 5000, success: function(data, status){ // DO Stuff here } });...
24,923,412
I am attempting to use Tkinter for the first time on my computer, and I am getting the error in the title, "NameError: name 'Tk' is not defined", citing the "line root = Tk()". I have not been able to get Tkinter to work in any form. I am currently on a macbook pro using python 2.7.5. I have tried re-downloading python...
2014/07/24
[ "https://Stackoverflow.com/questions/24923412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3871003/" ]
You have some other module that is taking the name "Tkinter", shadowing the one you actually want. Rename or remove it. ``` import Tkinter print Tkinter.__file__ ```
your code is right but the indent is wrong in the import code, instead of using one space use two spaces and try to not type this command: ``` import tkinter ``` use this code: ``` from tkinter import * root = Tk() canvas = Canvas(root, width=300, height=200) canvas.pack() canvas.create_rectangle( 0, 0, 150, 15...
24,923,412
I am attempting to use Tkinter for the first time on my computer, and I am getting the error in the title, "NameError: name 'Tk' is not defined", citing the "line root = Tk()". I have not been able to get Tkinter to work in any form. I am currently on a macbook pro using python 2.7.5. I have tried re-downloading python...
2014/07/24
[ "https://Stackoverflow.com/questions/24923412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3871003/" ]
You have some other module that is taking the name "Tkinter", shadowing the one you actually want. Rename or remove it. ``` import Tkinter print Tkinter.__file__ ```
Please make sure your Python file name is not "tkinter.py", or it will show this error.
24,923,412
I am attempting to use Tkinter for the first time on my computer, and I am getting the error in the title, "NameError: name 'Tk' is not defined", citing the "line root = Tk()". I have not been able to get Tkinter to work in any form. I am currently on a macbook pro using python 2.7.5. I have tried re-downloading python...
2014/07/24
[ "https://Stackoverflow.com/questions/24923412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3871003/" ]
Please make sure your Python file name is not "tkinter.py", or it will show this error.
your code is right but the indent is wrong in the import code, instead of using one space use two spaces and try to not type this command: ``` import tkinter ``` use this code: ``` from tkinter import * root = Tk() canvas = Canvas(root, width=300, height=200) canvas.pack() canvas.create_rectangle( 0, 0, 150, 15...
280,990
I have a list: ``` \begin{enumerate}[label={[\Roman*]},ref={[\Roman*]}] \item\label{item1} The first item. \end{enumerate} ``` What I want to achieve is this: In the most instances, I want to refer to the items of the list by the format specified above (that is: `\ref{item1}` should in general produce "[I]"). Ho...
2015/12/01
[ "https://tex.stackexchange.com/questions/280990", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/93296/" ]
Define `ref=` to use a macro, instead of the explicit brackets; such a macro can be redefined to do nothing when the brackets are not wanted. ``` \documentclass{article} \usepackage{enumitem,xparse} \usepackage[colorlinks]{hyperref} \makeatletter \NewDocumentCommand{\nobracketref}{sm}{% \begingroup\let\bracketref\@...
Here's a LuaLaTeX-based solution. It sets up a LaTeX macro called `\nobracketref` which, in turn, invokes a Lua function called `nobrackets` which removes the outermost brackets in the function's argument. Observe that the Lua function tests whether the cross-reference is valid. If it is not valid, i.e., if `\ref` re...
280,990
I have a list: ``` \begin{enumerate}[label={[\Roman*]},ref={[\Roman*]}] \item\label{item1} The first item. \end{enumerate} ``` What I want to achieve is this: In the most instances, I want to refer to the items of the list by the format specified above (that is: `\ref{item1}` should in general produce "[I]"). Ho...
2015/12/01
[ "https://tex.stackexchange.com/questions/280990", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/93296/" ]
Define `ref=` to use a macro, instead of the explicit brackets; such a macro can be redefined to do nothing when the brackets are not wanted. ``` \documentclass{article} \usepackage{enumitem,xparse} \usepackage[colorlinks]{hyperref} \makeatletter \NewDocumentCommand{\nobracketref}{sm}{% \begingroup\let\bracketref\@...
You have a couple of options: 1. Remove the brackets using a delimited argument. 2. Create a new `\label` that uses `\Roman` instead of `[\Roman]`. The first option is implemented by means of your `\nobracketsref{<label>}` choice. The second option is implemented by means of a `\speciallabel{<what>}{<label>}`. `<what...
1,556,700
there is a page ($9\times 9$) how many different rectangles can you draw with odd area? rectangles are different if they are different on size and place. for example if a rectangle is $15$ squares, its area is odd. if a rectangle is $12$ squares, its area is even. I have no idea how to approach this question so I c...
2015/12/02
[ "https://math.stackexchange.com/questions/1556700", "https://math.stackexchange.com", "https://math.stackexchange.com/users/295268/" ]
If the area has to be odd, the length and breadth both have to be odd. Hence, we count the number of rectangles by first choosing a row and a column ($10 \cdot 10$ ways to do this), and then choosing another row and column which are at an odd distance from the chosen one ($5 \cdot 5$ ways to do this). But we have count...
the number of squares with equal dimensions is $81$. so if number of squares is odd then the rectangle has an odd area. the total rectangles are given by ${10 \choose 2}.{10 \choose 2}=2025$ . you have rectangles now you just need to select two lines which are odd distances apart from each other . and its done. hope it...
31,633,191
What is the best way of removing element from a list by either a comparison to the second list or a list of indices. ``` val myList = List(Dog, Dog, Cat, Donkey, Dog, Donkey, Mouse, Cat, Cat, Cat, Cat) val toDropFromMylist = List(Cat, Cat, Dog) ``` Which the indices accordance with myList are: ``` val indices = Li...
2015/07/26
[ "https://Stackoverflow.com/questions/31633191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79147/" ]
Something like this should do the trick: ``` myList .indices .filter(!indices.contains(_)) .map(myList) ```
This works: ``` myList .zipWithIndex .collect{case (x, n) if !indices.contains(n) => x} ``` Here's a complete, self-contained REPL transcript showing it working: ``` scala> case object Dog; case object Cat; case object Monkey; case object Mouse; case object Donkey defined object Dog defined object Cat defined o...
31,633,191
What is the best way of removing element from a list by either a comparison to the second list or a list of indices. ``` val myList = List(Dog, Dog, Cat, Donkey, Dog, Donkey, Mouse, Cat, Cat, Cat, Cat) val toDropFromMylist = List(Cat, Cat, Dog) ``` Which the indices accordance with myList are: ``` val indices = Li...
2015/07/26
[ "https://Stackoverflow.com/questions/31633191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79147/" ]
Using `toDropFromMylist` is actually the simplest. ``` scala> myList diff toDropFromMylist res0: List[String] = List(Dog, Donkey, Dog, Donkey, Mouse, Cat, Cat, Cat) ```
This works: ``` myList .zipWithIndex .collect{case (x, n) if !indices.contains(n) => x} ``` Here's a complete, self-contained REPL transcript showing it working: ``` scala> case object Dog; case object Cat; case object Monkey; case object Mouse; case object Donkey defined object Dog defined object Cat defined o...
31,633,191
What is the best way of removing element from a list by either a comparison to the second list or a list of indices. ``` val myList = List(Dog, Dog, Cat, Donkey, Dog, Donkey, Mouse, Cat, Cat, Cat, Cat) val toDropFromMylist = List(Cat, Cat, Dog) ``` Which the indices accordance with myList are: ``` val indices = Li...
2015/07/26
[ "https://Stackoverflow.com/questions/31633191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79147/" ]
Using `toDropFromMylist` is actually the simplest. ``` scala> myList diff toDropFromMylist res0: List[String] = List(Dog, Donkey, Dog, Donkey, Mouse, Cat, Cat, Cat) ```
Something like this should do the trick: ``` myList .indices .filter(!indices.contains(_)) .map(myList) ```
233,158
I am working on a web api and I am curios about the `HTTP SEARCH` verb and how you should use it. My first approach was, well you could use it surely for a search. But asp.net WebApi doesn't support the `SEARCH` verb. My question is basically, should I use `SEARCH` or is it not important? PS: I found the `SEARCH` ve...
2014/03/21
[ "https://softwareengineering.stackexchange.com/questions/233158", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/82918/" ]
The HTTP protocol is defined by RFC documents. RFC2616 defines HTTP/1.1 the current release. SEARCH is not documented as a verb in this document.
AFAIK the `SEARCH` method is only a proposal and should not be used. Use `GET` instead.
3,639,718
I recreated a Select box and its dropdown function using this: ``` $(".selectBox").click(function(e) { if (!$("#dropDown").css("display") || $("#dropDown").css("display") == "none") $("#dropDown").slideDown(); else $("#dropDown").slideUp(); e.preventDefault(); }); ``` The only problem is ...
2010/09/03
[ "https://Stackoverflow.com/questions/3639718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324529/" ]
You also need to stop a click from *inside* the `#dropdown` from bubbling back up to `body`, like this: ``` $(".selectBox, #dropdown").click(function(e) { e.stopPropagation(); }); ``` We're using [`event.stopPropagation()`](http://api.jquery.com/event.stopPropagation/) it stops the click from bubbling up, causing...
Since you are setting an event handler that catches every click, you don't need another one on a child. ``` $(document).click(function(e) { if ($(e.target).closest('.selectBox').length) { $('#dropdown').slideToggle(); return false; } else { $('#dropdown:visible').slideUp(); } }); `...
28,429,768
Lets say I have a `ItemsControl`which is used to render buttons for a list of viewModels ``` <ItemsControl ItemsSource="{Binding PageViewModelTypes}"> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="{Binding Name}" CommandParameter="{Binding }"...
2015/02/10
[ "https://Stackoverflow.com/questions/28429768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/931051/" ]
Bind the button content to the item content and your templates will be resolved to the actual types: ``` <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="{Binding}" CommandParameter="{Binding }" /> </DataTemplate> </ItemsControl.ItemTemplate> ```
Unfortunately, your question is not at all clear. The most common scenario that could fit the vague description you've provided is to have each item in the `ItemsControl` displayed using a `DataTemplate` that corresponds to that type. Let's call that `Option A`. But the statement: > > replacing the `PageViewModelTy...
39,070,614
Here is a program about the Fibonacci sequence. Each time the code branches off again you are calling the fibonacci function from within itself two times. ``` def fibonacci(number) if number < 2 number else fibonacci(number - 1) + fibonacci(number - 2) end end puts fibonacci(6) ``` The only thing I u...
2016/08/22
[ "https://Stackoverflow.com/questions/39070614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is just the direct 1:1 translation (with a simple twist) of the standard mathematical definition of the Fibonacci Function: ``` Fib(0) = 0 Fib(1) = 1 Fib(n) = Fib(n-2) + Fib(n-1) ``` Translated to Ruby, this becomes: ``` def fib(n) return 0 if n.zero? return 1 if n == 1 fib(n-2) + fib(n-1) end ``` It's...
I don't really know which part baffles you but let me try. In the graph, a function f() denotes your fibonacci() and f(1) and f(0) are pre-defined as 1 and 0. As f(number) comes from f(number - 1) + f(number - 2) in your number = 2, f(2) = f(2 - 1) + f(2 - 2) = 1 + 0 = 1. Likewise, you can get f(3) = f(3 - 1) + ...