Skip to content

Instantly share code, notes, and snippets.

View cfong57's full-sized avatar

Christopher Michael Fong cfong57

  • San Francisco, California
View GitHub Profile
@cfong57
cfong57 / virtual objects.txt
Created September 18, 2013 21:29
virtual objects
Virtual objects
Virtual objects can be handy when creating lots of stock items, for example we use it on our random armour / weapon implementation. The outworld is also done with virtual rooms.
The MudOS? driver comes with the ability to create and use virtual objects. A virtual object is one that was NOT created from an existing file: thus, it doesn't take up any disk space. They're ideal for making a large number of similar but not identical objects: historically they've usually been used to make rooms, creating large areas without wasting a lot of disk space.
However, they are applicable to any situation where you need a lot of similar but not identical items which can be customized based on a single string argument (which can be sscanfed into multiple arguments if needed.)
Virtual objects get created in the following way. Whenever the driver tries to load a file that doesn't exist, it calls compile_object() in the master object, passing the name of the nonexistant file as an argument. This function ca
@cfong57
cfong57 / zerotime.rb
Last active December 23, 2015 06:29
0.times do
2.times {puts "herp"}
1.times {puts "derp"}
0.times {puts "murp"}
-1.times {puts "spoink"}
contents = File.read("zerotime.rb")
lines = contents.split("\n")
whole_command = lines[2].gsub("0.times {","").gsub("}","")
#puts "murp"
method = whole_command.split(" ").first.to_sym
@cfong57
cfong57 / games
Created September 8, 2013 09:15
video game listing (totally related to coding, right)
== Giant list of games that I play/have played ==
In no particular order. I'm only listing things that I've played to a reasonable degree (e.g. "beat the game"), and without cheating. Like, I've played The Legend of Zelda: Link to the Past / Ocarina of Time / Majora's Mask, but I cheated my way through them...
<strong>Strong</strong> indicates a completely amazing game that just blew me away. Nothing on this list is "bad", but some games are better than others. * indicates something I'm currently (re)playing.
=== <em>PC</em> ===
*Guild Wars 2 (because woo no sub)
<strong>*Melty Blood Actress Again Current Code</strong>
*World of Tanks (just installed, dunno if I'll like it)
<strong>Sengoku Rance</strong>
@cfong57
cfong57 / shadow.txt
Created September 2, 2013 22:01
tldr explanation of shadows
Thoran and someone (Hey! You there in the backrow! State your name!) asked for some help about shadows so I decided to write here a small help about them. Nothing big, just to get you started. If you don't know what you are doing, don't touch them. You'll just end up breaking yourself .
First question you might have is most likely "What are shadows?" or "What I can do with them?". Someone with more insight in coding and its terms might be better in answering this (Cutter) but anyways "Help shadow" tells us this:
The result is that it is possible to hide an object behind another one, but everything can be totally transparent. The shadow() efunction makes it possible to change the behavior of an object without changing the code for the object in question. One possible use for shadow() is to add special capabilities to various classes of players (thief, fighter, mage, etc). This usage would make it possible to keep the player object much simpler than it could be if the code for the various classes had to be in
@cfong57
cfong57 / in_words.rb
Created August 30, 2013 22:56
wordify numbers
##
#47 test cases, 117 iterations
#about 56% less efficient than the proposed solution on github (in_words.rb)
#which only has 75 iterations
#
#this is an UGLY brute force hack that could use some serious refactoring
#function over form though...
#
#***for purposes of easy testing I extend Intenger, not Fixnum***
#
@cfong57
cfong57 / lightyear_prime.rb
Last active December 21, 2015 21:59
simple program to calculate prime numbers and output the results to .txt
class Integer
INFINITY = Float::INFINITY
PRIMES = Enumerator.new do |y|
e = (3..INFINITY).step(2).lazy.map(&:to_i).select(&:prime?)
y << 2
loop { y << e.next }
end
def prime?
@cfong57
cfong57 / monobook.css
Created August 28, 2013 00:09
master .css file for monobook (default) skin
/* winter-related diables - keep for future devious uses
disables Snow tree background
div#content { background: white; }
div#article { background: white; }
master disable for "ice" effect
div.pBody { background: white; }
*/