This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns try-typed.core | |
(:require [clojure.core.typed :refer :all])) | |
; String型の引数をとりnilを返す | |
(ann foo [String -> nil]) | |
(defn foo | |
"I don't do a whole lot." | |
[x] | |
(println x "Hello, World!")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns try-itext.core | |
(:import [com.itextpdf.text | |
Document PageSize Paragraph Font | |
pdf.PdfWriter pdf.BaseFont] | |
[java.io FileOutputStream]) | |
(:gen-class)) | |
(defn create-pdf [] | |
(with-open [pdf-doc (Document. PageSize/A4 50 50 50 40)] | |
(doto pdf-doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns try-itext-compojure.handler | |
(:require [ring.util.response :as response] | |
[compojure.core :refer [defroutes GET]] | |
[compojure.handler :as handler] | |
[compojure.route :as route] | |
[korma.db :refer [defdb sqlite3]] | |
[korma.core :as korma]) | |
(:import [com.itextpdf.text | |
Document PageSize Paragraph Font] | |
[com.itextpdf.text.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
$inputFilter->add(array( | |
'name' => 'title', | |
'required' => true, | |
'filters' => array( | |
array('name' => 'StripTags'), | |
array('name' => 'StringTrim'), | |
), | |
'validators' => array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 半角数字のバリデータ | |
* | |
* @return array バリデータのspec | |
*/ | |
public static function digitsValidator() | |
{ | |
return array( | |
'name' =>'Digits', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Album\Helper; | |
use Zend\Form\View\Helper\FormElementErrors as ZendFormElementErrors; | |
/** | |
* フォームのバリデーションエラーメッセージ表示用ビューヘルパー | |
*/ | |
class FormElementErrors extends ZendFormElementErrors | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//... | |
//tableGatewayインスタンスからAdapterを取得する場合 | |
$adapter = $this->tableGateway->getAdapter(); | |
//ServiceManagerからAdapterを取得する場合 | |
$sm = $this->getServiceLocator(); | |
$adapter = $sm->get('Zend\Db\Adapter\Adapter'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$resultSet = $this->tableGateway->select(function ($select) { | |
$select->where(array( | |
'id' => 1, | |
'release_date > ?' => date('Y-m-d', strtotime('-1 year')) | |
)); | |
$select->where->like('artist', 'The%'); | |
$select->order('artist'); | |
//echo $select->getSqlString($this->tableGateway->getAdapter()->getPlatform()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sm = $this->getServiceLocator(); | |
$adapter = $sm->get('Zend\Db\Adapter\Adapter'); | |
$sql = new \Zend\Db\Sql\Sql($adapter); | |
$select = $sql->select(); | |
$select->from('album'); | |
//echo $select->getSqlString($adapter->getPlatform()); | |
$statement = $sql->prepareStatementForSqlObject($select); | |
$resultSet = $statement->execute(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sm = $this->getServiceLocator(); | |
$adapter = $sm->get('Zend\Db\Adapter\Adapter'); | |
$sql = new \Zend\Db\Sql\Sql($adapter); | |
$select = $sql->select(); | |
$select->from('album'); | |
$select->join( | |
'track', | |
'album.id = track.album_id', | |
array( |