Skip to content

Instantly share code, notes, and snippets.

View oluies's full-sized avatar

Örjan Angré (Lundberg) oluies

  • Sweden
  • 00:45 (UTC +02:00)
  • X @oluies
View GitHub Profile
@oluies
oluies / XMLToFileWriter.scala
Created October 16, 2011 08:46
XMLToFileWriter
package cusin
import xmlcusin.bo._
import scalaxb.DataRecord
import scalax.io._
import Resource._
import java.util.concurrent.TimeUnit
import akka.actor.Actor.actorOf
import akka.actor.Actor
import akka.actor.ActorRef
package cusin
import scalax.io._
import Resource._
import FileWriterBackend.xmlParserService
import FileWriterBackend.ParseLineRequest
import akka.actor.PoisonPill
object App {
@oluies
oluies / gist:1313710
Created October 25, 2011 18:12
Start akka microkernel from your IDE.
Start microkernel from your IDE.
Main: akka.kernel.Main
VM args: -Xms256m -Xmx1024m -Dakka.home=./kernel -Dlogback.configurationFile=src/main/resources/logback.xml
In kernel directory I have a symlink config -> ../src/main/resources
In the kernel directory I also have an empty deploy directory. Not used, but must be there.
@oluies
oluies / gist:1527721
Created December 28, 2011 12:00
CROSS JOIN to time-slice history table
-- Active status subscribers
-- Exposes Effective_Date as a pushdown predicate, use this to get only one possible value
REPLACE VIEW Subscriber_Snapshot AS
SELECT Cal.Calendar_Date AS Effective_Date
, Sub.Subscriber_Id
, SSN.Status_Code
FROM Sys_Calendar.Calendar Cal
CROSS JOIN Subscriber Sub
INNER JOIN Sub_Status_History SSH
ON Sub.Subscriber_ID = SSN.Subscriber_Id
@oluies
oluies / gist:1527724
Created December 28, 2011 12:01
svn clone to github
git svn clone http://example.googlecode.com/svn -s
git remote add origin [email protected]:example/example.git
git push origin master
@oluies
oluies / gist:1528811
Created December 28, 2011 17:34
Find missing values in seq
CREATE TABLE seqtest(seqval INT);
INSERT INTO seqtest( 3);
INSERT INTO seqtest( 4);
INSERT INTO seqtest( 5);
INSERT INTO seqtest( 8);
INSERT INTO seqtest( 9);
INSERT INTO seqtest(11);
INSERT INTO seqtest(18);
INSERT INTO seqtest(19);
@oluies
oluies / StupidBackoffLanguageModel.scala
Created April 14, 2012 16:43
StupidBackoffLanguageModel
import collection.GenMap
import scala.math
/**
* Created by IntelliJ IDEA.
* User: orjan
* Date: 2012-03-24
* Time: 15:15
* To change this template use File | Settings | File Templates.
*/
function luhn(cardnumber) {
// Build an array with the digits in the card number
var getdigits = /\d/g;
var digits = [];
while (match = getdigits.exec(cardnumber)) {
digits.push(parseInt(match[0], 10));
}
// Run the Luhn algorithm on the array
var sum = 0;
var alt = false;
@oluies
oluies / gist:3413761
Created August 21, 2012 09:03
findGaps
scala> List(3,4,5,8,9,10,12).sliding(2).collect{ case Seq(x, y) if(y != x + 1) => (x,y) }
res39: Iterator[(Int, Int)] = non-empty iterator
scala> .foreach(println(_) )
(5,8)
(10,12)
scala> def findGaps[T <: Int](xs:List[T]) = xs.sliding(2).collect{ case Seq(x, y) if(y != x + 1) => (x,y) }
findGaps: [T <: Int](xs: List[T])Iterator[(T, T)]
@oluies
oluies / gist:3519165
Created August 29, 2012 21:23
Caculating number of weeks based on birthdates
SELECT
calendar_date birth_date,
current_date - birth_date Diff_Days,
CASE WHEN Diff_Days >= 0 THEN (Diff_Days)/7
ELSE (Diff_Days +1) / 7 - 1 END
FROM sys_calendar.calendar
ORDER BY 1