Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - fugibo

1
Quote from: WhiteRose on July 25, 2010, 07:30:12 pm
I saw the name of this topic and thought instantly of this:
Spoiler: ShowHide


On topic: I lol'd. I read another really funny response similar to this the other day; I'll see if I can dig it up.


EDIT:
Ah, here it is:
http://www.albinoblacksheep.com/text/chain


obv. this response is inferior 2 bullet
2
Entertainment / Re: Inception
July 24, 2010, 08:01:55 pm
Quote from: Diokatsu on July 24, 2010, 07:59:36 pm
Quote from: fugibo on July 24, 2010, 07:23:06 pm
nothing like The Matrix. fairly interesting and the fight scenes weren't annoying. wasn't really that great, though. inspired.


I disagree with your opinion and would like you to revise it.


it's definitely the best movie out right now, but it's still not "great" or anything like The Matrix beyond the questioning of reality. and it was rather inspired.
3
Entertainment / Re: Inception
July 24, 2010, 07:23:06 pm
nothing like The Matrix. fairly interesting and the fight scenes weren't annoying. wasn't really that great, though. inspired.
4
Video Games / Re: Portal 2... PORTAL 2
July 23, 2010, 12:12:04 pm
Quote from: Blizzard on July 23, 2010, 11:45:04 am
Well, then the next weekend. Or the one after that. Or whichever weekend the first one is after the release xD
I really hope it'll be longer than the first one. You can beat Portal 1 in 1.5 hours using a laptop touchpad. Well, the part about the touchpad may be just me... <_<;

EDIT: :cclove:


It took me around 2 hours with mine. Of course, I also beat Half-Life 1 without much challenge with it. And Blue Shift/Opposing Force. Macbook trackpads are really good for FPSes, actually.

EDIT: releasedate is "TBA 2011"
5
Chat / Re: Favorite Books?
July 23, 2010, 11:43:52 am
Quote from: Diokatsu on May 01, 2010, 09:07:08 pm
Some of my favorites are As I Lay Dying by William Faulkner, Catcher in the Rye by J.D. Salinger, Dubliners by James Joyce (which I read a couple months back for my term paper and was really, really, really impressed by), Lolita by Vladimir Nabokov (favorite book ever), Pale Fire by Vladimir Nabokov, The Brothers Karamazov by Fyodor Dostoevsky and Catch-22 by Joseph Heller, and plus the epic poems The Odyssey by Homer, The Aeneid of Virgil, and The Epic of Gilgamesh translated by Andrew George.

I'm going to try and read Atlas Shrugged by Ayn Rand, Ulysses by Jame Joyce and Anna Karenina by Leo Tolstoy this summer, the first being my choice and the last two being recommendations from my English teacher. I may try and fit in To the Lighthouse by Virginia Woolf and On the Road by Jack Kerouac.


i could totally take that seriously if you hadn't listed catcher in the rye

On the Road (and pretty much all Beat stuff) is actually good, you should also check out William S. Burroughs if you're actually being serious.
6
Video Games / Re: Portal 2... PORTAL 2
July 23, 2010, 11:31:42 am
Quote from: Blizzard on July 23, 2010, 03:08:06 am
OMG OMG OMG! IT'S OUT! AAAAAAAAAAAAAHHHHHHHHHHHHH!!!!!!! There goes my weekend.


no it's not
7
oh god i hope they don't take down my internet

it'd be almost as bad as them trying me as a criminal or something
8
Entertainment / Re: Pickup Lines.
July 15, 2010, 07:41:00 pm
my friend has an empty packet of tea sweetener labeled "sweet thing" that he drops on the floor, picks up and says "excuse me, you dropped your name tag"
9
RPG Maker Scripts / Window Additions
July 15, 2010, 01:11:55 pm

=begin
- With this script, you can now create animations:
Window_Animation.resize 200, 200 # resize a window to 200x200
Window_Animation.move 50, 50 # move a window to (50, 50)

