Posts by felipsmartins • 1,566 points
35 posts
-
2
votes1
answer111
viewsA: Problem with CSS not applying in DIV
Your code should be: function nome () { var tela = document.createElement('div') tela.setAttribute('id', 'screen') document.body.appendChild(tela) } nome() This is because the value of the screen…
-
25
votes2
answers2921
viewsA: What does the "=>" operator mean?
Is known as Arrow functions. One Arrow Function is exactly like a normal/callback function, only less verbose and instance references like this are taken from the "surroundings" (which avoids…
-
0
votes2
answers2381
viewsA: Label and Caption on Chartjs Doughnut Charts
With any instance of Chart, just invoke the method .generateLegend(): <!DOCTYPE html> <html> <head></head> <body> <canvas id="mychart"></canvas> <div…
chartjsanswered felipsmartins 1,566 -
1
votes3
answers82
viewsA: Help with Regex
It works: /^(AG|AD|EX)(\d{8})$/gm This is where the groups in regular expression make sense: First group is a combination of uppercase letters like AG or AD or EX; Second group is a sequence of…
-
4
votes1
answer2091
viewsA: PHP Artisan command does not work
Understand the problem: <?php function spam(&$arg) { print $arg . "\n"; } $var = 'PHP'; spam(&$var); # Causa erro spam($var); # Okay! I don’t think this error is in the Laravel framework…
-
0
votes2
answers2040
viewsA: How to store the value of the indexes of this JSON in variable?
Although the answer has already been given - and chosen - I think it valid to post another solution that is very elegant and that the language brings natively (it seems to have even been built for…
-
2
votes2
answers625
viewsA: Interacting with multidimensional array - PHP
I think your question doesn’t really express what you’re trying to say. The way you describe it, you’d just do it that way: $arr1 = array('id' => 1, 'nome' => 'Joao'); $arr2 = array('id' =>…
phpanswered felipsmartins 1,566 -
3
votes2
answers192
viewsA: In MVC, if I have utility classes, will they be part of the models?
If these are really utilities, you should organize under a structure of this category, usually a directory/namespace called Helpers, Utils, Services, depends on what nomenclature your environment or…
mvcanswered felipsmartins 1,566 -
1
votes2
answers1807
viewsA: "Class 'Mongoclient' not found" error
Of the two: Or you have two versions of the PHP interpreter and your apache is configured with one of them; You have the configuration php.ini , mongo.ini available only for the version cli…
-
1
votes3
answers966
viewsA: Separate a string in php?
That’s all you should do: /** * * @param type $string A string para cortar * @return array Um array com 2 elementos */ function smart_split($string) { # adidione conforme necessidade $operators =…
phpanswered felipsmartins 1,566 -
1
votes1
answer331
viewsA: Computer Date and Language Shell Script
This should be trivial, actually: #!/bin/sh # script /tmp/tes.sh language=$LANG # Idioma date=$(date +"%d-%m-%Y %H:%M:%S") # Data e hora local timezone_offset=$(date +%z) # Fuso horário…
-
1
votes3
answers2032
viewsA: How to relate tables in Mysql to more than one entity?
I don’t think you’re right about the relationship N:N according to what you described. As far as I know, the relationship between: customers and phones: one-to-Many suppliers and phones: one-to-Many…
-
2
votes5
answers156
viewsA: Type induction for any type of object
Although what you’re trying doesn’t make sense (in any language), below is as close as you can get: class classeExemplo { public function meuMetodo($objeto) { if (!is_object($objeto)) { throw new…
-
1
votes1
answer186
viewsA: How to extract data in the form of indexes from this array?
This question is very strange, since the answer is quite obvious. Now, you will always need to specify an index for a particular record from which you want to get some information: $registro =…
-
0
votes2
answers1114
viewsA: Put Dollar " R$ " in angular
According to the official documentation of the corner, session i18n and l10n: Angular Supports i18n/l10n for date, number and currency Filters. All localizable Angular Components Depend on…
angularjsanswered felipsmartins 1,566 -
0
votes1
answer883
viewsA: Capture SOAP Header with PHP
Well, come on... The truth is that you should not need any parser, Reader XML to parse the XML data returned by the web service query via SOAP. Soapclient itself should be able to do this without…
-
2
votes1
answer403
viewsA: When to instantiate and when not to instantiate the object?
In what you call "Form 1" (or not instantiated class) is nothing more than a simple "wrapper" for a set operations or settings, it’s even easier to think of it as a small toolbox or utilities, hence…
-
3
votes3
answers2222
viewsA: What is a PHP Resource type? What is it for?
Well, for me the word Resource (resource) has a very clear meaning and it is somewhat difficult to explain the meaning of a word that is self-explanatory. Perhaps with analogy it becomes clearer…
phpanswered felipsmartins 1,566 -
1
votes2
answers7273
viewsA: Responsive side menu with button
Here’s what you need to adopt the "hamburger" menu trend (the one with three lines) or something like that. You leave it hidden by default, but when the screen has a certain width you can display…
-
4
votes2
answers1310
viewsA: How to know what is the class name of a javascript object?
Use the property name, of the object constructor: var f = new FormData(); console.log(f.constructor.name)
javascriptanswered felipsmartins 1,566 -
1
votes3
answers771
viewsA: How to put two $Row results into variable?
Well, judging by the description, you’re pretty new. The first thing you should always do when you are developing is enable errors (only disable them when the application is on production server,…
-
2
votes4
answers7859
viewsA: Take ID value and place inside the Hidden field
Evident! People do it all the time: HTML: <input type="hidden" name="x" id="hidden-field"> Javascript document.getElementById("hidden-field").value = "seu valor"; Javascript/jQuery…
javascriptanswered felipsmartins 1,566 -
0
votes2
answers108
viewsA: Script to open index.html from multiple folders
I know the question does not exactly involve Python, but since Python is present in almost all linux, why not do the script in that language? Well, here’s the Python version, but I’ll post it later…
-
0
votes2
answers1455
viewsA: How to create this rule in mysql
I think it’s a good idea to use ENUM here, but it would have been a good idea too if you TINYINT simulating a BOOLEAN. But let’s suppose you choose ENUM. So you need to understand the details a…
-
1
votes3
answers284
viewsA: How not to run script on mobile devices. in Wordpress
Well, you could analyze the HTTP header called User-Agent, which has information about the browser. In this string there is usually information about the device. However there is already a PHP tool…
-
2
votes2
answers108
viewsA: Regex - picking certain values - PHP
Now, if attributes are delimited by a __ and its values for .. it is very simple to perform this extraction task: <?php # É sua string principal, da qual se quer extrair $str =…
-
37
votes4
answers19928
viewsA: strtoupper() with accents
You need to use your counterpart, mb_strtoupper() that will deal with Unicode: $encoding = mb_internal_encoding(); // ou UTF-8, ISO-8859-1... echo mb_strtoupper("virá", $encoding); // retorna VIRÁ…
-
1
votes1
answer196
viewsA: PHP - Curl returning error "Microsoft Vbscript Runtime error '800a01a8' Object required: 'Session(...)'"
I’ve been doing a lot of these automations lately and making scripts really simulate human interaction. PHP+Curl is a bit boring and there are some details you should note because depending on how…
-
0
votes1
answer298
viewsA: ERROR: Connection timed out (110) >> shoutcast
Sometimes the remote server is slow to respond and there is usually a time limit (~30s, in general) for it to be returned until the network socket closes and returns an outdated connection time…
phpanswered felipsmartins 1,566 -
2
votes1
answer79
viewsA: Http request - log
Not sure that I understood the question, but if you already use Firefox, the best way to get the log of all traffic since the first HTTP request is by using the Developer Toolbar that already comes…
-
7
votes1
answer3154
viewsA: HTML list with image in UL
In fact, bootstrap does not require you to use only one element button to activate the dropdown. You can see this by looking at the CSS fonts in Twitter Boostrap, then you’ll see which classes…
-
2
votes3
answers1144
viewsA: Is there any way to use script as configuration files in python?
Yes, it is possible. The most widespread way to do this is to do as the Django framework ago: Creating a file (Settings.py, for example) and importing it into another module. See: . ├── main.py ├──…
-
4
votes4
answers64762
viewsA: Mysql installation socket error
Well, it’s probably a question of system permissions or you have only mysql-client installed, but not the mysql-server and therefore cannot create a UNIX-like Socket file. So what you should try…
-
6
votes2
answers3277
viewsA: How to extract specific data from a php html file?
It’s just for this type of task that PHP has support for Xpath. Suppose you have your HTML output that way and that it’s under a URL like localhost/emails.html: <!DOCTYPE html> <html>…
-
1
votes1
answer174
viewsA: Python lib subprocess
cmd points to a list, which is a mutable object. This means that when you extend cmd for the second time you modify the value still of the same object, and that’s what you have: >>>…
python-2.7answered felipsmartins 1,566