Skip to content

Instantly share code, notes, and snippets.

View jctosta's full-sized avatar

Carlos Tosta jctosta

  • Rio de Janeiro, Brazil
View GitHub Profile
@jctosta
jctosta / cors-wso2.md
Created June 27, 2014 23:21
Configuração CORS Filter WSO2

Configuração de Cross Origin no WSO2

Para configurar o filtro Cross Origin no WSO2 é necessário editar o arquivo <APIM_HOME>/repository/deployment/server/webapps/oauth2/WEB-INF/web.xml, adicionando a seguinte informação no final do arquivo:

<filter>
	<filter-name>CORS</filter-name>
	<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
</filter>
class CurrenciesController < ApplicationController
# GET /currencies
# GET /currencies.xml
def index
@currencies = Currency.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @currencies }
end
@jctosta
jctosta / readfile.rb
Created March 23, 2011 02:14
Leitura de arquivos com ruby
file = File.new("arquivo.rb", "r")
while (line = file.gets)
puts line
end
file.close
@jctosta
jctosta / arquivo_with_exception_handling.rb
Created March 23, 2011 02:31
Leitura de arquivos com tratamento de exceção em ruby
begin
file = File.new("arquivo.rb", "r")
while (line = file.gets)
puts line
end
file.close
rescue => err
puts "Exception: #{err}"
err
end
@jctosta
jctosta / maven-resources-plugin-config.xml
Created August 5, 2011 21:55
Configure maven plugin
<project>
...
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gerenciador de Coleções</title>
</head>
<body>
</body>
</html>
@jctosta
jctosta / programming_tips.md
Created June 3, 2017 11:47
Programming Tips

Programming Tips (Dicas de Programação)

Linguagem C

Definir Locale para exibição de caractéres acentuados no console

Incluir a biblioteca locale.h no cabeçalho da página:

#include 
@jctosta
jctosta / nerdtech2.md
Last active July 24, 2017 13:05 — forked from peas/nerdtech2.md
Links que citamos no NerdTech #2
{
"canvas": {
"parcerias_principais": {
"title": "Parcerias Principais",
"color": "blue_canvas",
"cards": [
{ "label": "Loja de Noivas", "description": "" },
{ "label": "Lojas de Aniversário", "description": "" },
{ "label": "Animadores de Festa", "description": "" },
{ "label": "Empresas de Entrega", "description": "" }
@jctosta
jctosta / GoogleSheets.gs
Created May 29, 2019 04:15
A google script to log web service data in a drive sheets
function deg2rad(deg) {
return deg * (Math.PI / 180);
}
function getDistanceFromLatLongInKm(lat1, lon1, lat2, lon2) {
var R = 6371; // Raio do Planeta Terra em KM
var dLat = deg2rad(lat2 - lat1);
var dLon = deg2rad(lon2 - lon1);
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));