Skip to content

Instantly share code, notes, and snippets.

View jnwelzel's full-sized avatar
💻
[object Object]

Jonathan Welzel jnwelzel

💻
[object Object]
View GitHub Profile
@jnwelzel
jnwelzel / conhecimento_transporte.rb
Created July 23, 2012 14:09
Super classe usada no projeto CT-e para definir um objeto que possa ser tanto persistido como serializado para XML
# encoding: utf-8
class EntidadeCte
include Mongoid::Document
include ROXML
class << self
# apelida o xml_accessor do ROXML para cte_attr
# alias :cte_attr :xml_accessor
@jnwelzel
jnwelzel / estados.json
Created August 1, 2012 14:30
JSON que eu usei para gerar os documents da collection de estados no mongodb
[{"_id":11,"nome":"Rond\u00f4nia","pais_id":1058,"sigla":"RO"},{"_id":12,"nome":"Acre","pais_id":1058,"sigla":"AC"},{"_id":13,"nome":"Amazonas","pais_id":1058,"sigla":"AM"},{"_id":14,"nome":"Roraima","pais_id":1058,"sigla":"RR"},{"_id":15,"nome":"Par\u00e1","pais_id":1058,"sigla":"PA"},{"_id":16,"nome":"Amap\u00e1","pais_id":1058,"sigla":"AP"},{"_id":17,"nome":"Tocantins","pais_id":1058,"sigla":"TO"},{"_id":21,"nome":"Maranh\u00e3o","pais_id":1058,"sigla":"MA"},{"_id":22,"nome":"Piau\u00ed","pais_id":1058,"sigla":"PI"},{"_id":23,"nome":"Cear\u00e1","pais_id":1058,"sigla":"CE"},{"_id":24,"nome":"Rio Grande do Norte","pais_id":1058,"sigla":"RN"},{"_id":25,"nome":"Para\u00edba","pais_id":1058,"sigla":"PB"},{"_id":26,"nome":"Pernambuco","pais_id":1058,"sigla":"PE"},{"_id":27,"nome":"Alagoas","pais_id":1058,"sigla":"AL"},{"_id":28,"nome":"Sergipe","pais_id":1058,"sigla":"SE"},{"_id":29,"nome":"Bahia","pais_id":1058,"sigla":"BA"},{"_id":31,"nome":"Minas Gerais","pais_id":1058,"sigla":"MG"},{"_id":32,"nome":"Esp\u00
@jnwelzel
jnwelzel / cidades.json
Created August 1, 2012 14:44
JSON que eu usei para gerar os documents da collection de cidades no mongodb
[{"estado_id":11,"_id":1100015,"nome":"Alta Floresta D'Oeste"},{"estado_id":11,"_id":1100023,"nome":"Ariquemes"},{"estado_id":11,"_id":1100031,"nome":"Cabixi"},{"estado_id":11,"_id":1100049,"nome":"Cacoal"},{"estado_id":11,"_id":1100056,"nome":"Cerejeiras"},{"estado_id":11,"_id":1100064,"nome":"Colorado do Oeste"},{"estado_id":11,"_id":1100072,"nome":"Corumbiara"},{"estado_id":11,"_id":1100080,"nome":"Costa Marques"},{"estado_id":11,"_id":1100098,"nome":"Espig\u00e3o D'Oeste"},{"estado_id":11,"_id":1100106,"nome":"Guajar\u00e1-Mirim"},{"estado_id":11,"_id":1100114,"nome":"Jaru"},{"estado_id":11,"_id":1100122,"nome":"Ji-Paran\u00e1"},{"estado_id":11,"_id":1100130,"nome":"Machadinho D'Oeste"},{"estado_id":11,"_id":1100148,"nome":"Nova Brasil\u00e2ndia D'Oeste"},{"estado_id":11,"_id":1100155,"nome":"Ouro Preto do Oeste"},{"estado_id":11,"_id":1100189,"nome":"Pimenta Bueno"},{"estado_id":11,"_id":1100205,"nome":"Porto Velho"},{"estado_id":11,"_id":1100254,"nome":"Presidente M\u00e9dici"},{"estado_id":11,"_id":110
@jnwelzel
jnwelzel / company_user_rel.rb
Created August 13, 2012 18:22
Company -> User (owner)
class Company
include Mongoid::Document
include Mongoid::Timestamps
has_and_belongs_to_many :users
belongs_to :owner, class_name: "User", inverse_of: :owns
end
class User
include Mongoid::Document
@import "jbar.colors";
@import "jbar";
@jnwelzel
jnwelzel / HttpProxyAuth.java
Created April 4, 2013 17:04
The boilerplate needed to make a http request behind a proxy that requires authentication
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
HttpConnectionParams.setSoTimeout(httpParams, 5000);
DefaultHttpClient client = new DefaultHttpClient(httpParams);
client.getCredentialsProvider().setCredentials(
new AuthScope(PROXY_HOSTNAME, PROXY_PORT),
new UsernamePasswordCredentials(PROXY_USERNAME, PROXY_USERPWD));
HttpHost proxy = new HttpHost(PROXY_HOSTNAME, PROXY_PORT);
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
@jnwelzel
jnwelzel / certificates.txt
Last active May 9, 2021 22:32
Client authentication through SSL certificate in JBoss AS 7.1.1.Final. This configuration will make sure that only clients whose certificates are trusted by the server may have access to the application (standalone.xml line 272)
PASSWORD
changethis
SERVER KEYSTORE - used by the server to establish a secure connection (HTTPS)
c:\eclipse\jdk1.7.0_05\jre\bin\keytool.exe -genkey -keyalg RSA -alias localhost -keystore localhost.jks -validity 365 -keysize 2048
CLIENT KEYSTORE - used to generate ".cer" file that wil be used in the server's trustore and in the browser to identify the client with the server
c:\eclipse\jdk1.7.0_05\jre\bin\keytool.exe -genkey -keyalg RSA -alias jonwelzel -keystore jonwelzel.jks -validity 365 -keysize 2048
# 1. not working
redirect_to contact_path(@message), :flash => { :error => "Captcha error! The image code you informed is incorrect."}
# 2. not working
flash[:error] = "Captcha error! The image code you informed is incorrect."
redirect_to contact_path(@message)
# 3. WORKING
flash[:error] = "Captcha error! The image code you informed is incorrect."
render "new"
@jnwelzel
jnwelzel / search_form.scala.html
Created July 20, 2013 18:04
twitter bootstrap search form the way i like it
<div id="actions">
<form action="@link(0, "name")" method="GET" class="form-search">
<div class="input-append">
<input type="search" id="searchbox" name="f" value="@currentFilter" placeholder="Filter by device name..." class="input-medium search-query">
<button type="submit" id="device-search-submit" class="btn"><i class="icon-search"></i> Search</button>
</div>
</form>
</div>
@jnwelzel
jnwelzel / sql_notes.sql
Last active January 2, 2016 11:49
Since I suck at SQL, here are a few notes and reminders if ever my memory fails me (and it always does)
UPDATE table_name
SET column1=value1
WHERE some_column=some_value;
ALTER TABLE table_name
ADD column_name datatype;
/* SQL Server */
alter table DEFAULT_PROPRIED_DOCTO
add VERSION bigint not null default 1;