Skip to content

Instantly share code, notes, and snippets.

View dalmat36's full-sized avatar

Matt Dalesio dalmat36

View GitHub Profile
String dateTimeStr = "2015120102"
DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMddHH")
DateTime datetime = dtf.parseDateTime(dateTimeStr).withZoneRetainFields(DateTimeZone.forOffsetHours(9))
println(datetime)
//Result: 2015-12-01T02:00:00.000+09:00
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-feed="http://www.springframework.org/schema/integration/feed"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.1.xsd">
<int:channel id="inputRssFeedChannel"/>
package blog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
public class RssReader implements MessageSource<String> {
private static Logger logger = LoggerFactory.getLogger(RssReader.class);
@dalmat36
dalmat36 / RssFeedMessageHandler.java
Created October 29, 2015 17:36
Message handler to perform action on received message from RSS feed
package blog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.Message;
import com.sun.syndication.feed.synd.SyndEntry;
public class RssFeedMessageHandler {
package springampqtest;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
package springampqtest;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
public class Main {
public static void main(String[] args) throws Exception {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory("hostName");
connectionFactory.setUsername("guest");
using UnityEngine;
using System.Collections;
public class Spin : MonoBehaviour {
public float speed = 3.0f;
// Update is called once per frame
void Update () {
transform.Rotate (0, speed, 0);
}
@dalmat36
dalmat36 / GroovySQLQueryPerson.groovy
Created July 22, 2015 19:49
Query result from Database using Groovy
import java.sql.ResultSet
import groovy.sql.Sql;
class GroovySQLQueryPerson {
static main(args) {
def db = Sql.newInstance("jdbc:sqlserver://localhost;databaseName=MyDB;integratedSecurity=true", '', '', 'com.microsoft.sqlserver.jdbc.SQLServerDriver')
db.query('SELECT id FROM Person WHERE name = ?', ["Sam"]){ ResultSet rs ->
while(rs.next()) println rs.getInt("id")
}
import groovy.json.JsonBuilder
class GroovyJsonBuilderPerson {
static main(args) {
def json = new JsonBuilder()
json.'person'{
'firstName' ('matt')
'lastName'('Dalesio')
'age'(30)
package groovyCollectionTesting
class GroovyCollectionTesting {
static main(args) {
def person1 = new Person("matt", "dalesio", 30)
def person2 = new Person("matt", "smith", 30)
def person3 = new Person("melissa", "cowan", 26)