Skip to content

Instantly share code, notes, and snippets.

@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'
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
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
@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

@Phrogz
Phrogz / nokogiri_reorder_nodes.rb
Created December 17, 2010 16:43
Reordering nodes in a Nokogiri XML document and getting the result as new XML
require 'nokogiri'
xml = <<ENDXML
<top>
<node1>
<value>mmm</value>
<value>zzz</value>
<value>ccc</value>
</node1>
<anothernode>
<value>zzz</value>
@Phrogz
Phrogz / simpleinheritance.rb
Last active January 21, 2017 13:55
Showing that a sub-class need not have an #initialize method
class Person
attr_reader :firstname, :lastname
def initialize( first, last )
@firstname, @lastname = first, last
end
def say_hi
puts "Hello, my name is #{@firstname} #{@lastname}"
end
end
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[])
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
@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
@Phrogz
Phrogz / .block
Last active November 12, 2016 01:48 — forked from mbostock/.block
Histogram
license: gpl-3.0