# this one makes a window hover up and down
Window_Animation.new do |window|
 window.displacement_x = window.displacement_y = Math::sin((Graphics.framecount % 360) * Math::PI / 180)
end

- You can also add objects to windows as thus:
window << object # the method named "insert_<object class>" is called, i.e. for a string "insert_String" would be called
window << animation # adds the animation, so that window#update will call it
=end
class Window_Animation
   
 def self.resize width, height
   return self.new do |window|
     if window.width > width
       window.width -= 2
     elsif window.width < width
       window.width += 2
     end

     if window.height > height
       window.height -= 2
     elsif window.height < height
       window.height += 2
     end
   end
 end
 
 def self.move x, y
   return self.new do |window|
     if window.x > x
       window.x -= 1
     elsif window.x < x
       window.x += 1
     end
     
     if window.y > y
       window.y -= 1
     elsif window.y < y
       window.y += 1
     end
   end
 end
 
 def self.proc &block
   return self.new(block)
 end
 
 def initialize &block
   @block = block
   @hash = {}
 end
 
 def call window
   @block.call window
 end
 
end

class Window
 
 attr_reader :displacement_x, :displacement_y
 
 alias fugibo_window_additions_initialize_alias initialize
 def initialize *args
   fugibo_window_additions_initialize_alias(args)
   @animations = []
   @displacement_x = 0
   @displacement_y = 0
 end
 
 def << object
   send 'insert_#{object.class}', object
 end
 
 def insert_Window_Animation animation
   @animations << animation
 end
 
 def insert_Proc proc
   @animations << Window_Animation.proc(proc)
 end
 
 alias fugibo_window_additions_update_alias update
 def update
   fugibo_window_additions_update_alias()
   @animations.each do |animation|
     animation.call(self)
   end
 end
 
 def displacement_x= x
   self.x += x - @displacement_x
   @displacement_x = x
   
   return x
 end
 
 def displacement_y= y
   self.y += y - @displacement_y
   @displacement_y = y
   
   return y
 end
 
end


a scripter's "tool." some methods added to the Window class and a new class (Window_Animation, not sure if that name's taken already). neat example (assuming the code works, which it should:)


w = Window.new
w.width = 160
w.height = 120
w.x = 240
w.y = 180

w << Window_Animation.move 120, 80
w << Window_Animation.resize 320, 240
w << Window_Animation.new do |window|
 w.angle = Graphics.framecount % 40 - 20
end

loop do
 Input.update
 Graphics.update
 w.update
 
 if Input.trigger? Input::C
   w.destroy
   break
 end
end
10
thanks cat

also here's a quick example of how you can use rum to build xml files (not sure if this will work, I'm typing it up quicklike):

# output all schools and their students to an XML file!
document = Rum::Document.new

schools.each do |school|
 school_node = document.spawn 'school', 'name' => school.name, 'address' => school.address.to_s
 school.students.each do |student|
   school_node.spawn 'student', 'name' => student.name, 'grade' => student.grade.to_s
 end
end

File.open('output.xml', 'w') do |file|
 file.write document.to_xml
end
11
Have Fun: ShowHide


