Posts by rodrigorgs • 6,635 points
50 posts
-
1
votes1
answer83
viewsA: EAD: Configuration error while running tests
According to the Demoiselle reference 2.4.2: Starting from version 2.4.0 (...) the parameters will be searched exactly as they were defined in the configuration class. Therefore, the configuration…
-
3
votes1
answer248
viewsA: How to insert data for graphing in ggplot
Only the parentheses were left after geom_point, since geom_point is a function you should call: ggplot(dados, aes(x=Ano,y=a)) + geom_point()…
-
2
votes1
answer108
viewsA: What are the advantages of working directly with stdin, stdout and stderr?
To answer your question, let’s understand what your problem is and what the alternative solutions are. Your problem is to transfer data between two processes, R and Python. Here are some solutions…
-
5
votes2
answers381
viewsA: Create new matrix from a fairly large first efficiently
You can use the library dplyr to make your code simpler and at the same time more efficient: library(dplyr) Data <- data.frame(Casa=c(1,1,1,1,2,2,2,3,3,3,3), Escola=c(1,1,2,2,1,2,1,1,1,1,1))…
-
5
votes2
answers472
viewsA: Create columns in R from another where some values are null
You can use the function na.locf package zoo. Example: library(zoo) x <- c(1, NA, NA, 2, NA, 3, 4) na.locf(x) Upshot: [1] 1 1 1 2 2 3 4…
ranswered rodrigorgs 6,635 -
3
votes1
answer250
viewsA: Applying Loop to Elements of a Matrix (R)
Use the function cut to encode the values according to the range they fit, and then convert the result to number: c <- cut(simu_matrix, breaks=c(0.0, 0.1, 0.4, 0.7, 0.9, 1.0))…
-
3
votes2
answers2857
viewsA: Compare 2 Matrices and Return a Third (R)
Answer C <- ifelse(B <= A, 1, 0) Explanation The operator <= is vectorized: it returns the comparison result (TRUE or FALSE) between corresponding elements of the vectors or matrices…
-
3
votes1
answer4059
viewsA: How to run the current line in Sublime Text 2? Or, IDE that allows running the current line in Python
Yes, it is possible with the package Sublimerepl, that allows you to run interpreters of several languages within the editor itself. Open a Python interpreter (Tools > SublimeREPL > Python…
-
5
votes1
answer829
viewsA: R workflow: strategies to organize a data analysis project
I have work in projects that involve the integration of various data sources, data transformation and reporting. Scripts are mostly in R, but sometimes I resort to other languages. I have created…
-
8
votes2
answers2443
viewsA: How to smooth a curve in R
It is better to interpolate the dots using splines: sp <- data.frame(spline(log10(df$x), df$y, n = 8*nrow(df))) sp$x <- 10 ** sp$x ggplot(data = df, aes(x, y)) + scale_x_log10() + geom_point()…
-
2
votes2
answers601
viewsA: How to change the location where MAMP creates the database?
I think the most practical thing is that you create a symbolic link in /Applications/MAMP/db pointing to /Volumes/Sites. If the folder db has already been created, move it first to destination: mv…
-
6
votes1
answer363
viewsA: Continue running the loop even if a passage gives problem
Use the function try. Your code will look like this: for (i in tickers) { try(getSymbols(i,src="yahoo")) } The function try evaluates the expression passed as parameter and captures any error that…
-
3
votes3
answers180
viewsA: How to include a variable high to n in regression
Use model1 <- lm(y ~ x + I(x^2)). The problem is that characters like +, -, * and ^ have specific meanings within a formula; the function I makes his expression (x^2) be taken literally, as…
-
2
votes6
answers1639
viewsA: Remove an undetermined number of " " in a column in the database
You can run the following query several times until it no longer changes any record: UPDATE product SET description = REPLACE(description, '\\\\', '\\') WHERE description LIKE '%\\\\\\\\%' Mysql…
-
3
votes2
answers659
viewsQ: How to use Quartz Scheduler with Demoiselle?
I created a job using Quartz Scheduler within a Java web application that uses the Demoiselle framework with JSF and Tomcat 7. The job must call a Business Controller (BC) method, which calls a DAO…
-
1
votes2
answers659
viewsA: How to use Quartz Scheduler with Demoiselle?
In the most common cases, the BC code is called from a Managed bean (MB) whose execution was originated by an HTTP request made by the web browser. In such cases, there is an active Requestcontext…
-
8
votes4
answers379
viewsA: What types of retain Cycles can be generated with ARC?
The main problem related to memory is the cycles of retain. They occur when an object has a pointer strong for a second object, and this has a pointer strong to the former. Even when all references…
-
9
votes1
answer239
viewsA: What is the Runloop?
All thread has a loop run (instance of NSRunLoop), who is responsible for handling events, such as a touch of the screen or the execution of a method scheduled with NSTimer. According to the…
-
2
votes2
answers1138
viewsA: Implementation Angularjs consuming data provided from Laravel using CORS
To enable CORS (exchange of data between different servers using AJAX), you need to make modifications to your client (Angularjs) and your server (Laravel). Client (Angularjs) In your Angularjs…
-
2
votes6
answers5183
viewsA: How to reverse the position of a div(and its content and attributes) with another div?
If elements are neighboring, use insertBefore: $('#div3').insertBefore($('#div2')); Example Executable example: http://jsfiddle.net/rodrigorgs/uya47/ Explanation To jQuery documentation clarifies:…
-
19
votes4
answers18077
viewsA: How to organize auto-increment numbering of a column Id of a table in Mysql?
You can use the following: SET @count = 0; UPDATE `tabela` SET `tabela`.`id` = @count:= @count + 1; Full example: http://sqlfiddle.com/#! 2/750ce/1 (Source:…
-
9
votes1
answer806
viewsA: How to get values from a column of multiple tables displayed on a web page?
Open the Chrome console (Ferramentas > Console Javascript) and write the following: $x("//tr[position() > 1]/td[2]/p/span/text()") This will call the Javascript function $x (set to the Chrome…
htmlanswered rodrigorgs 6,635 -
3
votes3
answers14753
viewsA: How do I remove a folder from Git’s history?
Adapting the command specified in Chapter. 9.7 of the book Pro Git: $ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch nome-do-arquivo-ou-diretorio' Note that since the command…
gitanswered rodrigorgs 6,635 -
122
votes6
answers12507
viewsA: Why shouldn’t we use mysql_* functions?
Because the use of functions mysql_* was frowned upon (deprecated) from PHP 5.5 and, according to the documentation, functions will be removed in future versions of PHP, causing the programs that…
-
64
votes5
answers28367
viewsA: When to use self vs $this in PHP?
In a simplified form, $this refers to the current object (instance), and self refers to the class. Therefore, as a general rule, $this to access members (attributes, methods) of the instance and…
-
7
votes4
answers15336
viewsA: In Git, how do I edit the description of a commit already made?
If it’s the last commit, use git commit --amend -m "Nova mensagem". It is not recommended to do this if you have already given one push of the commit.
-
5
votes2
answers364
viewsA: HTML zebra table with Ext JS
According to that page, pair lines of a grid have the CSS class x-grid-row-alt. So, you just set in your CSS different colors for the classes x-grid-row and x-grid-row-alt: x-grid-row .x-grid-cell {…
-
9
votes1
answer7768
viewsA: When to use a Unique constraints vs unique indices on Oracle?
Oneness of data To ensure the uniqueness of the data, there is no practical difference in most cases. A Unique Constraint is almost always implemented as a Unique index, and a Unique index prevents…
-
3
votes2
answers313
viewsA: Database on does not reflect changes in the same Activity
You are capturing the exception in the method testar() and returning false. With that, your SELECT may be crashing but program execution is not interrupted and no error message is displayed.…
-
5
votes1
answer492
viewsA: Error with Package Control Sublimetext 2
You will need to install the Git, if not already installed. Then go to the menu Preferences > Package Settings > Package Control > Settings > User, and edit the file to add the item…
-
7
votes1
answer1407
viewsA: How to return via PHP several JSON messages, each of which is fired at different times?
If I understand correctly, you use three instructions to return the JSON: echo json_encode($retorna1); echo json_encode($retorna2); echo json_encode($retorna3); Each json_encode is generating an…
-
16
votes3
answers1932
viewsA: Is there a more efficient way to create an array from another array dynamically, filtering the contents of the first one?
You can filter the values using an expression in the index: import numpy as np a = np.array ( [1, 2, np.nan, 4] ) # Filtra NaN filtrado = a[~np.isnan(a)] The expression np.isnan(a) returns a vector…
-
7
votes1
answer4590
viewsA: How to resize graphics in Ipython Notebook without loss of quality?
Instead of producing graphics in PNG (bitmap image format), you can configure Ipython Notebook to produce graphics in SVG (vector format), which does not lose the definition. You can change the…
-
6
votes2
answers531
viewsA: Association with scope in Ruby on Rails
According to this discussion on Github, this is a bug of Rails 4.0, which was fixed in version 4.0.1. By updating your Rails, you can include the readonly(false) within its scope and will work:…
-
4
votes1
answer7167
viewsQ: How to count the cumulative number of occurrences of an element in a vector?
Suppose I have a vector in R: x <- c("a", "a", "b", "a", "b", "c") I need to determine for each position i of the vector, how many times the element x[i] appeared until then. The result for the…
rasked rodrigorgs 6,635 -
3
votes1
answer7167
viewsA: How to count the cumulative number of occurrences of an element in a vector?
It is possible to use the function ave as follows: contagem <- ave(rep(1, length(x)), x, FUN=cumsum) First, a vector containing only numbers 1 is generated, the size of the input vector (rep(1,…
ranswered rodrigorgs 6,635 -
1
votes1
answer1706
viewsA: Working with SVG files dynamically
Firefox yet does not support CSS filters. Therefore, to increase compatibility, you must create a -webkit-filter to work on Chrome, Safari and other Webkit-based browsers, and an equivalent SVG…
-
13
votes3
answers4221
viewsA: Take only the values before the character "=" using regular expression?
Use ^[^=]*, which will recognize an uninterrupted sequence of different characters from = at the beginning of the line. Parts: ^: acknowledges the start of the line; [^=]: recognizes a character…
-
1
votes8
answers17582
viewsA: Use Bootstrap and Primefaces without one interfering with the other?
If you are only using Bootstrap for the visuals, you can use the Bootstrap theme from Primefaces: http://blog.primefaces.org/? p=2139 To activate the Bootstrap theme, modify the following files…
-
1
votes2
answers1264
viewsA: Accentuation of request parameter in JSF page
From what I understand, Tomcat decodes GET parameters using ISO-8859-1. As I do not have access to the server configuration, I adopted an outline solution. I created a convert to turn into UTF-8:…
-
1
votes4
answers10238
viewsA: Problem using paragraphs in JSON file
Assuming you are using quotes in your JSON file, use \\n for line breaking. The JSON format requires certain special characters, such as line break, to be "escaped" using \. Therefore, to produce…
-
5
votes6
answers2089
viewsA: How to change the bottom lines of a table alternately? With support for older browsers
You can use CSS: /* linhas ímpares */ table tr:nth-child(odd) td { background-color: #fff; } /* linhas pares */ table tr:nth-child(even) td { background-color: #ccc; } However, the user must use at…
-
66
votes1
answer24387
viewsA: What is the difference in the use of Return false, Event.stopPropagation() and Event.preventDefault()?
Return false in a jQuery event Handler is the same thing as calling event.preventDefault() and event.stopPropagation() (where event is the object received as parameter). So: event.preventDefault()…
-
6
votes8
answers48170
viewsA: How to calculate a person’s age in SQL Server?
You can pick up today’s date using getdate() and subtract the bank record date using DATEDIFF: SELECT DATEDIFF(hour, DataNascimento, getdate()) / 8766 FROM Pessoa 8766 is the number of hours in a…
-
8
votes4
answers107040
viewsA: What is the difference between public, default, protected and private modifiers?
Suppose you have a class Animal and a subclass Gato, who inherits from Animal. In class Gato, you can call all methods Animal declared as public or protected, and if the classes are in the same…
-
55
votes5
answers20362
viewsQ: Is there an algorithm to check the validity of a ID number in Brazil using check digits?
Is there an algorithm to check the validity of a RG number in Brazil using check digits, as with the CPF? If yes, how is this algorithm?
-
9
votes4
answers1446
viewsQ: Load file to current directory when running irb
It is possible to call irb by passing a library to be loaded as parameter (required): irb -r date But this does not work if I want to load a file in the directory where the command runs: irb -r…
-
17
votes5
answers74978
viewsA: How to get the table name and attributes of a Mysql database?
You can use the query: SELECT * FROM information_schema.tables WHERE table_schema = 'nome-do-banco'; It shows the table names and also information like the engine used, creation date, etc.…
-
55
votes2
answers39510
viewsQ: How to remove accents and other graphic signals from a Java String?
How to remove accents and other graphic signals from a Java String? Ex.: String s = "maçã"; String semAcento = ???; // resultado: "maca"…
-
5
votes2
answers1264
viewsQ: Accentuation of request parameter in JSF page
I have a JSF page that receives as a parameter, in the URL, the error message to be displayed. Ex.: http://example.com/application_error.jsf?exception=Não+permitido On the page, the parameter is…