Posts by Zuul • 35,190 points
501 posts
-
10
votes2
answers6054
viewsA: How do I read the record of incoming and outgoing calls on my iPhone using Xamarin?
Apple has no API on the SDK to access call logs. In the Xamarin Developer Center for IOS if you use the search box, with the term "call log" an API will appear, but it is for Android. I’m sorry, but…
-
15
votes2
answers1705
viewsQ: Hide widget if empty
I have a div which is used to display alerts to the user: <div id="page-alerts" style="margin:25px 0;"></div> Problem Example in Jsfiddle For reasons of formatting, it contains margins…
-
9
votes8
answers7830
viewsA: Is giving a "SELECT" before an "INSERT" a safe way of not having duplicate records?
The scenario of two operations happening exactly in the same timestamp is remote, but it can happen. Since you cannot make changes to the database, what I suggest is that you lock the table before…
-
11
votes5
answers1562
viewsQ: Optimize function to include classes also looking in sub-directories
I have the following function to include classes when we are trying to use a class that has not yet been defined: /** * Attempt to load undefined class * @param object $class_name object class name…
-
22
votes3
answers12113
viewsQ: Check if a table exists in the database
How to check if a table exists in the database before trying to use it? <?php // define a tabela $table = 'banana'; // verificar se tabela "banana" existe aqui // $tableExists = ?? // executa…
-
8
votes2
answers280
viewsQ: Trigger an action when a hash is found in the URL
The idea is to start an animation when a hash is found in the URL. Example Taking the example of a page whose navigation works by hashing: <nav> <ul> <li><a…
-
14
votes2
answers1581
viewsQ: Difference between method ". attr()" and ". date()"
I notice that there is a difference between updating or applying an attribute data using the jQuery method .attr() and the method .data(). The examples below can be seen in this Jsfiddle. Apply…
-
9
votes3
answers14251
views -
5
votes1
answer170
viewsQ: Read files in a directory sorted by creation date
I have the following code to include all PHP files I find in a directory: if (is_dir(CONF_REL_PATH_BANANAS)) { foreach (glob(CONF_REL_PATH_BANANAS.'/*.php') as $file) { require_once($file); } } When…
-
8
votes2
answers570
viewsQ: Handle 1-pixel edge to avoid double edge (1+1 pixels) with side-by-side elements
I have a grid created with a list ul whose internal elements to li contains a border. The idea is that when the elements are side by side the edges are manipulated so that only a single stroke with…
-
6
votes2
answers288
viewsA: How does Laravel 4 cache queries work?
By making use of the method remember, the created cache is only maintained by the number of minutes passed in the parameter $minutes: $value = Cache::remember('users', $minutes, function() { return…
-
16
votes2
answers28027
viewsA: Is there any way to enable full screen browser with Javascript?
There is a form of simulate the use of key F11, but cannot be automated. As this is a feature that only the user can control, it will have to click a button (for example), in order to activate full…
javascriptanswered Zuul 35,190 -
14
votes6
answers1877
viewsQ: Code refactoring to convert GPS coordinates into DMS format into an array
The user can enter GPS coordinates in two ways, Decimal Degrees or Degrees, Minutes, Seconds: ┌─────────────────────────────────┬─────────────────────┐ │ DMS (Degrees, Minutes, Seconds) │ DD…
-
10
votes2
answers495
viewsA: Parse error given when checking variables with the Empty() function
Your problem is that the function empty() accepts only one argument, that is, you can only check one variable at a time. An idea is to create a function that takes multiple arguments that for each…
-
27
votes4
answers15751
viewsQ: How to check if an image exists in a remote URL?
In order to have the administration of a website to be performed from a server other than the one where the website is hosted, the problem of dealing with remote images has arisen. Common problems:…
-
8
votes1
answer1584
viewsQ: Form with a "file" type field arrives at the server with "$_POST" empty
On our hosting server, I have two projects, where both are with a module in our administrative area to manage images. In the project To, the form is submitted to the server and the $_POST is…
-
3
votes1
answer510
viewsA: Conditional formatting error if document opened in Microsoft Office
Apparently, for Microsoft Office Excel, when defining the type of operator, we cannot indicate the same operator in the condition: Where is:…
-
3
votes1
answer510
viewsQ: Conditional formatting error if document opened in Microsoft Office
When applying conditional formatting to a spreadsheet xlsx generated with the Phpexcel, the same works smoothly when the document is opened in Libreoffice: $objConditional = new…
-
5
votes1
answer114
viewsQ: How to select partially distinct lines?
I have a table whose column reference contains constructed values as follows:: Reference / Color / Size / Gender Examples: JOHN/WHITE/52/MALE JOHN/WHITE/51/FEMALE JOHN/BLACK/52/MALE…
-
17
votes2
answers1662
viewsQ: In HTML5, should null elements be closed with ">" or "/>"?
In HTML 5, there is a series of null elements, which according to the specification (English) and examples given (English) by W3C, they are closed using only >: Elementos Nulos area, base, br,…
-
20
votes3
answers4043
viewsQ: How to add a CSS class to images that didn’t load?
I have an HTML page with numerous images presented as follows: <img alt="img1" width="50" height="120" src="my_image.jpg" /> <img alt="img2" width="50" height="120" src="another_image.jpg"…
-
6
votes1
answer576
viewsQ: How to detect the error cause: 'The requested URL returned error: 503'?
I’m working on developing a web-site where I get back and forth the following error that I can see through the Firebug: The requested URL returned error: 503 Is there any way to find out the origin…
-
6
votes3
answers427
viewsQ: How can I include the 'Submit' button in the 'POST' matrix generated by 'serialize'?
On the forms, I have the button like submit that when clicked will be intercepted by jQuery in order to make validations to the content of the form before sending it to PHP process via Ajax. Form…
-
4
votes1
answer58
viewsQ: How to update the value of a column by substituting in all rows of the table?
I have a table i18n in the database whose column constant contains all values with prefix lang: Description of the table…
-
47
votes3
answers1402
viewsQ: How can I simplify Urls for a website?
To access a particular area of the site, I have to indicate one to three parameters in the URL: Normal URL: # aceder a um módulo http://www.meusite.com/index.php?mod=john # aceder a um sub-módulo:…
-
2
votes2
answers210
viewsQ: How to change a query so that it is executed for each row of table X?
I have the following query of the working database: SET @orderid := '1'; INSERT INTO `cart_lines` ( `line_id` , `cart_id` , `book_id` , `book_reference` , `book_name` , `book_type` , `unit_price` ,…
-
13
votes2
answers345
viewsQ: How do I catch an error alert generated by the Google Maps API?
If, for some reason, an error occurs and Google disables access to the maps API, an alert of this kind will appear to the visitor: Google has disabled use of the Maps API for this application. The…
-
4
votes3
answers1778
viewsQ: How to select rows from table A that are referenced in a column of table B?
I am trying to execute a database query to collect all rows in table A referenced in a column of table B: Query I am running -- Consulta a recolher da tabela A as linhas com ID referenciado na…
-
2
votes1
answer644
viewsQ: How can I insert the results of a query into another table?
I am executing the following database query directly from the phpMyAdmin: SELECT shop.id AS cart_details_id, shop.id AS cart_id, e.name AS client_name, e.nif AS client_tin, e.addr AS client_address,…
-
4
votes1
answer644
viewsA: How can I insert the results of a query into another table?
In Mysql, to insert the result we get from a database query in a table of the same database, just precede the query we will perform with the insertion line. Link to documentation. (English) For your…
-
2
votes1
answer127
viewsQ: How to avoid infinite loop in the function/call that reduces the font size?
I created this small extension of jQuery that aims to reduce the size of the text by setting font-size CSS based on the overflow of its container. The operation is simple, find the current font size…
-
24
votes7
answers59028
viewsQ: Refactoring function to remove punctuation, spaces and special characters
I have this function already too old to "clean" the contents of a variable: Function function sanitizeString($string) { // matriz de entrada $what = array(…
-
3
votes1
answer335
viewsQ: How to read the output from a file to a variable by passing POST parameters?
We can get the result of running a URL to a variable using the function file_get_contents(): <?php $pagina = file_get_contents('http://www.meusite.com/'); echo $pagina; ?> But how can we…
-
2
votes1
answer335
viewsA: How to read the output from a file to a variable by passing POST parameters?
One way is to make use of the functions stream_context_create() and http_build_query() that will allow us to create a flow context and generate an HTML query. Then just apply all these as function…
-
20
votes7
answers3681
viewsA: What are the implications of not declaring variables in PHP?
I can list some problems of robustness, compatibility and future maintenance that will arise when we are working without declaring variables before using them: Warnings in PHP compatibility,…
-
9
votes3
answers90884
viewsA: Attribute "href" for Javascript links: "#" or "javascript:void(0)"?
Do not recommend any of the options in the question, continue to read to know why. To avoid usability problems in case Javascript support is disabled or in case the visitor wants to open the link in…
-
6
votes2
answers230
viewsQ: How to avoid animation of elements that will not fit in the width of the screen?
I created an animation in jQuery for a customer’s Christmas card. However, on 1024x768 or 800x600 resolution screens, elements appear in strange places: The code below hides the balls at startup,…
-
2
votes4
answers3358
viewsA: How to create an element and after a few defined seconds remove it?
There are already numerous very good answers to deal with the question asked, I will just leave a different and abstract example of the target element, which can serve for future visitors.…
-
57
votes8
answers67841
viewsA: How to export an HTML/PHP page to PDF
I use a tool called DOMPDF (english) dompdf which is an HTML to PDF converter. What it does is read the DOM of the HTML page in question and convert it to a PDF document: There are many examples…
-
8
votes6
answers5183
viewsA: How to reverse the position of a div(and its content and attributes) with another div?
Simplified method: One way to reconnect the intended operation, with little code but limited to elements that lie next to each other, is to make use of the jQuery method .before(), where what’s done…
-
9
votes6
answers3652
viewsA: How to detect page encoding with PHP?
Your question is a little vague about the specific problem you are encountering, so I leave here some considerations for a correct iteration with user data, data to and from the server and iteration…
-
14
votes4
answers13910
viewsA: What is the best way to represent an Address?
In our case, the way the data are organized is directly linked to the use of them to facilitate their completion, collection and analysis, i.e.: If we are going to perform surveys or compile…
-
4
votes3
answers157
viewsQ: Refactoring function to collect constants with a certain prefix
I have a function that aims to locate and group in a matrix the constants that are declared corresponding to a certain prefix: Function: function get_constantsByPrefix($prefix) { foreach…
-
6
votes2
answers1646
viewsA: Error creating new user in Moodle via webservice
This error may be related to Moodle password policy that by default requires the password to contain: Minimum number of characters: 8 Minimum number: 1 Minimum capital letters: 1 Lower case minimum:…
-
3
votes2
answers256
viewsA: Problems with Zend layout
By the content of your question I don’t know if you’re taking into account the path to the layout: $layout->setLayoutPath('caminho/para/o/layout'); But you can also change your code to:…
-
8
votes1
answer1608
viewsQ: How to apply the IF ELSE condition to selecting a column?
In Mysql, I have an old table entities where the column gender is in the format ENUM, containing values of the type: "i", "m", "f". When migrating this data to the new structure of this table, I…
-
9
votes1
answer1608
viewsA: How to apply the IF ELSE condition to selecting a column?
One way is to apply the case operator the selection of the desired column indicating each of the "conversions" to take place: Example of consultation: SELECT CASE gender WHEN 'i' THEN…
-
3
votes3
answers946
viewsA: Run function for each class you find
A jQuery function for this purpose is the .each() which allows the execution of a code block for each located element: $('.thumb').each(function() { // o teu código aqui });…
-
4
votes1
answer164
viewsQ: How to add a class to multiple cached elements at once?
In jQuery, we can add CSS classes to multiple elements, but with the element already cached in a variable, as we can perform the same operation? Example: // adicionar classe a ambos os elementos…
-
5
votes1
answer164
viewsA: How to add a class to multiple cached elements at once?
jQuery contains a method, the .add(), which makes it possible to group several jQuery objects representing a group of DOM elements into a single object: jQuery API documentation: . add() Example:…