module Rum
 class Node
   include Enumerable
   include Comparable
   
   attr_reader :parent, :label, :body, :attributes
   
   def initialize parent, label, attributes = {}
     @parent = parent
     @label = label
     @attributes = attributes
     @body = ''
     @children = []
   end
   
   def <=> other
     if other.kind_of? Node
       if @label == other.label
         return @attributes <=> other.attributes
       else
         return @label <=> other.label
       end
     else
       raise ArgumentError, "Unable to convert #{other.class} to Node"
     end
   end
   
   def [](attr_name)
     return attributes[attr_name]
   end
   
   def each
     @children.each {|node| yield node}
   end
   
   def find label=nil, attributes=nil, &block
     # kinda slow. it could probably use some optimization.
     super() do |node|
       (label == nil ? true : node.label == label) and
       (attributes == nil ? true : attributes.all? {|key, vaue| node[key] == value}) and
       (block == nil ? true : block.call(node))
     end
   end
   
   def select *args, &block
     subset = @children.clone
     
     args.each do |arg|
       
       if arg.is_a? String
         
         subset.delete_if do |node|
           node.label != arg
         end
         
       elsif arg.is_a? Hash
         
         subset.delete_if do |node|
           arg.any? do |key, value|
             node[key] != value
           end
         end
         
       end
       
     end
     
     if block != nil
       subset.each do |node|
         block.call node
       end
     end
     
     return subset
   end
   
   def push object
     object.kind_of?(Node) ? @children.push(object) : raise("Cannot add non-node #{object} as child of node #{self}")
   end
   
   def child_count
     return @children.count
   end
   
   def to_xml indent=0
     tab = "  " * indent
     if @body.size == 0 and @children.empty?
       return "#{tab}<#{@label}#{attributes_to_xml_string} />"
     else
       return "#{tab}<#{@label}#{attributes_to_xml_string}>\n#{tab}\t#{@body}\n" << (@children.inject('') {|s,n| s << n.to_xml(indent+1)}) << "#{tab}</#{@label}>\n"
     end
   end
   
   def spawn label, attributes = {}
     node = Node.new(self, label, attributes)
     self.push node
     return node
   end
   
   protected
   
   def attributes_to_xml_string
     return @attributes.inject(' ') {|string, pair| string << "#{pair[0]}=\"#{pair[1]}\""}
   end
   
 end
 
 class Document < Node
   
   protected
   
   def xml_attributes_from_string string
     attributes = {}
     
     if string != nil
       string.scan(/(\w+?)="(\w+?)"/) do |pair|
         attributes[pair[0]] = pair[1]
       end
     end
           
     return attributes
   end
   
   def tags_from_xml string
     node = self
     
     string.scan(/(<[^>]+>|<\/[^>]+>|[^<]*)/) do |sub|
       case sub[0]
       when /<([\w\-]+?) (.+)?\/>/ # simple node
         node.spawn $1, xml_attributes_from_string($2)
       when /<([\w\-]+?)( (.+) ?)?>/ # complex node (open)
         node = node.spawn $1, xml_attributes_from_string($2)
       when /<\/([\w\-]+?)>/ # complex node (close)
         if $1 == node.label and node != self
           node = node.parent
         else
           raise "Attempted to close tag named '#{$1}'; current tag is named '#{tag.name}'"
         end
       else # node content
         node.body << sub[0].strip
       end
     end
     
     return self
   end
   
   public
   
   attr_reader :source
   
   def self.open_xml filename, &block
     document = self.new :xml, File.read(filename)
     
     if block != nil
       block.call document
     end
     
     return document
   end
   
   def self.xml source, &block
     document = self.new :xml, source
     
     if block != nil
       block.call document
     end
     
     return document
   end
   
   def initialize type=:xml, source='', &block
     super nil, ''
     
     @source = source
     
     case type
     when :xml
       tags_from_xml @source
     end
     
     if block != nil
       block.call self
     end
   end
   
   def to_xml
     # overridden to avoid enclosing <></>
     return @children.inject('') {|string, node| string << node.to_xml}
   end
   
 end
 
end



Rum is a pure-Ruby library I wrote today that can be used to load, manipulate, and save XML files. What makes it different from REXML/&c.? This:


#! /usr/bin/ruby

require 'rum'
include Rum

XML = <<END_OF_STRING
<class id="101">
 <student id="99887" name="John" grade="11" />
 <student id="44753" name="Jenny" grade="10" />
</class>
<class id="102">
 <student id="99887" name="John" grade="11" />
 <student id="68532" name="Jenny" grade="10" />
</class>
END_OF_STRING

