Posts by João Paulo • 1,426 points
41 posts
-
3
votes1
answer104
viewsA: How to convert a tuple to a`void`pointer vector?
If you can use C++17, use Parameter pack with fold Expressions and std::apply: #include <iostream> #include <vector> #include <tuple> #include <string> #include…
c++answered João Paulo 1,426 -
2
votes1
answer34
viewsA: What is the difference between span and string_view in c++20?
To the std::basic_string_view, there is a whole set of specific methods to handle strings. std::span is for generic types, including user-defined types. cppreference for std::basic_string_view: The…
c++answered João Paulo 1,426 -
0
votes2
answers607
viewsA: What is the difference between initializing a constructor or doing attribution within the constructor?
I would like to complete the previous answer with the following code:: #include <iostream> class Tipo { int x; public: Tipo() { x = 0; std::cout << "tipo-default\n"; } Tipo(int p) { x =…
-
0
votes1
answer50
viewsA: Doubts with dynamic lists
You can do as below: #include <iostream> #include <cstdlib> #include <ctime> #include <utility> #include <list> int main() { std::srand(std::time(nullptr)); int…
c++answered João Paulo 1,426 -
1
votes2
answers74
viewsA: How to find the data type of a binary file
Generic way, header format is hopeless, or you know it, or you find out by trial and error. And responding to your comment, you can store variables however you want... it all depends on how you are…
-
1
votes1
answer58
viewsA: Something like Getasynckeystate() for Linux systems, is there something similar?
Inside the folder /dev/input of your Linux you will have information about the events of input of your system. They come in the following format: struct input_event { struct timeval time; unsigned…
-
2
votes1
answer230
viewsA: How to put a scroll in the tab system
I added these two properties to ul.tabs: white-space: nowrap; overflow-x: auto; $(document).ready(function () { $('.tab-content').each(function (i) { var tabTitle = $(this).data('tab-title'); var…
-
2
votes2
answers353
viewsA: How to remove only the parent element, without removing the children
Another alternative would be to take the content and replace it: var children = $("a").contents(); $("a").replaceWith(children); <script…
jqueryanswered João Paulo 1,426 -
3
votes2
answers1078
viewsA: Render subtitles in video with ffmpeg?
The HTML5 pure does not support subtitles embedded in the files. What you can do is separate the files and call them as is below: <video controls preload="metadata"> <source…
-
1
votes2
answers146
viewsA: Is it possible to change the background color of an element for printing?
Well, if a user has marked in the options something like "Print images and background colors" (will depend on the browser), no CSS will overwrite this. So always take that into account. But there…
-
7
votes4
answers1246
viewsA: Identify if all characters are equal
Using RegExp.prototype.test(), do the following: /^(.)\1+$/.test(sua_string) This returns true or false depending on whether all characters are equal or not. /^(.)\1+$/.test("xxxx"); // true…
-
2
votes3
answers9438
viewsA: Delete confirmation with bootstrap
You can also use the Sweetalert which is a great plugin for Alerts: function alert_it(){ swal({ title: "Are you sure?", text: "You will not be able to recover this imaginary file!", type: "warning",…
-
0
votes1
answer134
viewsA: Autocomplete with typeahead and JSON
Put the URL starting from root (webroot address) of your server. Use this syntax also inside the object you pass to the Bloodhound constructor: prefetch: {url : 'path/to/ativos.json'}…
-
6
votes3
answers2700
viewsA: JS - Object array for array arrays
With the Ecmascript 2017+ it is possible to do the following: var arrays = objetos.map(function(obj){return Object.values(obj)}); Whereas objetos is your object array. Chrome version 55, for…
-
2
votes1
answer135
viewsA: How to get toDataURL to save in a sessionStorage?
You can try it this way: var canvas = $(img_selector).cropper('getCroppedCanvas'); //pega o canvas var data = canvas.toDataURL('image/jpeg'); //gera a base64 com o mimetype var base64 =…
-
4
votes1
answer763
viewsA: How to return the converted image to Base64 in Postman
Only with pure code Base64 I believe you will not succeed. What you can do is pass a parameter in the request, when you want to test, indicating that you want to put the Base64 code inside a tag…
-
3
votes1
answer613
viewsA: Two effects with javascript in an image
You can do this way using only css: HTML: <img src="image.jpg"> CSS: img{ -webkit-animation: fade 2s 0s 1, bright 1s 2s infinite alternate; } @keyframes fade { from {opacity: 0;} to {opacity:…
-
14
votes4
answers23157
viewsA: Identify if the device is pc or mobile and use a different code for each
Simply put, you can use this function to detect if it is mobile: function detectar_mobile() { if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) ||…
-
1
votes3
answers115
viewsA: Multidimensional array
The operator * just for that: n = 6 final = [[290, 293, 291, 294]]*n
-
0
votes3
answers479
viewsA: Maximum occurrences in a python dictionary
As simple as possible: key = max(dic, key=dic.get) value = dic[key] print key, value dic is your dictionary.
-
1
votes1
answer169
viewsA: How do I use the Youtube API?
I don’t know how you’re closing your modal, but if you’re using .hide() jQuery, you can do the following: function pause_video(){…
-
2
votes3
answers11228
viewsA: How to timer in Javascript
Two simple options (2000 ms): requestAnimationFrame [requestAnimationFrame] Tells the browser that you Wish to perform an Animation and requests that the browser call a specified Function to update…
-
0
votes2
answers1293
viewsA: Xpath with Python
This here can solve your problem: import xml.etree.ElementTree as ET #dicionario de namespaces ns_dic = {'v' : 'http://exemplo.org', 'u' : 'http://exemplo2.org'} tree = ET.parse('marketplace.xml')…
-
4
votes1
answer344
viewsQ: Organize list with more than one criterion in case of a tie
I’m using sorted to organize a list, but I need two criteria to organize it for tie cases, for this, I call sorted( ) twice. It has how to make this organization calling sorted( ) only once?…
-
1
votes2
answers86
viewsA: How to create custom ordering?
In python, these lines solve your problem: string = 'acebdukl' organizada = sum([list(filter(lambda key: key if key[1].upper() == letra else None, lista)) for letra in string.upper()], [])…
logicanswered João Paulo 1,426 -
1
votes1
answer340
viewsA: Doubt to transpose part of a table with Python
Using map and chain: from itertools import chain data = [[10,11,12,13,14,15], [1,2,3,4,5,6], [7,8,9,10,11,12], [13,14,15,16,17,18], [19,20,21,22,23,24]] result = chain(*map(lambda line: [line[:2] +…
pythonanswered João Paulo 1,426 -
6
votes3
answers487
viewsA: Navigate horizontal scroll by pressing tab
I took advantage of @Guilherme Nascimento’s reply and made some modifications. Using jquery 1.11.1, it worked on IE 9. Example below works for any type of column width and works at the end of…
-
7
votes1
answer922
viewsQ: Redeem dictionary key with maximum sum of respective value
I have the following dictionary: dic = {'bsx_8612': [23, 567, 632], 'asd_6375': [654, 12, 962], 'asd_2498': [56, 12, 574], 'bsx_9344': [96, 1022, 324]} I want to redeem the key whose value has the…
-
5
votes1
answer3608
viewsQ: Run Python file with arguments
In my program, I do the following operation: import sys qtd_ponts = int(sys.argv[1]) I would like to know a practical way to run this file .py passing arguments without needing an IDE, using files…
-
2
votes5
answers8633
viewsA: What is the most complete way to install python on Windows?
I’ve come to quote the Anaconda. Anaconda is a completely free Python distribution (including for commercial use and redistribution). It includes more than 195 of the python packages most popular…
-
11
votes4
answers3572
viewsA: How can I distribute the . py program without the user having to install all libraries?
Well, I don’t know if this is possible, but maybe you can do this to facilitate the installation of packages: Using a file .bat you can install the libraries using Pip, for example: start /w pip…
-
1
votes2
answers1649
viewsA: Auto-start
Click on Start Menu > All programs > Initialize In English: Start Menu > All programs > Startup Inside the boot folder, put the shortcut of your file .bat which will open your python…
-
0
votes2
answers6881
viewsA: Graph possible python paths
Use the search algorithm Depth Dirst Search: dic = {'A':['B','C'],'B':['A','C','D'],'C':['A','B','D'],'D':['B','C']} def dfs_caminhos(grafo, inicio, fim): pilha = [(inicio, [inicio])] while pilha:…
-
1
votes1
answer35
viewsA: Extract everything using Libarchive
Try to use Pylzma: import pylzma i = open(compressed_file, 'rb') o = open(decompressed_file, 'wb') s = pylzma.decompressobj() while True: tmp = i.read(1) if not tmp: break o.write(s.decompress(tmp))…
pythonanswered João Paulo 1,426 -
3
votes4
answers15696
viewsA: How to extract digits from a Python string and add them together?
my_string = "96h11k" soma = sum([int(i) for i in my_string if i.isdigit()]) --------EDIT--------- Now that I see that my answer is identical to Maniero... For the answer not to be completely…
-
1
votes4
answers1574
viewsA: Database and transaction control in value transactions
In transaction you can put valor acumulado which will always be the valor acumulado previous + valor current, the first being valor acumulado is the very first valor. When you access the balance,…
-
1
votes3
answers221
viewsA: How I dynamically put and take out a href
Try this: ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "<script>$('#idLocal').append('<a href = \'url\'></a>');</script>", false); Or…
-
1
votes3
answers627
viewsA: How to collect the height of an element with jQuery
When you pass the C# instructions, pass using the following function: string html_para_passar = "<script>$('#id').appendTo('#id_2');</script>"; //no caso aqui usando jQuery…
-
1
votes2
answers988
viewsA: How to position a div side by side with JS/jQuery
You can create a ul and setar display as inline and position Absolute and with jquery go adding items (chat windows that can be a div) in this list. $("#ul_id").append("<li><div id='chat_"…
-
0
votes6
answers19014
viewsA: I want to align my menu to the center
<div style="width: 200px; margin: 0 auto; left: 50%; margin-left: auto; text-align: center;"> <ul id="menu"> <li>teste</li> </ul> </div> width you put the size…
-
2
votes1
answer754
viewsA: How can I pass a class value to a Listbox
You are creating a whole Listbox made this button click. Add this value in a previously created listbox, take ListBox lstbox = new ListBox();. But if you want to create a Listbox every time the…