Skip to content

Instantly share code, notes, and snippets.

View masatomo's full-sized avatar

Masatomo Nakano masatomo

View GitHub Profile
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="en-note">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="div">
<p>
<xsl:apply-templates/>
</p>
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#!/bin/sh
# resque wrapper for monit
# see also http://mmonit.com/wiki/Monit/FAQ#pidfile
usage()
{
echo "usage: ${0} {start|stop} <any_process_keyword>"
exit 1
}
set httpd port 2812
allow 192.168.123.0/24 # allow localhost to connect to the server and
set daemon 120 # check services at 2-minute intervals
with start delay 240 # optional: delay the first check by 4-minutes
# (by default check immediately after monit start)
set logfile syslog facility log_daemon
set idfile /usr/local/app/APPLICATION/shared/monit.id
#!/bin/sh
# resque_scheduler wrapper for monit
# see also http://mmonit.com/wiki/Monit/FAQ#pidfile
usage()
{
echo "usage: ${0} {start|stop}"
exit 1
}
check process resque-scheduler with pidfile /usr/local/app/APPLICATION/shared/pids/resque_scheduler.pid
group resque_scheduler
start program = "/usr/local/app/APPLICATION/current/script/resque_scheduler start"
stop program = "/usr/local/app/APPLICATION/current/script/resque_scheduler stop"
doc1: {"num": [3, 10, 25], "type": "A"}
doc2: {"num": [1, 2, 3, 5], "type": "B"}
doc3: {"num": [5, 6, 7, 1], "type": "A"}
At the moment, i can do that something like:
db.something.find({"type": "A"}, {"num": 1})
I get something like:
"num": [5, 6, 7, 1]
"num": [3, 10, 25]
SELECT d.nspname, b.relname, h.attname FROM pg_class b
JOIN pg_namespace d ON b.relnamespace=d.oid
join pg_attribute h on (b.oid=h.attrelid)
where b.relkind='r' and h.attname like '%_id'
and not exists (select true from pg_constraint e
join pg_class f on (f.oid=e.conrelid) where e.conrelid = b.oid and e.contype='f') and h.attnum > 0
and d.nspname not in ('pg_catalog', 'information_schema');
@masatomo
masatomo / sequence.rb
Created December 6, 2010 18:19
adds a feature to set sequence number to Mongoid::Document
# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to add automatic sequence feature
# usage:
# Class KlassName
# include Mongoid::Document
# include Mongoid::Sequence
# ...
# field :number, :type=>Integer
# sequence :number
@masatomo
masatomo / gist:951199
Created May 2, 2011 05:25
logging POST body in Google App Engine
class LoggerMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, env, start_response):
request = webapp.Request(env)
if request.body:
logging.info(request.body)
return self.app(env, start_response)