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
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>
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gerenciador de Coleções</title>
</head>
<body>
</body>
</html>
@jctosta
jctosta / linux_cheatsheet.md
Last active October 21, 2021 20:50
Linux - Comandos úteis

Linux - Comandos Úteis

  • O comando abaixo força o git a sempre utilizar o protocolo https em seus downloads:
    • git config --global url."https://".insteadOf git://
  • Configuração de Proxy no GIT:
    • git config --global http.proxy http://proxyuser:proxypass@prxrj.prevnet:8080
    • git config --global https.proxy http://proxyuser:proxypass@prxrj.prevnet:8080
  • Liberar autenticação do proxy em ambientes sem interface gráfica (Resolve o problema do erro 407 ao realizar requisições):
    • curl -v -U proxyuser:proxypass -x http://prxrj.prevnet:8080 --url http://www.google.com --proxy-ntlm
  • Matar todos os processos Zumbi:
@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>
@jctosta
jctosta / check_location.js
Created August 6, 2014 17:31
Check Machine Location
#!/usr/bin/env node
var args = process.argv.slice(2);
//console.log('Started');
// String startsWith polyfill
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
@jctosta
jctosta / screen_cheatsheet.markdown
Last active April 25, 2024 14:39
Screen Cheatsheet

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r