This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from rest_framework.response import Response | |
| from rest_framework.decorators import api_view, renderer_classes, permission_classes, authentication_classes | |
| from rest_framework.renderers import JSONRenderer | |
| from rest_framework.permissions import IsAuthenticated | |
| from rest_framework_jwt.authentication import JSONWebTokenAuthentication | |
| @api_view(['GET']) | |
| @renderer_classes((JSONRenderer,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *.strings diff=localizablestrings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LOGGING = { | |
| 'handlers': { | |
| 'logstash': { | |
| 'level': 'DEBUG', | |
| 'class': 'logstash.LogstashHandler', | |
| 'host': 'localhost', | |
| 'port': 5000, # Default port of logstash | |
| 'version': 1, # Version of logstash event schema. Default value: 0 (for backward compatibility of the library) | |
| 'message_type': 'logstash', # 'type' field in logstash message. Default value: 'logstash'. | |
| 'fqdn': False, # Fully qualified domain name. Default value: false. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def to_arabic(value) | |
| value = value.upcase | |
| result = 0 | |
| last_number = 0 | |
| if validate_roman(value) | |
| (value.length - 1).downto(0) do |i| | |
| result = calculate_value(@roman_decimal_map[value[i].to_sym], last_number, result) | |
| last_number = @roman_decimal_map[value[i].to_sym] | |
| end | |
| return result |
- Criar um arquivo unicorn.rb com o seguinte conteúdo
if ENV['IDE_PROCESS_DISPATCHER']
timeout TIMEOUT_EM_SEG_QUE_VC_QUER
end
- na configuração do servidor de debug colocar o seguinte
-c config/unicorn.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hotels = {} | |
| def calculate_rate(number_days_weekdays, number_days_weekend, hotel) | |
| (hotel.weekday_rate * number_days_weekdays) + (hotel.weekend_rate * number_days_weekend) | |
| end | |
| def calculate_cheapest_hotel() | |
| @rates = hotels.each {|hotel| calculate_rate(customer.number_weekdays, customer.number_weekend, hotel) | |
| @rates.sort { |r1, r2| r1 <=> r2}.first | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def merge_sort(arr, p, r): | |
| if p>=r: | |
| return arr | |
| else: | |
| q = int((p+r)/2) | |
| merge_sort(arr, p, q) | |
| merge_sort(arr, q+1,r) | |
| merge(arr, p, q, r) | |
| def merge(arr, p, q, r): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION truncate_tables(_schema IN VARCHAR) RETURNS void AS $$ | |
| DECLARE | |
| statements CURSOR FOR | |
| SELECT tablename, schemaname FROM pg_tables | |
| WHERE schemaname = _schema; | |
| BEGIN | |
| FOR stmt IN statements LOOP | |
| EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.schemaname) || '.' || quote_ident(stmt.tablename) || ' CASCADE;'; | |
| END LOOP; | |
| END; |