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
module maid; | |
import tools.base, tools.functional, irc, dice: rand; | |
// returns randomized indices of maxcount top values | |
int[] SelectTopRand(int[] input, int count) { | |
if (!input.length) return null; | |
if (input.length == 1) return [0]; | |
int max = input[1], maxpos; | |
foreach (i, v; input) if (v > max) { max = v; maxpos = i; } |
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
module restarter; | |
import std.string, std.file, std.thread, std.time, std.fun; | |
extern(C) { | |
alias pid_t = int; | |
pid_t fork(); | |
int execv(char* path, char** argv); | |
pid_t waitpid(pid_t, int* status, int options); | |
} |
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
module bintest; | |
// assume array is sorted from small to big | |
int findIndexOfOne(int[] array, int value) { | |
if (!array.length) raise new Error "$value not found during binsearch"; | |
auto test-idx = array.length / 2; | |
if (array[test-idx] == value) return test-idx; | |
if (array[test-idx] < value) // everything before test-idx is also smaller | |
return findIndexOfOne(array[test-idx+1 .. $], value) + test-idx+1; | |
else // everything after test-idx is also larger |
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
module bintest; | |
// assume array is sorted from small to big | |
int findIndexOfOne(int[] array, int value) { | |
if (!array.length) raise new Error "$value not found during binsearch"; | |
auto test-idx = array.length / 2; | |
if (array[test-idx] == value) return test-idx; | |
if (array[test-idx] < value) // everything before test-idx is also smaller | |
return findIndexOfOne(array[test-idx+1 .. $], value) + test-idx+1; | |
else // everything after test-idx is also larger |
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
module restarter; | |
import std.string, std.file, std.thread, std.time, std.fun; | |
extern(C) { | |
alias pid_t = int; | |
pid_t fork(); | |
int execv(char* path, char** argv); | |
pid_t waitpid(pid_t, int* status, int options); | |
} |
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
print(5+2) |
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
string host; | |
string nick = "neatbot"; | |
string channel; | |
using new Options { | |
addLong("host", "h", \(string h) { host = h; }, =>required); | |
addLong("nick", "n", \(string n) { nick = n; }); | |
addLong("channel", "c", \(string c) { channel = c; }, =>required); | |
args = process args; | |
} | |
auto sock = connect (host, 6667); |
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
+ public int getSelectedSlotId() | |
+ { | |
+ if (!mod_ComputerCraft.isMultiplayerClient()) { | |
+ synchronized (this.m_inventory) { | |
+ ItemStack itemstack = this.m_inventory[this.m_state.selectedSlot]; | |
+ if (itemstack == null) return -1; | |
+ return itemstack.id; | |
+ } | |
+ } | |
+ |
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
WorldObject[auto~] inRect(vec2f a, b) { | |
auto world-center = vec3f(0), world-radius = 1; | |
auto center = cam.apply(world-center).xy; | |
float radius; | |
using glModelviewMatrix { | |
cam.unrotate; | |
auto offset = cam.apply(world-center + world-radius * vec3f.X).xy - center; | |
radius = |offset|; | |
} | |
auto aspect = vec2f(1, 1/cam.aspect); |
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
ttq |