Posts by WeezHard • 1,208 points
24 posts
-
2
votes1
answer140
viewsA: Questions git & github
Imagine the following scenario: I have a directory that I call Workspace and within this directory I have all my projects. Examples: Workspace/project1 Workspace/project2 Workspace/project3 In case…
-
3
votes4
answers5008
viewsA: Odd or even array in PHP
I know it’s been taken care of, but I’ll leave you an alternative: <?php $par_ou_impar = array(2,3,4,56,5,42,98,100); for ($i = 0; $i < count($par_ou_impar); $i++){ echo ($par_ou_impar[$i] %…
-
0
votes2
answers426
viewsA: Extract a new array from an array - Ruby
It’s important to leave the code of what you tried to do so the staff will be more motivated to help you. However, here comes the code that gives you more or less what you need: dados = [["CELULA",…
-
0
votes1
answer63
viewsA: Sqldatareader Not Closed?
As in the comments I can not leave formatted code, with reply with a previous solution... I will change as you give the feedback. First... change the method in question so it stays that way: Public…
-
6
votes4
answers114
viewsA: How to make a query that returns the last record of each day?
Try this solution: SELECT * FROM tabela INNER JOIN (SELECT MAX(data) AS ultimo_registo FROM tabela GROUP BY DATE(data)) as Lookup ON Lookup.ultimo_registo = tabela.data As you can see, I ran the…
-
5
votes3
answers5900
viewsA: How do I make a program written in python open with two click’s made one executable?
For Windows, Create a . bat file with content similar to this: @echo off python c:\teu_script.py %* pause You must have python installed and command python recognized. Or you can create the…
-
1
votes1
answer680
viewsA: Ruby on Rails alphabetical order
The ordination can be done this way: @posts_categories = Admin::PostCategory.order(name: :asc) This is if the poss_categories table has the "name" field. If not, simply replace it with the field…
-
0
votes2
answers40
viewsA: Help with #Rails relationships
I would do so: class Area < ... has_many :shared_areas end and... class Request < ... belongs_to :shared_areas end and... class SharedArea < ... belongs_to :area has_many :requests end With…
ruby-on-railsanswered WeezHard 1,208 -
13
votes2
answers4492
viewsA: Is there any way to foreach two variables at once?
If it is two arrays, can be done as follows: foreach(array_combine($dados, $telefones) as $d => $t) { }
-
3
votes1
answer107
viewsA: Meaning of the operator?
The operator ! denies. If I put another ! before, I’ll be denying the first denial. That is to say: If i == verdade and !i == falsa, then !!i == verdade I could have more denial operators before. I…
-
2
votes1
answer5886
viewsA: How to place the current date and time in a datetime field?
Well, I don’t know if that’s exactly what I understood. Suppose you have the following table: CREATE TABLE `test`.`tasks` ( `id` INT NOT NULL AUTO_INCREMENT, `created_at` DATETIME NULL, PRIMARY KEY…
-
2
votes3
answers4966
viewsA: What is the function of the operator "!" (exclamation)?
The operator ! serves to deny. That is, if the line: livro.aplicaDescontoDe(0.1)return true, prior to the operator ! he becomes falsa and vice versa. public class HelloWorld{ public static void…
-
0
votes4
answers498
viewsA: Full byte type cast
If we run the code below: public class HelloWorld{ public static void main(String []args){ int i = 10; byte b = 5; b = (byte) i; System.out.println(b); // esta linha irá imprimir 10 } } The value…
-
32
votes3
answers2385
viewsA: How important is the use of the word "this"?
The this serves to reference the object itself. There are cases where its use becomes necessary. class Pessoa { private string nome; public Pessoa(string nome){ this.nome = nome; } } In the example…
-
4
votes1
answer1090
viewsA: git commit push merge, only I have problems?
As @Maniero said, the idea is that with Git there are fewer conflicts with SVN. Maybe the problem is the workflow they’re using. So I’m going to try to share here what workflow I’ve been using when…
-
3
votes3
answers245
views -
3
votes1
answer186
viewsA: Perform random SELECT
With Mysql 4.1 or later, you can do the following: SELECT id FROM tabela WHERE id >= (SELECT FLOOR(MAX(id) * RAND()) FROM tabela) ORDER BY id LIMIT 1; Note that this method only works on tables…
-
2
votes0
answers85
viewsQ: Subdomain accessing only specific features with Rails
I’m using Rails 4.2.2 I have the following code in the config/Routes.Rb file: Rails.application.routes.draw do namespace :api, constraints: { subdomain: 'api' }, path: '/' do resources :users end…
-
1
votes3
answers169
viewsQ: Conditional relationships
I need your help I have following model: class User < Ac... enum user_type: [:normal, :admin] end And I also have the model "Department": class Department < A.... end What I need to do is make…
-
0
votes2
answers534
viewsA: Problem with function that generates friendly url
A simple function that works with me: function url_amigavel($string){ return preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($string)); } Something more complete would be: function…
-
4
votes1
answer3084
viewsA: Error trying to insert SQL SERVER
The way you created your table, it is set that the id_documents_defense field cannot be null, and at the time of inserting, you are not specifying value for such field (which cannot be null).…
sql-serveranswered WeezHard 1,208 -
3
votes3
answers1464
viewsA: How to control volume to app media on Android
To control the volume of your application in Mediaplayer, you can use the method "setVolume" // Volume baixo em ambos os lados (Esquerdo e direito) mp.setVolume(0,0) To learn more about this method,…
-
1
votes1
answer270
viewsA: Configure PHP INI to load default PHP file
I don’t know why you need it, but here it comes: Open the PHP.ini file, and search for "include_path": Change its value: include_path = "/var/meus_includes" Note that you can include more than one…
-
3
votes1
answer56
viewsA: How to increase the number of comments on wordpress
On the comments page, at the top right, you have a "Screen options" button as in the image below: Click this button and you can change the number of comments viewed…