Posts by Pedro Vinícius • 1,870 points
71 posts
-
3
votes1
answer95
viewsQ: What is the difference between Observables and common Javascript events?
I have seen a lot of people talking about Observables and about Pattern Observer in general, mainly from the Rx JS library. What is the difference between Observers and the events we usually treat,…
-
4
votes3
answers1915
viewsQ: What are [ ] bash for?
I’m starting shell script now, and often, reading other people’s programs, I see the use of [] associated with if. For example: if [condition]; then fi I have often seen the use as follows: if…
-
1
votes2
answers174
viewsQ: How to send commands to the ruby interpreter from a Shell Script?
This is more out of curiosity... I’ve seen some examples of what I want to do, but in Perl. I tried to find a way to do the same in Ruby, but to no avail. I want a function to generate an MD5 hash…
-
1
votes2
answers389
viewsQ: MD5 is good enough?
I’m working on a legacy system, which has a database with about five years of accumulated records with no normalization. Among other things, its purpose is to allow users to write and post posts in…
-
0
votes1
answer102
viewsQ: What are the options for Rest?
Presently the Rest architecture has become a standard for building API’s and Webservices. But what about beyond Rest? What more there is aimed at building API’s?
-
8
votes2
answers2357
viewsQ: Why is it necessary to use bind when working with ES6 and Reactjs?
Using ES5 in Reactjs development, a component can be declared as follows: var MyComponent = React.createClass({ alertSomething: function(event) { alert(event.target); }, render: function() { return…
-
0
votes2
answers75
viewsQ: How to pass an Array to the IN clause of a flat query?
I am using Activerecord to run queries in several different databases. In one of the queries, I have to do the following: publications_to_read = [1,2,3,4]…
-
1
votes1
answer201
viewsQ: How to measure the amount of disk space required for an ALTER TABLE operation?
I need to make some changes to one of the tables to add new columns. The problem is that I cannot do it. I get the following error: PG::Diskfull: ERROR: could not extend file…
-
4
votes2
answers235
viewsQ: Why don’t all commands work with pipe?
I’m intrigued by the fact that kill and some other commands do not work with pipe. For example, I tried cat /tmp/server.pid | kill -9 and it didn’t work. Searching some forums in English I found the…
-
1
votes1
answer110
viewsQ: Should I use foreign_key in both has_many and belongs_to?
I have two models. Office and Employee. Employee has office_id as foreign key. So, which is correct? class Office < ActiveRecord::Base has_many :employees, foreign_key: 'office_id' end class…
-
1
votes2
answers1124
viewsQ: How to rewrite correctly on Nginx?
I’m having trouble setting up Nginx as a reverse proxy in an application. It’s a Rails application that runs on Unicorn. In case, I have the mastery http://www.meudominio.com.br. Instead of creating…
-
4
votes1
answer976
viewsQ: How do I make an application available only on my wireless network?
I’m developing an app, and I want it to only be available to devices connected to my Wi-Fi network. I can even leave running on my personal computer and access via ip, something like…
-
1
votes0
answers45
viewsQ: How to direct Submit from a form to the method of a Wordpress plugin?
I am studying Wordpress, and to exercise I am developing a theme and a plugin. The goal is to use a contact form in the theme, that instead of sending the data by email, as usually done, make the…
-
3
votes2
answers1523
viewsQ: How do asymmetric signatures work in JSON Webtokens (JWT)?
I recently started to study the possibility of starting to use JSON Webtokens in my projects, given their advantages. From what I understand, there is a symmetrical form and an asymmetric way of…
-
0
votes1
answer155
viewsQ: Error executing a Rake Task
I need to perform some custom tasks, but whenever I try, I get the following message: Application has been already initialized. I searched several places, including the OS in English, but without…
-
2
votes1
answer261
viewsQ: jQuery UI autocomplete only works once
I am working on a functionality of a Rails application where we use a Gem call Best in Place, which provides the possibility of inline editing of model attributes. But there was a need to use jQuery…
-
6
votes1
answer890
viewsQ: How to maintain multiple connections with postgresql in Node.js?
I am used Node.js in a task where I need to migrate data between two Postgresql databases. The idea is more or less the following: Connect to Bank A. Connect to Bank B. Return all records from A.…
-
3
votes2
answers46
viewsQ: Doubt with syntax
Simple doubt. Usually I see this syntax: require('../lib/dbconnect')(config); But I don’t understand why I use those parentheses like that (....)(....); Can someone explain to me what this is all…
-
3
votes1
answer201
viewsQ: How to create relationships using the HTML 5 Indexed Database API?
Can anyone tell me how to best relate data using HTML 5’s Indexed Databases? I’ve seen many examples of how the API works, but in none of them have I seen data being related. For example, what…
-
4
votes1
answer100
viewsA: Collect data from wordpress database
There... there is. Just know the schema of the WP database. As the friend said there in the comment, is a common Mysql database, so just connect and make the query you need.…
-
1
votes0
answers29
viewsQ: Problem deploying with Pistrane
I am having a very strange problem with Pistrano at the time of deploying to my staging environment. I am using Ruby 2.0.0, Rails 4.2.3 and Capistrano 3.4.0. My server environment is ready, however…
-
3
votes0
answers135
viewsQ: What does this git error mean?
I’m migrating a git repository from the server. I’m taking it out of my VPS and moving it to Bitbucket. I took all the VPS branches and successfully climbed to the mentioned service. I even added a…
-
0
votes1
answer21
viewsA: How to create custom Stages with Capistrano 3?
Good. I researched better and found the solution. Just do this at the time of installation: bundle exec cap install STAGES=app1_staging,app1_production,app2_staging,app2_production…
-
1
votes1
answer21
viewsQ: How to create custom Stages with Capistrano 3?
I have a repository from which two different applications derive. Although they share the same source code, the visual and database of the two is different, as well as the paths on the server. Good…
-
2
votes2
answers757
viewsQ: How to deploy with Wordpress
I want to increase the agility of my projects made with Wordpress. I usually use the git just in the themes. When everything is ready, I raise the theme in the traditional way, by FTP. Of course, I…
-
1
votes2
answers162
viewsQ: Problem when rendering partials dynamically
I have the following code: <table class="table table-bordered table-striped" border="0"> <% @time_line.each do |time_line| %> <%= render partial: partial_name( get_type(time_line) ),…
-
0
votes1
answer166
viewsQ: How does social application integration work?
Lately it has become increasingly common to integrate applications of various types into social networks, such as Facebook, Twitter and even Github. I wanted to understand how this integration…
-
0
votes1
answer52
viewsQ: Why does this way of using case not work?
I have the following code: def label_file_type(type) label = case type.to_s when ['.jpg', '.jpeg', '.png'].include?(type) then content_tag(:span, 'Imagem', class: ['label', 'picture']) when…
-
3
votes1
answer753
viewsQ: Regular expressions with grep
I need to extract data from a text and I’m trying to do this using grep. But the way to make use of regular expressions with this command is quite different from what is usually done in Ruby or…
-
2
votes1
answer58
viewsQ: How to add more lines to a Ruby class?
I began to venture into the world of rubygems. I’m developing a Gem to generate my twitter bootstrap-style app’s Assets, as I intend to reuse my front-end code. All I need to do is put the Assets in…
-
6
votes2
answers125
viewsQ: Use of ';' before starting a function
It has become frequent for me to find codes on github that start like this: ;(function(window){ 'use strict'; })(); Just never understood the following. What is the purpose of using the ';' before…
-
4
votes2
answers106
viewsQ: Variable scope problem in each method
I’m having problems with assigning a variable within a each in jQuery. (function(){ var filters = $(".filter_check:checked"); var hiddenFields = ''; $.each(filters, function(){ hiddenFields +=…
-
-1
votes1
answer86
viewsQ: How to center a dropdown with Javascript?
I need to create a drop-down menu with the following styling: As you can see, it must be aligned with the 'Arrow' pointing to the center of the parent element. I tried numerous styling combinations,…
-
3
votes1
answer715
viewsQ: Load bar with pure Javascript
Sometimes I see loading bars with percentage on sites that I believe overwrite the default behavior of the page when loading (white screen until the content is ready). There are some jQuery plugins…
-
1
votes1
answer648
viewsQ: Unilateral replication in Postgresql
I have two servers. One is only and exclusively for testing. The other is for production itself. I need the test database to contain the same data from the production database. I can’t do a mirror,…
-
1
votes0
answers206
viewsQ: How to create a box from a server?
Here where I work, we are facing many problems due to differences in software versions and development environment. Vagrant seems like a great solution in these cases. The problem is that we cannot…
-
11
votes3
answers1593
viewsQ: Function as parameter in jQuery functions
I always used some functions without really understanding what was happening and where such parameters came from. I speak of the following: Example 1: $("#link").on("click", function(event){…
-
7
votes2
answers841
viewsQ: What is the practical applicability of the super word in Ruby?
There are several explanations on the Internet about it. But I still can’t understand what the practical applicability of the word is super in ruby. Okay, I know it’s meant to call the method with…
rubyasked Pedro Vinícius 1,870 -
4
votes2
answers1654
viewsQ: What’s the difference between top and margin-top in css?
This is a subject that always confuses me a lot. What is the real difference of both? When to use one and the other? I usually go for trial and error, but I need to understand how it really works.…
cssasked Pedro Vinícius 1,870 -
1
votes1
answer193
viewsQ: How to create block helpers in Rails?
I need to create a dropdown menu helper... but I don’t have much idea how to do that. Wanted a block helper, as is done with forms. Ex.: <%= form_for(@teste) do |f| %> <%= f.text_field…
-
2
votes1
answer64
viewsQ: Why use nested classes in Ruby?
Back and forth I see things like: class Teste class Foo end class Bar end end Using classes within classes... Can anyone tell me what this is for? It’s not better and more correct to use modules?…
-
0
votes1
answer60
viewsQ: Definition of Wordpress-style roles
I am planning the architecture of a personal project to be implemented using Rails. In it, I wish it was possible to easily modify the access rules of users, as is done in wordpress. I know there is…
-
0
votes1
answer829
viewsQ: "Headers already sent" error when creating tables in plugin activation
I am developing a plugin for Wordpress, in which during the activation, two tables that relate should be created. My code is like this: function create_tables(){ global $wpdb; require_once(ABSPATH .…
-
0
votes1
answer742
viewsQ: How to pass parameters dynamically to Rails?
I have a rather complex problem. I need to somehow pass parameters dynamically to params via javascript, to show/hide some fields in a report at the user’s request. Below is a representation of the…
-
-2
votes1
answer181
viewsQ: How to cover testing in Rails applications already completed?
TDD is usually used during development. But what about when you walk into a company, get the code all messed up and see the urgent need for improvement and of course, test coverage? How to proceed?…
-
8
votes1
answer373
viewsQ: Offline mode Rails app
In a new endeavor, I need a simple application to stay working if the internet connection is lost. Can someone explain to me how to do this? I had thought to use HTML5’s persistence features in case…
-
1
votes3
answers1199
viewsA: Selection of fields that repeat in the Mysql database
I think you can use SQL GROUP_BY for this. Example: SELECT * FROM tabela WHERE (condição) GROUP_BY assunto;
-
4
votes1
answer802
viewsQ: How to model product categories?
I am about to start the development of an e-commerce, but I am focused on the issue of modeling, especially regarding categories and subcategories of products. For example. A category can have…
-
1
votes1
answer87
viewsQ: How to use authentication in Sinatra?
What would be the best way to authenticate in applications built with Ruby/Sinatra? Devise I know doesn’t work. I have tried several tutorials with Warden, but the settings are very complex and…
-
0
votes4
answers853
viewsQ: Click event only works the first time
I’ve looked for it in other places but I couldn’t find a solution that would work for me. This is the site: http://pedrowebdesign.hol.es/damaso/ These 3 squares at the top, are locations for photos…