Posts by Michael Siegwarth • 3,427 points
53 posts
-
1
votes1
answer80
viewsA: Specific url in Django
In practice it is necessary to create the same URL structure of the current blog on Dispatcher URL django. Below is an example of a definition of Urls (copied from the Django documentation). You…
-
35
votes3
answers4929
viewsA: What is the point of using double negation in Javascript?
As the goal of return !!navigator.userAgent.match(/iPad/i); is to find out if the current device is an iPad or not, it is interesting/elegant that the return of the function is boolean (true or…
javascriptanswered Michael Siegwarth 3,427 -
0
votes2
answers404
viewsA: carry out independent process
In Windows, you can use the function os.startfile. Thus: import os os.startfile('C:\Windows\Notepad.exe') If you’re in need of a platform-independent solution, take a look at this link (English).…
-
1
votes1
answer143
viewsA: Display all tables in the Phpmyadmin navigation column
Note: this solution does not effectively disable paging, but the result in practice is the same. The answer depends on whether you want the settings to be applied always, or only in the current…
-
8
votes2
answers146605
viewsA: How to get input using HTML and Javascript
In the Javascript code below (I didn’t use jQuery), there are two events: one to detect the key at the time the value is entered in the input, and another to detect the click on "Send". HTML:…
-
1
votes1
answer2838
viewsA: Automatically insert Youtube video into a div
I solved it that way: HTML: <div class="videos"></div> Javascript (with jQuery): $(function() { // Baixar URLs do feed do canal…
-
13
votes2
answers808
viewsA: What are the size limits of variables in Ruby?
Since it sometimes depends on its architecture (32 or 64 bits), I set the limits as defined in the language code (when existing): String: 32 bits: 2**31 - 1 64 bits: 2**63 - 1 Source:…
-
2
votes1
answer146
viewsA: Django - How does Developer @login_required work in views from another app?
Can use yes! Django has a middleware that is responsible for user login "at project level", not being tied to any app that you created. Assuming you already have an app using @login_required and…
-
5
votes1
answer919
viewsA: Swap all words in an HTML code
Thus: var elements = document.getElementsByTagName('*'); for (var i = 0; i < elements.length; i++) { var txt = elements[i].innerHTML.replace("Original", "Alterada"); elements[i].innerHTML = txt;…
javascriptanswered Michael Siegwarth 3,427 -
6
votes3
answers216
viewsA: Is it wiser to use client-side validations in Rails?
Ideal is that you make the customer validations And on the server. Validating on the client side is cool precisely for the reasons you mentioned (save bandwidth, less response time, cooler UX,…
-
1
votes1
answer325
viewsA: Change password Student
Looks like you’re trying to save alunoNovaSenha without changing his password. Whereas the correct password is on aluno, the code below should solve the problem: alunoNovaSenha.Senha = aluno.Senha;…
-
2
votes1
answer1397
viewsA: How do I use Template Inheritance to inherit Style Sheets (css) in my Django project?
Add the {% load staticfiles %} in the library.html also. Django requires you to add the required headers to each template file, even if they are already declared in the base template. Are you using…
-
1
votes1
answer255
viewsA: Problem in importing User models
This is not the "common" way to run a project with Django, but if you just want to solve the problem in question, the solution is to set the variable DJANGO_SETTINGS_MODULE. When you turn the…
-
6
votes2
answers7033
viewsA: How do I make Django "see" CSS?
I understand that three things are missing to solve your problem: 1) Set the path to static resources There is a variable that you add to settings.py, calling for STATICFILES_DIRS, where you can add…
-
7
votes3
answers1021
viewsA: How to add object properties in Javascript?
With the library Underscore.js you can do something like this: var totais = _ .chain(vendas) // Primeiro: "achatar" as vendas .map(function(v) { return _ .chain(v) .map(function(v2) { return v2; })…
javascriptanswered Michael Siegwarth 3,427 -
1
votes1
answer666
viewsA: Import: cannot import name Certs
The problem can be solved by reinstalling Python (version 2.7.6), and later the Requests library, directly by git: git clone git://github.com/kennethreitz/requests.git cd requests python setup.py…
pythonanswered Michael Siegwarth 3,427 -
5
votes3
answers26625
viewsA: Simple comparison between dates
Complementing: There is a great library, called Moment js., specially made to deal with dates/times/timezones. Depending on the need for date manipulation in your project, it can become interesting.…
javascriptanswered Michael Siegwarth 3,427 -
11
votes2
answers8317
viewsA: How to delete a variable in Javascript?
According to the MDN, the delete serves to remove properties of an object: x = 42; // cria a propriedade x no objeto global var y = 43; // declara a variável y delete x; // retorna true (x é uma…
-
2
votes1
answer121
viewsA: How to use Xcode 5.0 with 10.7.5?
Cannot install on your Mac OS version (10.7.5), as the minimum version to run Xcode 5 is 10.8.4. Either you use Xcode 4 (where you can’t develop for IOS 7), or you update your Mac OS.
-
6
votes2
answers2720
viewsA: View control via authorization with Angularjs + Webapi
I think that’s the way to go. I recently implemented something similar (but with Knockoutjs instead of Angularjs), and I didn’t worry much about this access issue, since the block that really…
-
0
votes2
answers2231
viewsA: Show image and upload an input
"fakepath" is a security measure that some browsers implement to prevent javascript from knowing the path of files. I do not believe that there is a way to get the path without resorting to some…
-
4
votes1
answer429
viewsA: Inappropriate behavior when stretching image
This situation happens because the default value of the property display in the elements a and img mute inline for block the moment you apply the position: absolute. That, coupled with the fact that…
-
1
votes3
answers20997
viewsA: Leave td with transparent background
Apply background-color to a style attribute: <td style="background-color: rgba(123, 123, 123, 0.5)"> The value 0.5 is the amount of transparency you want to put into the color. It varies…
-
8
votes2
answers1210
viewsA: How to list more than 50 Youtube videos using Curl
In the URL there is the parameter start-index. If the value is 1, the results will be brought from 1 to 50. If the value is 2, the results will be brought from 2 to 51. And so on and so forth. You…
-
3
votes1
answer1183
viewsA: How to compare the value of numbers saved as VARCHAR in mysql?
You can use a cast to decimal. So: SELECT coordenadas_cache.endereco FROM coordenadas_cache WHERE latitude_sul <= CAST('-29.123456' AS DECIMAL(10,5)) AND latitude_norte >= CAST('-29.123456' AS…
-
-2
votes3
answers694
viewsA: Using function and header file (header)
Try Codecount. h, change the code to: #ifndef __CODECOUNT_H__ #define __CODECOUNT_H__ void imprime(); #endif In theory your error message has nothing to do with duplicate references, but I’m running…
canswered Michael Siegwarth 3,427 -
18
votes4
answers43355
viewsA: Check if string has only numbers
Option 1 (Javascript only): function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } isNumber('123'); // true isNumber('asda123'); // false Option 2 (using jQuery):…
-
6
votes1
answer4759
viewsA: Change class when resizing screen
You can use the event resize jQuery. The code below adds the classes when the page is loaded, and later, every time the screen is resized (triggering the event resize): function addIconClasses() {…
jqueryanswered Michael Siegwarth 3,427 -
2
votes2
answers887
viewsA: Replace symbols < /> with Javascript
Depending on your requirements, one option may be to use the tag xmp instead of a Javascript. It is "deprecated", but works on most browsers. <xmp> <a href="blabla">bleble</a>…
-
5
votes2
answers306
viewsA: How to do data Mining in a txt file with re.finditer
To get the full sentences, you can do so: import re f = open('C:/pah.txt','r+') text = f.read() words = ['batman','sei'] for x in words: sentences = [sentence for sentence in re.split('\.|\?|!',…
pythonanswered Michael Siegwarth 3,427 -
1
votes3
answers243
viewsA: Regex for hexadecimal colors
Here comes the expression: ^#((\w{2})(\w{2})(\w{2})|(\w{3}))$ I basically added a new condition for the 3-character case, and also a $, indicating that the string should end there. As a bonus, here…
-
1
votes1
answer119
viewsA: Recover Text and Value from Select with KENDO MVVM
The correct bind syntax of a select, according to the documentation of Knockout is like this: <select data-bind="options: availableCountries, optionsText: function(item) { return item.countryName…
-
8
votes2
answers10718
viewsA: Search the entire database
In phpMyAdmin, use the search feature: Select the Data Base Click on the search tab ("Search") Choose the terms you want to search for Choose the tables you want to search for Go!…
-
6
votes2
answers3494
viewsA: How to change the text of the OK button of Alert?
One option is to use some plugin that builds a custom confirmation window. The advantage is to be able to style with the colors and text you want. The downside is having to use one more plugin in…
-
6
votes2
answers17667
viewsA: How to send string variables as parameter to call Ajax?
Just specify a javascript object: var foo = "bar"; var bar = "foo"; function register(){ $.ajax({ method: "post", url: "meu_script.php", data: {foo: foo, bar: bar}, }); } To be a little less…
-
2
votes1
answer319
viewsA: How to make a query inside an XML file?
The SelectSingleNode allows you to browse the XML file according to its structure: XmlDocument doc = new XmlDocument(); doc.Load("c:\\seu_arquivo.xml"); XmlNode node =…
-
2
votes2
answers180
viewsA: In the Firebug Javascript debug, how to display the current line of code?
In my case, I can go back to the current point of the code by clicking on the last item of the main bar that is inside the "Script" tab. It usually shows the name of the function you are currently…
javascriptanswered Michael Siegwarth 3,427 -
2
votes1
answer369
viewsA: Find HTML inside an iframe
Search for the URL of iframe on the page, and open with the webbrowser. In the case of the link you passed, the URL is this:…
-
2
votes1
answer161
viewsA: PHP crypt password
Case 1: In the first example, you are adding a Salt ('st') when calling the function crypt. I believe the problem is there, since it is the only visible difference. Change the second example to:…
-
2
votes2
answers515
viewsA: Which jquery plugin allows you to select days and events each day in a horizontal Timeline?
I believe the solution is even in using some plugin. I think a variant of lightbox can solve your problem well. In any case, if you want to implement the solution, I have put together a very basic…
-
7
votes2
answers835
viewsA: How to make an effect by adding a new item to a list
I’m guessing you’re only interested in the visual part of the thing, and you’ve already solved the part about bringing the data from the server. I created a very basic example, using jQuery. It’s…
-
1
votes2
answers65
viewsA: Consulting type passed via generic method
Use the typeof. Then, just get the string with the name, and apply on the switch, thus: Type tipoEntidade = typeof(TEntidade); string tipo = tipoEntidade.FullName; switch (tipo) { ... }…
-
5
votes3
answers3820
viewsA: Changing LABEL value by Jquery or Javascript does not work in ASP.NET
The option value is not applicable for Abels. Try to exchange for innerHTML. Thus: document.getElementById('<%= Label4.ClientID %>').innerHTML = "Habilitado";…
-
14
votes3
answers39348
viewsA: Function to add more hours or days to a date
Just to complement: depending on the project, it might be a good idea to use the library Moment js., who takes very good care of this type of situation. You can do things like this here: // Criar…
javascriptanswered Michael Siegwarth 3,427 -
41
votes6
answers5796
viewsA: How is computer randomization generated?
The answer is based on the concepts of "random seed" (or "Seed"), and "pseudorandom number generators". Why "pseudo"? Because the random numbers that are appearing in your call to Math.random() are…
-
9
votes1
answer233
viewsA: Track navigation with Analytics from single pages that have Javascript navigation
Google Analytics has an event tracking system that I believe applies to your needs. The details are here: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide You add…
-
1
votes5
answers6608
viewsA: Capture dates of a text using regular expression in javascript
var reg = /([0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4})/g; var str = "Um texto com uma data aqui 01/01/2012 e mais uma aqui 03/04/2000"; var todasAsDatas = str.match(reg); It is important to remember that the…
-
2
votes2
answers160
viewsA: Unittest Django Views: I can’t log into the system by unittest
I believe that any of these three options will solve the problem: 1) Change the test client: Instead of instantiating the client with c = Client(), use the client that already comes with Testcase.…
-
3
votes5
answers20277
viewsA: How do I use @import in a CSS file?
As already mentioned by @woliveirajr, the @import should be on the first line of the file. Just one comment: remember to consider that the use of @import can bring a negative impact on the…
-
1
votes2
answers960
viewsA: How to format several bxSlider on the same page with different styles?
(I am editing the answer completely because the solution will be quite different than I predicted) The Problem When you apply bxSlider to an element, it changes the structure of HTML. See only:…