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 function utf8_iter(s, i) | |
| if i >= #s then return end | |
| local b, nbytes = s:byte(i+1,i+1), 1 | |
| -- determine width of the codepoint by counting the number if set bits | |
| -- from top to bottom. not 100% to standard, but it works well enough | |
| if b/4 >= 63 then nbytes = 6 | |
| elseif b/8 >= 31 then nbytes = 5 | |
| elseif b/16 >= 15 then nbytes = 4 | |
| elseif b/32 >= 7 then nbytes = 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
| class Constant(Module): | |
| def __init__(self, val = 0): | |
| self.out = val | |
| def __repr__(self): | |
| return 'Constant({})'.format(self.out) | |
| class Mul(Module): | |
| def __repr__(self): | |
| return 'Mul()' |
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 Table(dict): | |
| def __getattr__(self, name): | |
| return self[name] if name in self else None | |
| def __setattr__(self, name, value): | |
| if value is not None: | |
| self[name] = value | |
| elif name in self: | |
| del self[name] | |
| def __delattr__(self, name): | |
| self.__setattr__(name, None) |
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
| #!/usr/bin/python | |
| class AnsiColor: | |
| default = '\033[00;30m' | |
| bold = '\033[01;30m' | |
| green = '\033[00;32m' | |
| boldgreen = '\033[01;32m' | |
| boldred = '\033[01;31m' | |
| pass |
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
| love=$(/usr/bin/env love) | |
| zip=$(/usr/bin/env zip) | |
| luac=$(/usr/bin/env luac) | |
| # path to win and osx distributions | |
| windir=~/Stuff/love-win-x86 | |
| osxapp=~/Stuff/love.0.8.app | |
| game=TITLE-OF-THE-GAME.love |
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 lhc = require 'lhc' | |
| local SAMPLERATE = 44100 | |
| local generator = { | |
| sine = function(x) return math.sin(x * 2 * math.pi) end, | |
| tri = function(x) x = (x-.5)%1 return math.min(2*x-1, 1-2*x) end, | |
| saw = function(x) return (2*x-1)%2 - 1 end, | |
| rect = function(x) return 2 * math.floor((2*x)%2) -1 end, | |
| wn = function(x) return math.random() 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
| int l_imwrite(lua_State *L) | |
| { | |
| // see https://gist.github.com/4154182 | |
| cv::Mat *img = LuaProxy<cv::Mat>::get(L, 1); | |
| const char *path = luaL_checkstring(L, 2); | |
| if (cv::imwrite(path, *img)) | |
| { | |
| lua_pushboolean(L, true); | |
| return 1; |
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 <lua_proxy.hpp> | |
| #include <opencv.hpp> | |
| // Exposing cv::Mat to Lua | |
| template<> struct LuaXTraits<cv::Mat> | |
| { | |
| constexpr static const char *name() | |
| { | |
| return "Type.cv::Mat"; |
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 chrome = require "chrome" | |
| local capi = { luakit = luakit } | |
| local page = "chrome://favs/" | |
| local pattern = page.."?" | |
| local cutycapt_bin = "/home/matthias/.bin/CutyCapt" | |
| local html_template = [====[ | |
| <html> |
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
| // ==UserScript== | |
| // @include *love2d.org/forums/viewtopic.php* | |
| // ==/UserScript== | |
| (function() { | |
| var users = []; // the users to hide automatically | |
| function getElementsByTagAndClass(tag, cls) { | |
| var tags = document.getElementsByTagName(tag); | |
| var ret = []; |