Skip to content

Instantly share code, notes, and snippets.

@maji-KY
maji-KY / HttpBackdoor.java
Created September 23, 2011 11:11
HttpBackdoor
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URL;
import java.util.List;
import java.util.Map.Entry;
import com.sun.net.httpserver.Headers;
@maji-KY
maji-KY / SendJavaMail.java
Created October 1, 2011 14:31
JavaMail Example
//staticインポート...
import static javax.mail.Message.RecipientType.TO;
import java.io.IOException;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
@maji-KY
maji-KY / glassfish
Created December 5, 2012 13:48
GlassFish Init Script
#!/bin/sh
#
# glassfish Startup script for glassfish
#
# chkconfig: - 99 01
# processname: glassfish
# config: /etc/glassfish/glassfish.conf
# config: /etc/sysconfig/glassfish
# pidfile: /var/run/glassfish.pid
# description: glassfish is a JavaEE Application Server
@maji-KY
maji-KY / myapp.conf
Created January 20, 2013 13:37
LogWatch java app
##########################################################################
# $Id: myApp,v 1.0 2012/12/23 20:35:04 maji-KY $
##########################################################################
#
#
########################################################
#use diagnostics;
#use strict;
#use warnings;
@maji-KY
maji-KY / JsonTest.scala
Created October 18, 2014 13:43
json4sでcase classをJSONにシリアライズするときにキーをスネークケースにしたい
import org.json4s.jackson.{JsonMethods, Serialization}
import org.json4s.{Extraction, Formats, NoTypeHints}
object JsonTest extends App {
// Extraction.decomposeでJSON ASTを組み立てている
// んで、それにはsnakizeKeysってメソッドがあるのでそれを使えばスネークケースになる
def myWrite[A <: AnyRef](a: A)(implicit formats: Formats): String = JsonMethods.mapper.writeValueAsString(Extraction.decompose(a)(formats).snakizeKeys)
// プリティ☆バージョン
@maji-KY
maji-KY / processing.sbt
Last active August 29, 2015 14:15
processing with sbt
organization := "com.neco-labo"
name := "processing with sbt"
version := "0.1"
scalaVersion := "2.11.5"
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked")
@maji-KY
maji-KY / ShowTest.scala
Created February 15, 2015 15:58
processing swing
package com.neco_labo.processiong
import javax.swing.JFrame
import com.neco_labo.processing.Test
/**
* Created by maji-KY on 2015/02/14.
*/
object ShowTest extends App {
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>react</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
@maji-KY
maji-KY / JDBI.scala
Created March 17, 2015 06:53
sample JDBI with hikariCP
package com.neco_labo.db
import com.zaxxer.hikari.{HikariDataSource, HikariConfig}
import org.skife.jdbi.v2.{DefaultMapper, DBI}
import scala.collection.JavaConverters._
object JDBI extends App {
val config = new HikariConfig()
@maji-KY
maji-KY / JDBI2.scala
Created March 18, 2015 07:57
JDBI in Scala
package com.neco_labo.db
import java.sql.ResultSet
import com.zaxxer.hikari.{HikariDataSource, HikariConfig}
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper
import org.skife.jdbi.v2.sqlobject.{BindBean, Bind, SqlQuery}
import org.skife.jdbi.v2.tweak.ResultSetMapper
import org.skife.jdbi.v2.{StatementContext, DefaultMapper, DBI}