Skip to content

Instantly share code, notes, and snippets.

View rescribet's full-sized avatar

Thom rescribet

View GitHub Profile
Encountered error "TypeError: Object function Symbol(description) {
var value = new SymbolValue(description);
if (!(this instanceof Symbol))
return value;
throw new TypeError('Symbol cannot be new\'ed');
} has no method 'for'" when prerendering ActiveToggle with {<<...props hash here...>>}
var value = new SymbolValue(description);
if (!(this instanceof Symbol))
return value;
throw new TypeError('Symbol cannot be new\'ed');
@rescribet
rescribet / gist:3cbe8a8487e9763a3da8
Last active August 29, 2015 14:23
Component prerender exception stacktraces

Stacktraces associated with this issue

In my application:

Encountered error "TypeError: Object function Symbol(description) {
      var value = new SymbolValue(description);
      if (!(this instanceof Symbol))
        return value;
 throw new TypeError('Symbol cannot be new\'ed');
@rescribet
rescribet / react_ujs.js
Created July 20, 2015 23:38
Non-global react_ujs
/*globals React, Turbolinks*/
/* Modified react_ujs to prevent the components polluting global scope whenever possible.
* Since I use subdirs for my components, it also flattens the structure making
* _componentStore[className] possible.
* Creds for the react_ujs.js file to the people from react-rails (https://github.com/reactjs/react-rails)
*/
var path = require('path');
@rescribet
rescribet / base.rb
Last active September 17, 2016 06:06
A Turbolinks 5 drop-in for when permanent partials can't be lazy loaded (no-script requirement).
# A turbolinks 5 drop-in for when permanent partials can't be lazy loaded (no-script requirement).
#
# Whenever a static partial is really heavy, it is undesirable to render it on every/many request(s), so this render drop-in only renders the partial's content if the `Turbolinks-Referrer` header is *not* present.
#
# Usage:
# ```ruby
# render partial: 'navbar', permanent: true
# # => <div id="turbolinks_navbar" data-turbolinks-permanent="true">[Always rendered]</div> # Behaviour as described in the RailsConf '15 keynote, where HTML might be lazy loaded via JS
#
# render partial: 'navbar', permanent: 'navbar'
@rescribet
rescribet / fetchHelpers.js
Last active August 9, 2016 19:41
The helpers we use to aid in using fetch with secure and non-secure (json) calls.
/**
*
* A regular non-safe get request:
* fetch('/profiles/foobar.json', jsonHeader());
*
* How this would look in a safe fetch request:
* fetch('/profiles.json', safeCredentials({
* method: 'POST',
* body: JSON.stringify({
* q: input,
@rescribet
rescribet / trackers.txt
Last active April 26, 2016 19:26
List of (white line separated) trackers. There might be some dead in there, but it's a nice kick start for adding to dead transfers
udp://tracker.opentrackr.org:1337/announce
udp://9.rarbg.me:2710/announce
http://retracker.krs-ix.ru/announce
udp://9.rarbg.com:2710/announce
http://tracker.trackerfix.com/announce
@rescribet
rescribet / countLines.js
Last active December 19, 2018 09:24
Snippet to count the amount of lines added/removed in bitbucket pull requests
(function countLines() {
let addedArr = [];
let removedArr = [];
document.querySelectorAll('#commit-files-summary .lines-added').forEach((n) => { addedArr.push(n.innerText) });
document.querySelectorAll('#commit-files-summary .lines-removed').forEach((n) => { removedArr.push(n.innerText) });
let added = addedArr
.map((n) => parseInt(n))
.reduce((a, b) => { return b + a } );
let removed = removedArr
.map((n) => parseInt(n))
@rescribet
rescribet / filterByArrIncludes.ts
Last active April 19, 2018 12:06
Variable types don't seem to be filtered by comparing them via an array includes statement.
abstract class SomeNode {
public readonly termType!: string;
}
class NamedNode extends SomeNode {
public readonly termType: "NamedNode";
constructor() {
super();
this.termType = "NamedNode";
@rescribet
rescribet / 0_results.md
Last active November 11, 2018 22:00
RDFLib PR parsing benchmark
@rescribet
rescribet / jsonld-parser.js
Last active October 21, 2019 08:36
JSON-LD parser connector for rdflib when not needing to support { termType: 'Collection' }
function convertTerm (kb, term) {
switch (term.termType) {
case 'BlankNode':
return kb.rdfFactory.blankNode(term.value);
case 'NamedNode':
return kb.rdfFactory.namedNode(term.value);
case 'Literal':
return kb.rdfFactory.literal(term.value, term.language || convertTerm(kb, term.datatype));
case 'DefaultGraph':
return kb.rdfFactory.defaultGraph();