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
#!/usr/bin/env ruby | |
def integer?(number) | |
(number % 1) == 0 | |
end | |
def double_square_number?(number) | |
sqrt = Math.sqrt(number) | |
if integer?(sqrt) | |
[sqrt.to_i, 0] |
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
#!/usr/bin/env ruby | |
class String | |
def *(str) | |
maxshift = self.length + str.length - 2 | |
results = Array.new(maxshift+1, 0) | |
self.split(//).map(&:to_i).each_with_index do |i, at1| |
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
#!/usr/bin/env ruby | |
# simple connect to database with DataMapper | |
require "rubygems" | |
require "data_mapper" | |
DataMapper.setup( | |
:default, | |
"sqlite3:///tmp/dm-core.sqlite3" | |
) |
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
package JiftyTest::View::Page; | |
use base Jifty::View::Declare::Page; | |
use Jifty::View::Declare::Helpers; | |
# use base qw(Jifty::Plugin::ViewDeclarePage::Page); | |
# This plugins is used for replace Jifty::View::Declare::Page | |
# try it later | |
use Class::Trigger; |
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
#!/usr/bin/env ruby | |
# shelling | |
# This script show how to initialize more instance variables when creating an Array object | |
class Array | |
attr_reader :this | |
def initialize | |
super | |
@this = 0 |
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
#!/usr/bin/env perl | |
# shelling <shelling@cpan.org> | |
# This script can get enrollment tidings(招生資訊) | |
# from 台灣大學教務處(NTU ACA) and render rss list | |
use utf8; | |
no warnings; | |
use CGI::RSS; | |
use pQuery; | |
use LWP::Simple; |
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
module ActiveRecord | |
module Render | |
module From | |
def render_as_form | |
res = String.new | |
obj = self.class.to_s.downcase.to_sym | |
self.class.columns.each do |c| |
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
#!/usr/bin/env perl | |
# | |
# author: shelling <shelling@cpan.org> | |
# | |
# This script is used to help Jifty Application | |
# to insert primitive data into database | |
use lib "lib"; | |
use Jifty; | |
use Jifty::Everything; |
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
#!/usr/bin/env perl | |
# | |
# shelling <shelling@cpan.org> | |
# | |
# First KiokuDB example | |
use KiokuDB; | |
package Person; | |
use Moose; |
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
#!/usr/bin/env ruby | |
require "net/ftp" | |
require "yaml" | |
config = YAML::load_file(File.expand_path("~/.passwd"))["localhost"] | |
Net::FTP.open(config["host"], config["user"], config["pass"]) do |ftp| | |
ftp.passive = true |