Deshi Xiao xiaods

View advanced-style-ruby
1 2 3 4 5 6
def triangle(a, b, c)
raise TriangleError if [a,b,c].min <= 0
x, y, z = [a,b,c].sort
raise TriangleError if x + y <= z
[:equilateral,:isosceles,:scalene].fetch([a,b,c].uniq.size - 1)
end
View common-style-ruby
1 2 3 4 5 6 7 8 9 10
def triangle(a, b, c)
if a == 0 || b == 0 || c == 0
raise TriangleError
end
if((a+b < c) || (a+c < b) || (b+c < a))
raise TriangleError
end
if a == b && b == c # && a == c
:equilateral
elsif a == b || b == c || c == a
View tiny-rss-openshift-setup.md
  1. 下载tiny-tiny-rss source code
cd ~/src/git 
clone git://github.com/gothfox/Tiny-Tiny-RSS.git
  1. 创建openshift空间
View gist:952663
1 2 3 4 5 6 7 8 9
upstream tumblr {
server 72.32.231.8:80;
}
 
server {
listen 80;
server_name jyorr.com;
 
access_log /var/log/nginx/jyorr.access.log;
View gist:924997
1 2 3 4 5 6 7 8 9 10
class SvgController < ApplicationController
require 'active_support/secure_random'
def create
# create an SVG image
# based on Highcharts index.php
batik_path = Rails.root.to_s() + '/vendor/batik/batik-rasterizer.jar'
svg = params[:svg]
filename = params[:filename].blank? ? "chart" : params[:filename]
View nginx.conf
1 2 3 4 5 6 7 8
user app;
worker_processes 2;
 
error_log /home/app/logs/nginx.error.log info;
 
events {
worker_connections 1024;
}
View gist:420453
1 2 3 4 5 6 7 8 9 10
This example shows how to setup an environment running Rails 3 beta 3 under 1.9.2-head with a 'rails3' gem set.
 
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
 
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2-head
 
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2-head@rails3
View gist:337218
1 2 3 4 5 6 7 8 9 10
# inspiration
# http://github.com/jnstq/rails-nginx-passenger-ubuntu
 
# sudo this sudo that bollocks
sudo -i
 
# system-related stuff
apt-get install htop strace sysstat
dpkg-reconfigure sysstat
apt-get install ntp
View testhelpers.rb
1 2 3 4 5 6 7 8 9 10
require "rubygems"
require "test/unit"
require "stringio"
 
module Test::Unit
# Used to fix a minor minitest/unit incompatibility in flexmock
# AssertionFailedError = Class.new(StandardError)
class TestCase
Something went wrong with that request. Please try again.