Document.xml XML do |document|
 # Want to find all unique students in all classes?
 document.collect {|klass|
   klass.select('student')
 }.flatten.uniq
 
 # Want to find all classes with a grade 11 student?
 document.select('class') {|klass|
   klass.select('student', 'grade' => '11').size > 0
 }
 
 # how many juniors are in the school?
 document.select('student', 'grade' => '12').uniq.count

 # Want a pretty list of all classes and the students in them?
 document.select('class') do |klass|
   print "In class #{klass['id']}:\n"
   klass.select('student') do |student|
     print "\t#{student['name']} (student #{student['id']}, grade #{student['grade']})\n"
   end
 end
end


I still need to do some work on it, such as getting select/find's fancy search mechanisms to work with more of Enumerable, converting the simple node label recognition into more advanced path-style (think CSS selectors, I guess?) recognition, &c.

In the end I want it to be able to do things more like:

# are any seniors in any classes?
document.any? 'class/student', 'grade' => '12'


Do whatever you want with the code.
12
It depends on how .exe contents are referenced from the Win32API side. If they aren't presented as local files then you might be able to hack in some code to "virtually" present the contents to the .exe code.

/i have no guarantees that i am sane at the moment
13
Not as much using a hammer to drill a hole as using a toy drill to drill a hole
14
No offense, but there's really no reason to be using tables when CSS is easier and simpler.
15
He wants to add the .DLL to the executable file as if it were an image/sound file.
16
Programming / Scripting / Web / Re: Project Euler
March 14, 2010, 02:06:46 pm
I was staying up really late and I was doing some really stupid stuff. ><

I'd rather work out most of my algorithms myself. Just because I like the challenge, and it makes me feel special. :V
17
Video Games / Re: PKMN : Heart Gold + Soul Silver
March 14, 2010, 01:38:30 pm
Yeah, 356/2 doesn't run perfectly, but it nearly rivals the PS2 at near flawless framerates. I wouldn't say that the DS is exactly weak.
18
Programming / Scripting / Web / Project Euler
March 14, 2010, 01:29:53 am
http://projecteuler.net/

Lots of interesting math/comp. sci. problems.

...it also has proven to me how much I suck at math/programming.

EDIT:
QuoteFind the sum of all the positive integers which cannot be written as the sum of two abundant numbers.


and my processor is still eating away at #3 and #10 ><

EDIT:
I gave up on #3 for now, my prime number algorithm needs some serious revision. I'm currently taking the factorial of 1,000,000 for my lexicographic permutation prediction algorithm on one core while the other continues to try and find prime numbers up to 2,000,000 (and then add them!).
19
Quote from: Elite Four NAMKCOR on March 11, 2010, 09:28:03 pm
Quote from: fugo ad te, pikachu! on March 11, 2010, 10:00:06 am
I'm tired of everyone assuming that sexuality is protected under the constitution. I could be wrong, but I'm pretty sure that's not in the main document, and I'm fairly certain it hasn't been amended, either.


Quote
    * Ninth Amendment - Protection of rights not specifically enumerated in the Bill of Rights.

    The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.


's all I'm sayin


this helped african americans very well, yes.
20
I do support gay rights. I'm just sick of everyone claiming that it's "unconstitutional" to discriminate against homosexuals. it's definitely not right, but it's also definitely not illegal (yet).

Also, we have now made the front page of Yahoo. That ugly girl, Constance? Yeah, she nearly got me expelled when I said "The Well" to her. I was referring to the nearby suburb "Ryan's Well" and she assumed I was calling her a whale, so she ran off to tell the principal.

also all of the teachers are getting tons of hate mail usually taking the form "HOW COULD YOU NOT TEACH YOUR KIDS ANYTHING" and "I FEEL SO SORRY FOR THE KIDS WHO HAVE TO LIVE THERE." I think it's hilarious, but everyone else who's ever gone to the school is freaking out (a lot of the current students are concerned for their scholarships/&c.)