Skip to content

Instantly share code, notes, and snippets.

implicit def toFilter1(property:Symbol) = new {
def ===(value:Any):Query => Query =
query => query.addFilter(property.toString, Query.FilterOperator.EQUAL, value)
}
class DataStore(){
val ds = DatastoreServiceFactory.getDatastoreService()
def from(name:Symbol) = new Filter(ds, new Query(name.toString))
}
class Filter(ds:DatastoreService, query:Query){ def where(predicate:Query => Query) = new FetchOption(ds, predicate(query))}
class FetchOption(ds:DatastoreService, query:Query){
package cn.orz.pascal.gae
import javax.servlet.http.{HttpServletResponse => Response, HttpServletRequest => Request}
import com.google.appengine.api.users.{User, UserService, UserServiceFactory}
import com.google.appengine.api.datastore._
import cn.orz.pascal.gae.persist.DataStore
import pascal.gae.framework.AbstractRoute
object Route extends AbstractRoute{
// ifによる記述
String x;
if(n % 15 == 0){
x = "FizzBuzz";
}else if(n % 5 == 0){
x = "Fizz";
}else if(n % 3 == 0){
x = "Buzz";
}else{
x = x.toString();
<?php
print "演算子優先順位がへんだから、期待通りに動作しない\n";
foreach(range(1, 30) as $x){
print ($x % 15 == 0) ? "FizzBuzz"
:($x % 5 == 0) ? "Fizz"
:($x % 3 == 0) ? "Buzz"
: $x;
print "\n";
}
def split xs
if xs.size == 1 then return [xs, []] end
[xs[0..(xs.length / 2 -1)],
xs[(xs.length / 2)..-1 ]]
end
def merge args
l, r = args
inf = 1.0 / 0
<?php
function p($xs){
foreach($xs as $x) print("$x ");
print "\n";
}
function split2($xs){
if(count($xs) == 1) return array($xs, array());
@koduki
koduki / ruby_api_search.js
Created July 18, 2009 22:44
rubysearch.js
CmdUtils.CreateCommand({
name: "ruby api search",
icon: "http://doc.loveruby.net/refm/api/theme/default/rurema.png",
description: "るりまからRubyのAPIを検索",
help: "How to use your command.",
author: {name: "koduki", email: "[email protected]"},
homepage: "http://gist.github.com/149718",
arguments: {type: noun_arb_text, object: noun_arb_text},
preview: function preview(pblock, args) {
var xs = args.object.html.toString().split(" ");
-- client side
<script>
function f = 2
function echo = ...
//一番近いfを呼ぶので2
alert(f());
//クライアントにmath.fが無いので2
alert(math.f());
require 'rubygems'
# intericense
require 'irb/completion'
# history
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
// ==UserScript==
// @name Rakuten Books Plus
// @namespace cn.orz.pascal.rakuten
// @include http://item.rakuten.co.jp/book/6184213/
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.2/jquery.js
// ==/UserScript==
$(function(){
var xfind = function(xpath){
var r = document.evaluate(xpath, document, null, 6, null );
var xs = new Array(r.snapshotLength);