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 Song < ActiveRecord::Base | |
composed_of :songinfo, :class_name => "SongInfo", :mapping => [%w(title, title)] | |
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 ActiveRecord::Base | |
def keys | |
arr = [] | |
self.each do |x, y| | |
arr.push x | |
end | |
return arr | |
end | |
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
import getopt | |
import sys | |
version = "1.0" | |
verbose = False | |
output = "default.out" | |
try: | |
options, remainder = getopt.getopt(sys.argv[1:], "o:v", ["output=", "verbose=", "version="]) | |
except Exception as err: | |
print(err) | |
sys.exit(1) |
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 Array | |
def double_each other, &block | |
self.each_with_index do |item, index| | |
yield [item, other[index]] | |
end | |
end | |
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 GID | |
# Filters out naughty words | |
def self.filter! str | |
words = ["fuck", "shit", "bitch", "cunt", "fag", "douche", "ass", "a55", "b1tch", "f4g", "5h1t"] | |
substitutes = ["faxf", "spwo", "bawpr", "capf", "fpa", "dclax", "aic", "a21", "b5sea", "f8m", "1z8l"] | |
words.each do |x| | |
str.gsub!(x, substitutes[words.index(x)]) | |
end | |
return str | |
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 String | |
def strpush! push | |
newstring = push + self | |
self.replace(newstring) | |
end | |
end | |
class HTMLDocument | |
private | |
def refresh_full | |
@full_doc = @open_doc + @close_doc |
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
<html> | |
<head> | |
<script type="text/javascript"> | |
window.onload = function() { | |
document.getElementsByTagName("form")[0].onsubmit = function() { | |
document.getElementsByTagName("body")[0].style.color = "Red"; | |
document.getElementsByTagName("input")[1].value = "Calculating..."; | |
var inputted = Number(document.getElementsByTagName("input")[0].value); | |
inputted /= 57.295779501; | |
alert(Math.sin(inputted)); |
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
Array.class_eval do | |
def unpack index | |
temp = self | |
self[index].map {|item| temp.push item} | |
temp.delete(self[index]) | |
return temp | |
end | |
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 Proc: | |
def __init__(self, code): | |
self.code = code | |
def call(self): | |
exec(self.code) | |
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
def count(arr): | |
d = {} | |
for x in arr: | |
if x in d.keys(): | |
d[x] += 1 | |
else: | |
d[x] = 1 | |
return d |