Skip to content

Instantly share code, notes, and snippets.

View rponte's full-sized avatar
🏠
Working from home

Rafael Ponte rponte

🏠
Working from home
View GitHub Profile
C:\>sqlcmd -S localhost -U sa -P 1234
1> -- Set TriadWorksDb as the current database
2> USE TriadWorksDb;
3> GO
Changed database context to 'TriadWorksDb'.
1> -- Create a new server login name: rponte
2> CREATE LOGIN rponte WITH PASSWORD = 'TopSecret'
3> GO
IF EXISTS (SELECT name FROM sys.databases WHERE name = N'MyDb')
BEGIN
drop database MyDb
END
// Adding js script dynamically into page..
script = document.createElement("script");
script.src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";
document.body.appendChild(script);
@rponte
rponte / mybatis-scriptrunner-sample.java
Last active August 28, 2018 09:16
MyBatis ScriptRunner Example
// http://mybatis.googlecode.com/svn/trunk/src/test/java/org/apache/ibatis/submitted/sptests/SPTest.java
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:mem:sptest", "sa", "");
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/sptests/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setDelimiter("]");
runner.setLogWriter(null);
@rponte
rponte / CAP-Theorem
Created December 2, 2010 16:03
CAP - Consistency, Availability and Partition-Tolerant
CAP - Consistency, Availability and Partition-Tolerant
The CAP principle states that in distributed computing when it comes
to consistency (C), availability (A) and partition (P)
resilience/tolerance you can have only two of the three.
I was recently introduced to this principle and find it rather
insightful. Basically you can't have your cake and eat it too,
otherwise (computing) life would be too easy.
@rponte
rponte / printer-applet
Created December 6, 2010 18:03
Impressão via Applet
Eu tive problemas ao tentar imprimir diretamente na LPT1 via Applet *assinado*.
Mesmo o Applet sendo assinado sempre era disparado uma exceção de segurança.
Pesquisando pelo Google, por sorte, acabei achando o trecho de código com a solução abaixo:
import java.security.AccessController;
import java.security.PrivilegedAction;
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Impressao impressao = new Impressao();
-- backuping constraints :p
create table antes_da_caca as select * from pg_class;
Postgres 8.3:
------------
Aqui tu vês as constraints para uma tabela:
select nm.nspname, cla.relname, cla.reltriggers, constr.*
from pg_constraint constr inner join pg_class cla on cla.oid = constr.conrelid
inner join pg_namespace nm on nm.oid = cla.relnamespace;
<target name="test" depends="instrument">
<mkdir dir="${test.report.dir}" />
<junit printsummary="on" fork="yes" forkmode="once" haltonfailure="true" haltonerror="true">
<sysproperty key="net.sourceforge.cobertura.datafile" file="${coverage.xml.dir}/cobertura.ser" />
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<classpath>
<!-- Adiciona libs necessarias para o build -->
<path refid="build-classpath" />
<path refid="acceptance-tests-classpath" />
@rponte
rponte / WebAppContextFactory.java
Last active September 24, 2015 16:08
Embedded Jetty with Spring 3.x
package base;
import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import org.mortbay.jetty.webapp.WebAppContext;
import org.springframework.stereotype.Component;
import br.com.syspdv.initializers.DefineHomeInitializer;
#Rode estes comando se tiver problemas de permissão na instalação do nodejs e npm:
sudo find node -type d -exec chmod 777 {} \;
sudo find node -type f -exec chmod 666 {} \;
sudo chown -R $USER /usr/local/{share/man,bin,lib/node}