Skip to content

Instantly share code, notes, and snippets.

@yudai09
yudai09 / gist:4076020
Created November 15, 2012 01:18
モデルのアソシエーション
class Event < ActiveRecord::Base
has_many :days_infos
has_many :participants
# has_many :users
attr_accessible :event_name, :explanation, :password, :url
end
class Participant < ActiveRecord::Base
belongs_to :event
belongs_to :user
@yudai09
yudai09 / gist:4076033
Created November 15, 2012 01:22
ネストしたResourcesの例
# config/routes.rb
resources :events {do |event|
resources :participants
end
@yudai09
yudai09 / install_rails.cent63.sh
Created November 20, 2012 02:54
centOS6.3にrailsをインストールする
#!/usr/bin/env bash
#[OpenSSLのインストール]
{
yum -y install zlib zlib-devel ;
yum -y install openssl-devel ;
yum install gcc make ;
} || exit 1
#[readline-develのインストール]
@yudai09
yudai09 / testfs.py
Last active December 18, 2015 08:39
#!/usr/bin/env python
# step-1
# will mount an FS, but useless beyond that
import errno
import fuse
import os # import os for current uid/gid
import stat # import stat, ExampleFS_Stat class, ExampleFS.getattr
from datetime import date
@yudai09
yudai09 / xmp-2.py
Last active December 18, 2015 16:59
#!/usr/bin/env python
# Copyright (C) 2001 Jeff Epler <jepler@unpythonic.dhs.org>
# Copyright (C) 2006 Csaba Henk <csaba.henk@creo.hu>
#
# This program can be distributed under the terms of the GNU LGPL.
# See the file COPYING.
#
import os, sys
################################################################################
# Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. #
# Leap Motion proprietary and confidential. Not for distribution. #
# Use subject to the terms of the Leap Motion SDK Agreement available at #
# https://developer.leapmotion.com/sdk_agreement, or another agreement #
# between Leap Motion and you, your company or other organization. #
################################################################################
import Leap, sys, thread, time, math
from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture
watchfor /error:/
pipe "./forward_fluent.sh swatch.err"
echo red
watchfor /warning:/
pipe "./forward_fluent.sh swatch.warn"
echo yellow
watchfor /no problem/
# nothing to do
echo
watchfor /.*/
#!/bin/sh
# pipeで受け取った標準入力をfluent-catで送り出す
tag=$1
if [ $# -ne 1 ]; then
echo "$0: specify tag name"
exit 0
fi
if [ -p /dev/stdin ]; then
from smtpd import SMTPServer
import asyncore
class RejectSMTPServer(SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
return '500 Error'
def start_smtpd():
server = RejectSMTPServer(('127.0.0.1', 1025), None)
asyncore.loop()