Posts by tayllan • 2,453 points
53 posts
-
1
votes3
answers2146
viewsA: Collect instagram tag images for website
I also wanted to add a widget fairly simple as a solution: Lightwidget. It’s free (but only recharges new Instagram images once a day :)). For example, to display the tag photos #taflovessneakers…
-
3
votes2
answers9616
viewsA: Read input data to EOF in URI Online Judge
Simple, use an object Bufferedreader and call the method readline() until he returns null. Remembering that the method readLine() class BufferedReader() returns a String. And as in your exercise you…
-
2
votes1
answer3029
viewsA: Location container Docker on host
According to the docker’s documentation, from the version 1.10 the names of directories in which the containers are located within the host are not equal to the Ids of containers. And the…
-
0
votes3
answers1646
viewsA: Java Maps: take key from value
You can also double the size of your table by placing all the valores of chaves as chaves of valores: myMap.put("1", "valor1"); myMap.put("2", "valor2"); myMap.put("3", "valor3");…
-
4
votes4
answers256
viewsA: What’s the difference between creating a module normally and creating a module within a function?
The difference between the two codes has to do with the type of variable scope implemented in Javascript. Javascript uses a function scope, instead of the block scope used by languages such as C and…
-
1
votes1
answer376
viewsA: How to convert certain group of columns to JSON?
If using Postgres 9.3: SELECT id, row_to_json( (SELECT d FROM (SELECT col2, col3, col4) d) ) AS dados FROM tab_1; Example in SQL Fiddle. In the Postgres 9.4+ gets easier: SELECT id,…
-
8
votes1
answer1197
viewsA: What is the prefix attribute for in the html element (tag)?
The attribute prefix is one of the attributes created by Rdfa (Resource Description Framework in Attributes). Rdfa is an attribute-level extension for several markup languages, such as HTML and XML.…
-
2
votes3
answers17331
viewsA: Convert Fractional decimal to binary
The algorithm you want can be created from the following logic: Given a number d decimal, for example 12.25d; Take the whole part of the number and turn it into a binary number b: 12d flipped 1100b;…
-
12
votes1
answer5823
viewsA: When to use the xmlns attribute in the html element?
In his example, xmlns="http://www.w3.org/1999/xhtml" indicates that the syntax used in the document is actually XHTML5 and not HTML5. The following lines create several namespaces XML, used to…
-
1
votes4
answers3189
viewsA: Access JSON with multiple JS objects
You’re getting your file .json in server text format. The best way to resolve this is to change your server code to upload the file .json with the header appropriate. In PHP it would look something…
-
1
votes1
answer79
viewsA: Can I use GZIP compression on files that have been minified by Gulp or Grunt?
Yes, it’s a good idea to minify your files .js and .css and then compress them using gzip. I did a simple test with the jQuery. I downloaded the non-minified jQuery and the minified: -rw-rw-r-- 1…
-
2
votes2
answers495
viewsA: Merge two objects with the same ID
If the only key that objects have in common is id and you are sure that the value will always be the same, so just iterate over the properties of the objects and add the values to the third object:…
-
1
votes1
answer773
viewsA: Redirect AJAX Cross-Domain Request in PHP
You need to enable on your server that will be accessed by an external domain the permission for the external domain to access it. Considering http://api.dominio.com as its main domain, and…
-
2
votes2
answers300
viewsA: Import . sql from Postgresql in Neo4j
@Brunorb is correct, you will need to at some point create a mapping function Modelo Relacional <--> Grafo of your data. This tutorial from Neo4j can help you. Simplifying the link above, you…
-
5
votes3
answers1419
viewsA: What is the difference in checking an array with isset and array_key_exists?
array_key_exists() will return if the key exists or not in the array, regardless of the value it has. isset() will return you bool(true) only if the key exists in the array And its value is…
-
4
votes2
answers8938
viewsA: Function calling $.getJSON() returns Undefined
As it stands, its function will not append anything in the <div>. That’s because the function $.getJSON() is asynchronous, meaning it is not executed at exactly the same time it is called. So…
-
5
votes2
answers1063
viewsA: Challenge of the Ant Colony
Complementing @Gomiero’s excellent response, you can really use a simple tree to represent the connections between the anthills, having the anthill number 0 as the root node of the tree. For each…
-
6
votes3
answers1884
viewsA: Javascript timer
Use a set of setInterval() with setTimeout(): var temporizador = document.getElementById('temporizador'); var ativerIntervalo = function() { temporizador.innerHTML = 60; var intervalo =…
javascriptanswered tayllan 2,453 -
2
votes2
answers41
viewsA: Slowly recount the number of records in a table
Use the function setInterval() javascript: var contador = document.getElementById('contador'); var TOTAL_CLIENTES = 10; var intervalo = setInterval(function() { contador.innerHTML =…
-
2
votes2
answers88
viewsA: How to update the last name of a person who starts with the initial 'Fabio%'?
You have to use: UPDATE pessoa SET nome = 'Fábio Borges' WHERE nome LIKE 'Fábio%'; nome = '%Borges' makes the name become literally "%Borges", because the character % only works to match anything in…
-
0
votes2
answers1943
viewsA: PHP - Check for GET parameters in a URL
To break your string representing a URL you can use the methods parse_url() and parse_str(). parse_url() takes a string representing a URL and breaks the string into components. Given its example…
-
1
votes1
answer61
viewsA: When the time reaches 0, the button gets disabled
In his index php. leaves the function fun() as follows: function fun() { $.ajax({ url: 'aposta.php', success: function(a){ if(a) { a = JSON.parse(a); $("#tempo").html(a.time); if (a.time === 0) {…
-
6
votes15
answers4487
viewsA: Determine if all digits are equal
Contribute my version in Haskell: digitosSaoIguais :: Int -> Bool digitosSaoIguais x = and $ map (== head xs) (tail xs) where xs = show x show converts the number x to String (Char list). now xs…
-
2
votes1
answer502
viewsA: How to catch the key in a while loop?
You can do it in two ways. Given the array: $array = array( 'teste' => '1', 'teste2' => '2' ); 1. Using the method Current(), which returns the current element of the array, along with the…
-
2
votes1
answer726
viewsA: How to make a "while" of the number of rows of a query?
Do the following: $query = mysql_query('SELECT * FROM tabela'); $linhas_afetadas = mysql_num_rows($query); $limit = 100; for ($offset = 0; $offset < $linhas_afetadas; $offset += $limit) { $query…
-
1
votes2
answers76
viewsA: How to install Grunt offline?
As already answered by @Frantic, you need internet to install the Grunt for npm. That, or you can pick up a pen drive, find a friend of yours who already owns the Grunt installed, connect the pen…
-
6
votes2
answers22129
viewsA: Get current date in mysql
Solutions: 1. Maintaining the current table structure: Format the column Datacadastro within the clause where to compare two values DATE: mysql> SELECT * FROM cad_clientes WHERE…
-
7
votes5
answers1538
viewsA: How to run an event once?
I recommend you use the method .one(), since it was developed precisely for situations like the one you described. It fires the event for given element only once. After that the event is untied from…
-
4
votes1
answer113
viewsA: Power using recursion
Your problem here is the type of variables you are using. In C, the native type int accepts values at most until 2147483647, That’s why when you try to calculate 6 ^ 15 the result makes no sense.…
-
6
votes4
answers1407
viewsA: How to work with values that far exceed the long (64 bit) limit value
How large numbers are represented and stored will depend on your programming language. In languages such as C and Java, the most they offer you are libraries that implement giant numbers. Already in…
-
0
votes2
answers697
viewsA: How do I find the smallest cycle of an undirected graph?
First you must give weight 1 to all existing edges of your graph and weight INFINITO rough grafo[i][i] to every vertex i. Also make your graph pseudo-directed: grafo[i][j] = 1 grafo[j][i] = 1 to any…
-
3
votes2
answers767
viewsA: Path between 2 nos of a graph using smaller number of colored edges
The first thing you should notice in the problem is that the cost between the various bus lines is always 1, then you don’t even need to use the dijkstra’s algorithm or any other generic shortest…
-
1
votes1
answer63
viewsA: am as root and Els says I am not (Ubuntu 14.04)
I don’t really have an explanation of why this occurs, but the following made the command work for me: In the Els.sh installed (on my computer it got on /usr/local/Els/), you will find the following…
-
1
votes2
answers2485
viewsA: Phrase "Email sent successfully" on the same page of the Form. How to configure?
You just need to encapsulate your PHP code that deals with receive the POST parameters and save to the bank and send the email within the following IF: if ($_SERVER['REQUEST_METHOD'] === 'POST') {…
-
1
votes2
answers50
viewsA: How to send hidden information through a form?
This may not be your case, but if you are doing this to implement the technique of honeypot, where you place an Hidden field to identify that your user is actually a spammer bot, a input…
-
15
votes3
answers10205
viewsA: How to format date in full?
To leave in the format you want and with the month in full: Date data = new Date(); Locale local = new Locale("pt","BR"); DateFormat formato = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy",local);…
-
1
votes1
answer1282
viewsA: Regular expression formatted as internet domain
How about: ^(?!\d+\.)(\w[\w\-]{0,24}\w)\. (?!\d+\.) is a negative Lookahead. It checks that the domain is not composed only of digits. \w the first character cannot be a hyphen, so one expects a…
-
3
votes2
answers574
viewsA: How to find out if a number is subnumber
A simple way to do it: >>> str(101) in str(100001010057) True >>> str(18) in str(100001010057) False You convert your 2 numbers to string and use the operator in Python native,…
-
1
votes1
answer480
views -
5
votes5
answers5903
viewsA: Capture filename in directory
The easiest way not to fall into this Exception is to use a foreach. Example: public static void getImgs(String path){ File file = new File(path); File[] arquivos = file.listFiles(); for (File…
-
1
votes3
answers1441
viewsA: PHP Regex Catch the html tag
There’s no way you can do what you want with just three exact Matches. You can’t capture, for example, just WW from the string WAW in a single capturing group, whether or not using non-capturing…
-
12
votes2
answers28407
viewsA: What is the difference between unit test and integrated test
Complementing the rodrigo’s answer with examples: Unitary Test (that purists like to call "unit test". Blorg! ): you have the following function in your system (super simplistic): def soma(a, b):…
-
8
votes10
answers1739
viewsA: How to count the zeroes to the right of a number?
Version in Haskell :) countZerosDireita :: Int -> Int countZerosDireita = length . takeWhile (==0) . reverse . map (read . (:[])) . show show converts the number to String (Char list). map (read…
-
1
votes1
answer481
viewsA: Combination of digits from A to Z (Crosse Join)
Indeed, as commented by @Bacoo, its bottleneck is being the constant impression of values. In your simplest case (all combinations with 4 digits of 26 characters) you have 26 ^ 4 = 456.976…
-
1
votes1
answer155
viewsA: Schedule linux task (Cron)
The following commands worked for me (I used firefox in place of qbittorrent because I don’t have qbittorrent installed): $ sudo su to log in as root and nay change the global crontab table (located…
-
4
votes3
answers428
viewsA: Linux or GNU/Linux?
Linux is just the core (kernel) Operating System, responsible for carrying out communication between hardware (printers, monitors, keyboard, etc) and software. Already GNU (which is a recursive…
-
2
votes2
answers381
viewsA: File permission on Linux
TL;DR Log with the same user with whom you have done all the described actions. Execute the command umask to find out your user’s default permissions. The command will return you a number on octal…
-
7
votes2
answers998
viewsA: Is there any way to change a commit message?
Complementing the response of Rodrigo, if you just want to change the last commit message, use git commit --amend -m "SUA NOVA MENSAGEM AQUI". But if you want to change any other commit, including…
-
0
votes2
answers799
viewsA: Typeerror - 'int' Object has no attribute '__getitem__' when iterating over list
What happens is that the first time your program runs line 10, the array i_copy receives the value of x. However, x is just a number taken from the same array (see line 6). Then in the next loop…
-
19
votes1
answer1446
viewsA: Organizing packages in a java project
Oracle itself has defined certain conventions to avoid conflicts between Java classes of different programmers/companies/projects. It suggests that a company (or any programmer) use their own…