This file contains hidden or 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
| function string.split(t,b) | |
| local cmd = {} | |
| local match = "[^%s]+" | |
| if type(b) == "string" then match = "[^"..b.."]+" end | |
| for word in string.gmatch(t, match) do table.insert(cmd, word) end | |
| return cmd | |
| end | |
| function new_account(user,pw) | |
| local file = assert(io.open("sys/lua/Fun Server/user_accounts/"..user..".txt","w")) |
This file contains hidden or 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
| function table.join(t, n, d) | |
| local s = "" | |
| if (n == nil) then n = 1 end | |
| if n<1 then n = 1 end | |
| if not d then d = " " end | |
| while (n <= #t) do | |
| s = s .. t[n] .. "".. d | |
| n = n + 1 | |
| end |
This file contains hidden or 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
| /** | |
| * @(#)Knight.java | |
| * | |
| * | |
| * @author | |
| * @version 1.00 2009/12/10 | |
| */ | |
| import java.util.ArrayList; | |
| public class Knight { | |
This file contains hidden or 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
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
This file contains hidden or 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
| local _mtg = getmetatable(_G) or {} | |
| function _mtg.__index(self, k) | |
| return rawget(self,k.."___macro") | |
| end | |
| setmetatable(_G,_mtg) | |
| function string.escape(text) | |
| local str = "" | |
| for i=1, #text do | |
| local chr = text:sub(i,i) |
This file contains hidden or 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
| #Hello World | |
| class Operator(object): | |
| def __init__(self, func, count=2): | |
| self._func_ = func | |
| self._args_ = [] | |
| self._count_ = count | |
| def __ror__(self, first_arg): | |
| self._args_.append(first_arg) | |
| return self |
This file contains hidden or 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 point(object): | |
| def __init__(self, *args): | |
| self.points = args | |
| def __getitem__(self, key): | |
| return float(self.points[key]) | |
| def __len__(self): | |
| return len(self.points) | |
| def __repr__(self): | |
| return "(%s, %s)"%self.points | |
| def __iter__(self): |
This file contains hidden or 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
| print ", ".join([str(i) if i%3 and i%5 else "Fizz" if i%5 else "Buzz" if i%3 else "FizzBuzz" for i in range(1,101)]) |
This file contains hidden or 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 collision(t1,t2): | |
| """ | |
| collision(t1,t2) | |
| @Params: t1,t2 => ((x,y),(x,y),(x,y)) where x,y are floats | |
| @Return: Boolean (True if the two triangles collide, else False) | |
| Triangle collision detection via a vectoral approach. | |
| Imagine two triangles of verticies (a,b,c) and (d,e,f) | |
| a,b,c,d,e,f ~ (x,y) within Reals | |
| We can then serialize each triangle/polygon into a 2-dimensional array ((x,y),(x,y),...,(x,y)) |
This file contains hidden or 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 math | |
| class reflect(object): | |
| def __init__(self, fn=None, step = 0.01, start = 0, limit = None, threshold = 10.**(-3), args = []): | |
| self.fn = fn | |
| self.step = step | |
| self.n = start | |
| self.limit = limit | |
| self.threshold = threshold | |
| self.initial = args | |
| self.call = True if fn else False |