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
proc `..<`(a, b: int): auto = | |
if a < 0: | |
raise newException(IndexError, "Left index == " & $a & ", out of range") | |
if b <= 0: | |
return 1 .. 0 | |
if a >= b: | |
return a .. <a | |
return a .. <b | |
proc `.!`(a, b: int): auto = |
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 strutils | |
from base64 import nil | |
proc encodeUrlSafe(s: string): string = | |
result = base64.encode(s, newLine="") | |
while result.endsWith("="): | |
result = result.substr(0, result.high-1) | |
result = result.replace('+', '-').replace('/', '_') | |
proc decodeUrlSafe(s: string): string = |
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
proc cool*() = | |
echo "cool" |
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 itertools | |
def readable_size(nbytes, i=True): | |
sizes = ("B KiB MiB GiB TiB" if i else "B KB MB GB TB").split() | |
last = sizes[-1] | |
d = 1024 if i else 1000 | |
for sz in sizes: | |
if nbytes < d or sz is last: | |
return '{} {}'.format(format(nbytes, '.1f').rstrip('0').rstrip('.'), sz) |
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 <Judy.h> | |
#define indices_n 2000 | |
Word_t indices[indices_n] = {15058, 4615, 6668, 19845, 10014, 15721, 2240, 2242, 631, 13511, 8475, 6887, 892, 4482, 8121, 14453, 4908, 17673, 5832, 2941, 5004, 6091, 8217, 10317, 9396, 5332, 2703, 7244, 13111, 15175, 8566, 16577, 11083, 17706, 4009, 19840, 9041, 16178, 12902, 2578, 15617, 17487, 5431, 18698, 2980, 6648, 19904, 12869, 14177, 2706, 13589, 1539, 2826, 2252, 19633, 14102, 19260, 12452, 1857, 4188, 13202, 1976, 10017, 4048, 3797, 7838, 11787, 12890, 9904, 17862, 15096, 5640, 1347, 6616, 9498, 15933, 13588, 14450, 2773, 13210, 12112, 1448, 2793, 7565, 1429, 8562, 510, 8059, 18845, 7602, 19739, 362, 18320, 14386, 6955, 10739, 8387, 15216, 456, 2042, 15969, 16558, 9596, 3598, 13373, 8904, 17604, 7732, 18004, 13635, 4626, 15346, 3456, 17926, 16743, 1101, 13777, 11257, 14685, 8030, 11892, 556, 19225, 2187, 18030, 7171, 12630, 13436, 13390, 7567, 8533, 18102, 16930, 4063, 452, 15028, 18198, 8103, 7002, 19811, 9833, 11289, 18303, 5631, 4767, 8337, 5920, 4558, 845 |
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 sys | |
import random | |
import math | |
def sample1(randbelow, n, k): | |
# Array-based shuffle algorithm (used by Python) | |
pool = list(range(n)) | |
for i in range(n, n-k, -1): | |
j = randbelow(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
type | |
Nullable = concept x | |
isNil(x) is bool | |
NilOption*[T] = distinct T | |
CompositeOption*[T] = object | |
has: bool | |
val: T |
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 macros | |
macro doThis(s: static[string]): stmt = | |
let n = parseStmt(s) | |
quote do: | |
template actuallyDoIt: stmt = | |
`n` | |
template exec*(s: string) {.immediate.} = | |
doThis(s) |
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
%if false: | |
echo 5 | |
echo "a" | |
echo "lol" | |
for i in 0..10: | |
%if true: | |
echo 6 | |
echo 8 | |
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
git diff CSFML-2.2 CSFML-master | grep -vP '^([^-+]|. *//)' | sed -r 's/^[-+]{3} .+\///g' | uniq | |
SoundBuffer.h | |
-CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, size_t sampleCount, unsigned int channelCount, unsigned int sampleRate); | |
+CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const sfInt16* samples, sfUint64 sampleCount, unsigned int channelCount, unsigned int sampleRate); | |
-CSFML_AUDIO_API size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer); | |
+CSFML_AUDIO_API sfUint64 sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer); | |
Audio.h | |
+#include <SFML/Audio/SoundStatus.h> | |
+#include <SFML/Audio/SoundStream.h> |