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 acos = math.acos | |
| local asin = math.asin | |
| local sqrt = math.sqrt | |
| -- Define unit vectors | |
| local mx = sqrt(1*1+2*2+3*3) | |
| local x,y,z = 1/mx,2/mx,3/mx | |
| local ma = sqrt(4*4+5*5+6*6) | |
| local a,b,c = 4/ma,5/ma,6/ma | |
| -- Dot product | |
| print(acos(x*a+y*b+z*c)) |
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
| -- Given the target number n | |
| -- Starting with accumulator at 0 | |
| -- what is the optimal number of times | |
| -- you can add a, multiply by b, or divide by | |
| -- c to reach the target number? | |
| -- Output is in Java, but it can be any language that | |
| -- supports integer division. | |
| -- (or use // in Lua 5.3 <3) |
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 HttpService = game:GetService('HttpService') | |
| local apid = HttpService:JSONDecode(HttpService:GetAsync('http://anaminus.github.io/rbx/json/api/latest.json')) | |
| local function CoreDump(Reference, ClassName) | |
| ClassName = ClassName or Reference.ClassName | |
| print('Dump: ' .. ClassName) | |
| local Table,LongestKey = {}, 0 | |
| for _,Entry in next,apid do | |
| if (Entry.type == 'Property' and Entry.Class == ClassName) then | |
| local Skip = false |
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
| #include <stdio.h> | |
| #define AB_WIN | |
| #include "ab.h" | |
| void MatchString(char *Match, const char *String, char *Result) { | |
| int StringIndex = 0; | |
| int MatchLength = 0; | |
| int ResultLength = 0; | |
| bool Class = false; | |
| bool JustRestart = false; |
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
| // Derived from | |
| // http://burtleburtle.net/bob/rand/smallprng.html | |
| // TODO(alex): SSE intrinsic | |
| #if !defined(AB_RAND_H) | |
| #define AB_RAND_H | |
| #define ULONG_MAXF 4294967295.0 // 2^32-1 | |
| // Internal affixation, _ | |
| // 32 bit (u4, ulong) | |
| #define _ab_rand_rot(x,k) (((x)<<(k))|((x)>>(32-(k)))) |
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 Message = "This is a very powerful function and can be used in multiple ways. Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made:" | |
| local Methods = { | |
| { "%s+", " " }, | |
| { "are", "r" }, | |
| { "be", "b" }, | |
| { "you", "u" }, | |
| { "i%sam", "i'm" }, | |
| { "first", "1st" }, | |
| { "second", "2nd" }, |
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
| -- Localized variables that I didn't copy over go here. | |
| local function Solve(r0, r1, c, p) | |
| local x,y,z,r00,r01,r02,r10,r11,r12,r20,r21,r22 = c:components() | |
| local px,py,pz = p.x-x,p.y-y,p.z-z | |
| local tx = r00*px+r10*py+r20*pz | |
| local ty = r01*px+r11*py+r21*pz | |
| local tz = r02*px+r12*py+r22*pz | |
| local d = (tx*tx+ty*ty+tz*tz)^0.5 | |
| d = r0+r1<d and r0+r1 or d |
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 Tests = { | |
| '<string name="Name">TEST</string>', -- pass | |
| '<>TEST</string>', -- load | |
| '< >TEST</string>', -- load | |
| '<a a>TEST</string>', -- fail = not found | |
| '<string a=" name="Name">TEST</string>', -- fail = not found | |
| '<string a= a=""="">TEST</string>', -- ??? load |
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
| var EXEC_FILE_LOCATION = process.argv[2] | |
| var LUA_BINARY_NAME = process.argv[3] ? process.argv[3] : 'lua' | |
| var chokidar = require('chokidar'); | |
| var fs = require('fs'); | |
| var http = require('http'); | |
| var exec = require('child_process').exec | |
| var responses = [] |
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
| .intel_syntax noprefix | |
| .global main | |
| .format: | |
| .asciz "%d\n" | |
| main: | |
| xor rbx, rbx | |
| inc rbx | |
| add rsi, 8 | |
| dec rdi |