Skip to content

Instantly share code, notes, and snippets.

View miere's full-sized avatar
😁
Distributing data among friends

Miere Teixeira miere

😁
Distributing data among friends
View GitHub Profile
@miere
miere / RELEASE.md
Last active April 7, 2016 18:54
Sizebay Catalog API - client java
package sizebay.intelligence.security;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/**
*
lombok.accessors.fluent=true
lombok.accessors.chain=true
lombok.nonNull.exceptionType=IllegalArgumentException
@miere
miere / lang-date.js
Created July 6, 2015 18:41
Very tiny utility for date manipulation.
/**
* Sample:
* new Date().add( 20, Date.DAY ) // will point to 20 ahead from today
* new Date().add( -20, Date.DAY ) // will point to 20 ago from today
*/
Date.SECOND = 1000
Date.MINUTE = (60*Date.SECOND)
Date.HOUR = (60*Date.MINUTE)
Date.DAY = (24*Date.HOUR)
@RequiredArgsConstructor
final public class NamedThreadFactory implements ThreadFactory {
private final AtomicInteger counter = new AtomicInteger(1);
final private String baseName;
@Override
public Thread newThread(final Runnable r) {
final Thread thread = new Thread(r, getNextMethod());
thread.setDaemon(true);
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="Eclipselink_JPA" transaction-type="RESOURCE_LOCAL">
<!-- which one will be the Persistence Provider that will provide the JPA implementation? -->
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
@Singleton
public class ConnectionProvider {
public Connection provideConnection() throws Exception {
Class.forName("org.sqlite.JDBC");
return DriverManager.getConnection("jdbc:sqlite:/tmp/nbwy.db");
}
}
@miere
miere / Method.js
Created October 20, 2014 19:53
fake polymorphic method. It will switch between number of arguments but will make no distinction between types
/**
* fake polymorphic method. It will switch between number of arguments but will
* make no distinction between types.
*/
function Method( args ){
if ( this instanceof Method ) {
this.expectations = {}
this.target = args || window
} else
return new Method()
@miere
miere / todolist.html
Created October 20, 2014 17:46
Hypothetical two-way binding API for improvement
<div id="template">
<fieldset>
<legend>New task</legend>
<form>
<input type="text" id="title" placeholder="Title" />
<input type="text" id="description" placeholder="Description" />
<button class="btn-primary btn-add">Adicionar</button>
</form>
</fieldset>
package tests.helper;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Class with helper methods to read file content from your classpath.
* It is especially useful when need to compare big string output with
* a file that contains the expected response.