Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View k4200's full-sized avatar

Kazuo Kashima k4200

View GitHub Profile
import java.io.File
import play.api._
import play.api.Application
import play.api.db.slick.Database
import scala.slick.model.codegen.SourceCodeGenerator
import scala.slick.jdbc.meta.createModel
/**
*/
object PlaySlickCodeGenerator {
@k4200
k4200 / fabfile.py
Last active November 28, 2021 10:31
fabfile.py for Play! framework 2.2 multi-project settings.
from fabric.api import local, env, run, roles, execute, put
from fabric.utils import abort
env.user = "playuser"
env.roledefs = {
'web': ['web.example.com'],
'batch': ['batch.example.com']
}
env.num_of_releases = 3
@k4200
k4200 / .emacs
Last active December 20, 2015 17:39
.emacs PHP関連の設定もうちょっと充実させて、ちゃんとバージョン管理する。
(put 'upcase-region 'disabled nil)
(add-to-list 'load-path (expand-file-name "~/.emacs.d/elisp"))
(add-to-list 'load-path (expand-file-name "~/.emacs.d/auto-install"))
;; key bindings
(global-set-key "\C-c\C-c" 'comment-or-uncomment-region)
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
@k4200
k4200 / scraping-yql.html
Created April 3, 2013 05:31
Scrape a page by using YQL
<html>
<header>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/javascripts/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var url = "http://example.com/";
var query = 'select * from html where url="' + url + '" and xpath="*"';
@k4200
k4200 / gist:3088139
Created July 11, 2012 05:12
Calculate height (or width etc.) of a hidden element
/**
* Based on the following discussion:
* http://stackoverflow.com/questions/2345784/jquery-get-height-of-hidden-element-in-jquery
* @param jQuery $elem jQuery object
*/
function getHeightOfHiddenElem($elem) {
$clone = $elem.clone();
$clone.css({'position':'absolute','visibility':'hidden','display':'block'});
$('body').append($clone)
var height = $clone.height();
@k4200
k4200 / gist:2935406
Created June 15, 2012 08:30
Handling MySQL point type with Squeryl
// 1. Class for MySQL point type
class MySQLPoint(val lat: Double, val lng: Double) {
import MySQLPoint._
override def toString = {
lat.toString() + "," + lng.toString()
}
/**
* Gets a binary representation
@k4200
k4200 / gist:1192189
Created September 4, 2011 03:17
jQuery UI Autocomplete for Japanese IME
// jQuery UI doesn't work with Japanese, Chinese and probably other
// languages' IMEs.
//
// This code snippet is a modified code of jQuery UI Autocomplete 1.8.16
// that works with Japanese IME. It's based on the code in the ticket below.
// http://bugs.jqueryui.com/ticket/5933
//
// I briefly tested it, and it seems ok.
// Any comments/feedback would be appreciated.
//
@k4200
k4200 / gist:1183377
Created August 31, 2011 11:55
printToFileを使った例
// http://stackoverflow.com/questions/4604237/how-to-write-to-a-file-in-scala
FileUtils.printToFile(tempFile)(writer => {
val it = Source.fromFile(conf).getLines()
for (line <- it) {
startPattern.findFirstIn(line) match {
case Some(_) =>
while (it.hasNext && it.next.length != 0) {}
case _ =>
writer.println(line)
}
@k4200
k4200 / fizzbuzz.scala
Created July 13, 2011 11:09
FizzBuzz
(1 to 100)foreach{x=>println(if(x%15>0)if(x%5>0)if(x%3>0)x else"Fizz"else"Buzz"else"FizzBuzz")}
@k4200
k4200 / MegaCRUDify.scala
Created July 10, 2011 09:20
A trait that modifies CRUDify a bit
// This file is distributed under the same license as that of Lift.
package com.example
package lib
import net.liftweb.mapper._
import net.liftweb.common._
import net.liftweb.http.S
trait MegaCRUDify[KeyType, CrudType <: KeyedMapper[KeyType, CrudType]]