Skip to content

Instantly share code, notes, and snippets.

View opamp's full-sized avatar

opamp_sando opamp

  • Japan
View GitHub Profile
@opamp
opamp / app.qml
Created September 21, 2011 08:32
QML練習0
/****************************************************************************
**
http://d.hatena.ne.jp/opamp_sando/20110921/1316594257
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples of the Qt Toolkit.
@opamp
opamp / automakelink.rb
Created September 16, 2011 11:52
DotfilesをDropboxで管理するときに若干役に立ちそうなスクリプト
@opamp
opamp / 7.rb
Created September 4, 2011 10:42
ProjectEuler7
#!/usr/bin/env ruby
#-*- encoding:utf-8 -*-
# * へっぽこコード
def isPnum?(a) #素数か判定する
sa = (Math::sqrt(a)).truncate
return true if a == 2 or a == 3
return false if a < 2
2.upto(sa) do |x|
if a % x == 0 then
@opamp
opamp / 3.rb
Created September 2, 2011 18:07
projectEuler3
#!/usr/bin/env ruby
#-*- encoding:utf-8 -*-
=begin
Question.
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
超へっぽこコード クラスにした意味がわからない。
@opamp
opamp / main.rb
Created August 10, 2011 02:43
Swing_test-JRuby
#!/usr/local/bin/ruby --1.9
#-*- encoding: utf-8 -*-
require 'java'
import 'javax.swing.JFrame'
import 'javax.swing.JButton'
import 'javax.swing.JTextField'
import 'javax.swing.JTextArea'
import 'javax.swing.JPanel'
import 'java.awt.BorderLayout'
@opamp
opamp / yakubun.rb
Created August 5, 2011 09:54
yakubun
#!/usr/bin/env ruby
#-*- encoding:utf-8 -*-
def eukeides(m,n)
loop do
r = m % n
if r == 0 then
return n
end
m = n
@opamp
opamp / ls.rb
Created July 27, 2011 07:38
easy ls command (Practice)
#!/usr/bin/ruby -Ku
class Pdir
def initialize(dirnameArray,optionArray)
@AllPrintDirPATH = dirnameArray
@Alloptions = optionArray
@diro = Array.new
dirnameArray.each do |x|
if File.exists?(x) == true && File.directory?(x) == true then
@diro << Dir.open(x)
@opamp
opamp / eculidean.rb
Created July 6, 2011 11:14
Euclidean algorithm
#!/usr/bin/env ruby
#-*- encoding:utf-8 -*-
# コマンドライン引数は 第一引数 >= 第二引数 でなければならない。
if ARGV.size != 2 then
STDERR::puts "Arguments error."
exit 1
end
@opamp
opamp / practice_libdb
Created June 21, 2011 16:41
practice_libdb_cxx
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<db_cxx.h>
using namespace std;
//BerkeleyDBの練習...
//db51のlibdb_cxx.aなどとリンクする必要があります。
#!/usr/local/bin/ruby
# I'm novice.
$ARGS = ARGV.size
def option_arg(argv)
optq = []
optnumq = argv.size - 2
i = 0