Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Treleaven ntrel

  • London
View GitHub Profile
@ntrel
ntrel / v_in_range
Created Jul 20, 2020
Grepping for inclusive and exclusive range checks
View v_in_range
# Note: maybe some false positives for both
# inclusive range: 65 lines
$ gg -E '\b(\w+) >=?.+&&\s*\1\s*<='
cmd/v/help/help.v:15: if (b >= `a` && b <= `z`) || b == `-` || (b >= `0` && b <= `9`) {
examples/vpwgen.v:15: if c >= `0` && c <= `~` {
thirdparty/fontstash/stb_truetype.h:1128: STBTT_assert(n >= 1 && n <= 4);
thirdparty/fontstash/stb_truetype.h:1163: STBTT_assert(offsize >= 1 && offsize <= 4);
thirdparty/fontstash/stb_truetype.h:1173: if (b0 >= 32 && b0 <= 246) return b0 - 139;
thirdparty/fontstash/stb_truetype.h:1174: else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108;
View V get_unsafe (repeat)
Czastka Family@family-desktop MINGW32 /c/git/v (arr-get)
$ time ./v.exe -prod self
V self compiling (-prod)...
real 0m29.046s
user 0m0.015s
sys 0m0.000s
Czastka Family@family-desktop MINGW32 /c/git/v (arr-get)
$ cp /c/v/v.exe . && time ./v.exe -prod self
View V get_unsafe
Czastka Family@family-desktop MINGW32 /c/git/v (arr-get)
$ gcc --version
gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Czastka Family@family-desktop MINGW32 /c/git/v (arr-get)
$ /c/v/v.exe --version
View geo.d
import std.stdio;
import std.file;
import std.algorithm.iteration;
import std.range;
import std.conv;
void main()
{
auto bytes = read("geo_points.txt");
auto s = cast(string)bytes; // avoid Unicode validation of readText
View ctags optlib2c bug.txt
$ ./autogen.sh
+ type autoreconf
autoreconf is /usr/bin/autoreconf
+ type pkg-config
pkg-config is /usr/bin/pkg-config
+ '[' -z '' ']'
+ type make
+ MAKE=make
++ make -s -f makefiles/list-optlib2c-input.mak
+ ctags_files='optlib/RSpec.ctags