This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import Test.HUnit | |
poker :: String -> String | |
poker = check . split | |
split :: String -> [(String, String)] | |
split ('D':'1':'0':xs) = [("D", "10")] ++ split xs | |
split ('C':'1':'0':xs) = [("C", "10")] ++ split xs | |
split ('S':'1':'0':xs) = [("S", "10")] ++ split xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import Test.HUnit | |
import System.Environment | |
data Image = Image Int String | |
instance Show Image where | |
show (Image l d) = "Image " ++ [(intToDigit l)] ++ ":" ++ (apply $ appendZero d) | |
appendZero :: String -> String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import System.Environment | |
main = do | |
args <- getArgs | |
print . process. head $ args | |
process = foldl (\acc x -> cal acc x) [] | |
cal acc x = acc ++ [r x] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class TM | |
def self.calc(ary) | |
ary.sort!.map!(&:to_i) | |
touch_info = ary.permutation(2).map { |a,b| check_touch(a, b) } | |
touch_numbers = touch_info.each_slice(3).map {|i| i.compact.length } | |
return 'T' if touch_numbers.max == 3 | |
return 'O' if touch_numbers.all? { |i| i == 2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class EqualAttributesMatcher | |
def initialize(attrs) | |
@attrs = attrs | |
end | |
def matches?(model) | |
@model = model | |
@attrs.all? { |k,v| @model.send(k) == v } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ValidAttributeMatcher | |
def initialize(attr_name) | |
@attr_name = attr_name | |
end | |
def matches?(subject) | |
@subject = subject | |
@subject.valid? | |
@subject.errors[@attr_name].empty? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# nginx - this script starts and stops the nginx daemin | |
# | |
# chkconfig: - 85 15 | |
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \ | |
# proxy and IMAP/POP3 proxy server | |
# processname: nginx | |
# config: /usr/local/nginx/conf/nginx.conf | |
# pidfile: /usr/local/nginx/logs/nginx.pid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-key global-map "\C-h" 'delete-backward-char) | |
(define-key isearch-mode-map "\C-h" 'isearch-delete-char) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum install pcre-devel | |
wget http://nginx.org/download/nginx-1.2.6.tar.gz | |
tar zxvf nginx-1.2.6.tar.gz | |
cd nginx-1.2.6 | |
./configure --with-openssl=/usr/lib64/openssl/engines | |
make | |
sudo make install | |
git clone git://gist.github.com/4406334.git | |
sudo mv 4406334/nginx /etc/init.d/ | |
sudo chmod 755 /etc/init.d/nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# description: Tomcat6 service | |
# processname: java | |
# chkconfig: - 99 1 | |
# Source function library. | |
. /etc/init.d/functions | |
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre | |
export TOMCAT_USER=solr | |
export CATALINA_HOME=/opt/tomcat6 |