Skip to content

Instantly share code, notes, and snippets.

  1. Hi.

Hello.

>> e = Enumerator.new do |y|
?> y << 1
>> y << 2
>> sleep 10
>> y << 3
>> end
=> #<Enumerator: #<Enumerator::Generator:0x007ffcd3801100>:each>
>> puts Time.now; puts e.take(1).to_a; puts Time.now
2017-06-15 18:56:15 +1000
1
@kivikakk
kivikakk / verify.rb
Created August 10, 2017 03:11
sourcepos verifier
#!/usr/bin/env ruby
require 'nokogiri'
doc = File.read(ARGV[0]).split("\n")
xml = Nokogiri::XML(`build/src/cmark-gfm -t xml --sourcepos #{ARGV[0]}`)
xml.css('text, code').each do |el|
from, to = el['sourcepos'].split('-').map {|r| r.split(':').map(&:to_i)}
if from[0] != to[0]
@kivikakk
kivikakk / test.rs
Last active October 19, 2017 15:14
Compiling diesel_ltree v0.1.0 (file:///Users/kivikakk/kivikakk/diesel_ltree)
error[E0599]: no method named `load` found for type `diesel::query_builder::SelectStatement<tests::my_tree::table, diesel::query_builder::select_clause::SelectClause<functions::ltree2text_t<functions::lca_t<diesel::expression::bound::Bound<diesel::types::Array<types::Ltree>, std::vec::Vec<_>>>>>>` in the current scope
--> src/tests.rs:65:10
|
65 | .load::<String>(&connection)
| ^^^^
|
= note: the method `load` exists but the following trait bounds were not satisfied:
`_ : diesel::query_builder::QueryId`
`_ : diesel::query_builder::QueryId`
Compiling diesel_ltree v0.1.0 (file:///Users/kivikakk/kivikakk/diesel_ltree)
error[E0277]: the trait bound `functions::ltree2text_t<functions::lca_t<diesel::expression::bound::Bound<diesel::types::Array<types::Ltree>, std::vec::Vec<functions::text2ltree_t<diesel::expression::bound::Bound<diesel::types::Text, &str>>>>>>: diesel::query_builder::Query` is not satisfied
--> src/tests.rs:92:5
|
92 | LoadDsl::load(ltree2text(lca(vec![text2ltree("1.2.2.3"), text2ltree("1.2.3")])), &connection);
| ^^^^^^^^^^^^^ the trait `diesel::query_builder::Query` is not implemented for `functions::ltree2text_t<functions::lca_t<diesel::expression::bound::Bound<diesel::types::Array<types::Ltree>, std::vec::Vec<functions::text2ltree_t<diesel::expression::bound::Bound<diesel::types::Text, &str>>>>>>`
|
= note: required because of the requirements on the impl of `diesel::query_builder::AsQuery` for `functions::ltree2text_t<functions::lca_t<diesel::expression::bound::Bound<diesel::types::Array<types::Ltree>, s

A glimmering ray of light
fast in soft hands;
I've come so far in search of its holder,
wandering 'til the brink of time.

I've been looking for you all this time,
not even knowing your name;
because I've been wanting to share
just this one feeling with you.

diff --git a/Cargo.toml b/Cargo.toml
index 64f9b6c..54d4b57 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,6 +32,7 @@ clap = { version = "2.29", optional = true }
twoway = "0.1"
pest = "1.0"
pest_derive = "1.0"
+jetscii = "0.4"
{
"name": "Ruby",
"scopeName": "source.ruby",
"patterns": [
{
"name": "meta.class.ruby",
"match": "(?x)\n^\\s*(class)\\s+\n(\n (\n [.a-zA-Z0-9_:]+\n (\\s*(\u003c)\\s*[.a-zA-Z0-9_:]+)? # class A \u003c B\n )\n |\n ((\u003c\u003c)\\s*[.a-zA-Z0-9_:]+) # class \u003c\u003c C\n)",
"captures": {
"1": {
"name": "keyword.control.class.ruby"
@kivikakk
kivikakk / dedup.rb
Last active September 11, 2018 05:31
extract and dedup suppressions in valgrind suppressions files
#!/usr/bin/env ruby
# frozen_string_literal: true
def parse_suppressions(data)
state = :idle
current = nil
result = []
data.lines.each do |line|
case state
@kivikakk
kivikakk / whitelist.md
Created November 16, 2018 02:18
HTML sanitizer whitelist for user content on GitHub.com
  • Any allowed id and name attributes have "user-content-" prefixed to their value.
  • A maximum of 2 nested sub or sup tags are allowed.
  • A maximum of 10 nested ul or ol tags are allowed.
Allowed Element Allowed Attributes
All allowed elements abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, charset, checked, clear, color, cols, colspan, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, hreflang, hspace, id, ismap, itemprop, label, lang, maxlength, media, method, multiple, name, nohref, noshade, nowrap, open, prompt, readonly, rev, rows, rowspan, rules, scope, selected, shape, size, span, start, summary, tabindex, title, type, usemap, valign, value, vspace, width
a As above plus href (must be github-mac, github-windows, http,