Skip to content

Instantly share code, notes, and snippets.

# Benchmarking answers to http://stackoverflow.com/questions/9333952/in-ruby-how-to-make-the-string-include-method-ignore-case/9334066
# http://www.gutenberg.org/cache/epub/1661/pg1661.txt
strings = IO.read('sherlock.txt').scan(/\w+/) # 109,222 words
known = 500.times.map do
strings.sample.downcase.chars.map{ |c| rand<0.5 ? c.upcase : c }.join
end
words = known.flat_map{ |s| [s, s+"-"] } # \w does not include -
@Phrogz
Phrogz / Makefile
Created August 28, 2016 16:11
Qt QML Makefile generated by qmake
#############################################################################
# Makefile for building: qt-client
# Generated by qmake (3.0) (Qt 5.2.1)
# Project: qt-client.pro
# Template: app
# Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -spec linux-g++ -o Makefile qt-client.pro
#############################################################################
MAKEFILE = Makefile
@Phrogz
Phrogz / .block
Last active November 12, 2016 01:48 — forked from mbostock/.block
Histogram
license: gpl-3.0
@Phrogz
Phrogz / gist:079c45bc73ea536176f21d0e6f48e7a0
Created November 15, 2016 17:43
Build errors attempting to compile QQuickMapboxGL
gkistner@gkistner-dt3:/var/git/mapbox-gl-native$ make qt-qml-app
npm update # Install dependencies but don't run our own install script.
npm http GET https://registry.npmjs.org/node-pre-gyp
npm http 304 https://registry.npmjs.org/node-pre-gyp
npm http GET https://registry.npmjs.org/node-pre-gyp/0.6.31
npm http 304 https://registry.npmjs.org/node-pre-gyp/0.6.31
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/rc
npm http GET https://registry.npmjs.org/npmlog
TEMPLATE = app
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
INSTALL_DIR = $$PWD/../install
target.path = $$INSTALL_DIR
# Copy the QQuickMapboxGL folder to the install directory
index 0dd8c96..b28aebf 100644
--- a/platform/qt/qmlapp/main.cpp
+++ b/platform/qt/qmlapp/main.cpp
@@ -1,5 +1,3 @@
-#include <QMapbox>
-
#include <QGuiApplication>
#include <QIcon>
#include <QQmlApplicationEngine>
@@ -13,10 +11,6 @@ int main(int argc, char *argv[])
@Phrogz
Phrogz / LICENSE.md
Last active October 4, 2017 18:47 — forked from ganezasan/LICENSE.md
Day / Hour Heatmap in v4

Copyright (c) 2016, Tom May

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTH

class SafeTemplate < Parslet::Parser
# ...
rule(:cond) do
test.as(:test) >> markup.as(:out)
>> (elif.as(:test) >> markup.as(:out)).repeat.as(:elifs)
>> (ells >> markup.as(:elseout)).maybe
>> stop
end
# ...
end
require 'parslet'
class PishTemplate < Parslet::Parser
attr_accessor :vars
# `vars` is a hash of symbol-to-values for referencing in templates.
# vars can also be safely set using the #assign-values method.
def initialize(vars={})
super()
@vars = vars
@Phrogz
Phrogz / app.lua
Last active October 31, 2018 18:59
Overriding Lua libraries with stub versions, that have access to the originals
-- add my custom lib directory to the path
package.path = 'lib/?.lua;'..package.path
-- add this line only to switch to using the wrappers;
-- do this after making any other path adjustments.
package.real,package.path = package.path,'debug/?.lua;'..package.path
local mylib = require 'mylib'