Skip to content

Instantly share code, notes, and snippets.

View dallonf's full-sized avatar

Dallon Feldner dallonf

View GitHub Profile
import * as fs from "fs";
const coverage = JSON.parse(
fs.readFileSync("coverage/coverage-final.json", "utf-8")
);
const output = Object.values(coverage).map((x) => {
const path = x.path;
const totalStatements = Object.keys(x.statementMap).length;
const coveredStatements = Object.entries(x.s).filter(
@dallonf
dallonf / BaseReconciler.cs
Last active January 1, 2021 00:57
Unity "Reconciler" system
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
[System.Serializable]
public abstract class BaseReconciler<TKey, TObject> : ISerializationCallbackReceiver where TObject : Object
{
private Dictionary<TKey, TObject> managedObjects;
private List<TObject> serializedManagedObjects;
// importing a dependency from Cargo (the package manager)
extern crate threadpool;
use std::sync::{self, mpsc};
use std::thread;
use std::time;
// data type to keep a handle for a task
struct ThreadpoolTask<T> {
rx: mpsc::Receiver<T>,
const nock = require('nock');
const test = require('tap').test;
const superagent = require('superagent');
test('reqheaders ignored #748 - test matching', t => {
nock('http://www.example.com', {
reqheaders: {
'authorization': 'Bearer TOKEN'
}
})
@dallonf
dallonf / Conditional.jsx
Created December 29, 2015 16:45
Conditional JSX
function render1() {
return (
<div>
{ templates.length
? null
: <div>Nothing to see here, move along...</div>
}
</div>
);
}
@dallonf
dallonf / index.html
Created October 6, 2015 21:11
React can't render SVG under PhantomJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<svg id="svgRoot">
<g id="gElement">
</g>
declare module 'co' {
interface ICoStatic {
<T>(coroutine: () => IterableIterator<any>): Promise<T>
wrap<T>(coroutine: (...args: any[]) => IterableIterator<Promise<any>>): (...args: any[]) => Promise<T>
}
var co: ICoStatic;
export default co;
}
@dallonf
dallonf / jsonify-bootstrap.js
Created August 4, 2015 16:01
Experiment: render Bootstrap variables to JSON file
let fs = require('fs');
let path = require('path');
let less = require('less');
let bluebird = require('bluebird');
let css = require('css');
async function execute() {
let variablesLess = await bluebird.fromNode(cb => fs.readFile(path.join(__dirname, 'less/variables.less'), 'utf-8', cb));
let [parseResult] = await bluebird.fromNode(cb => less.parse(variablesLess, cb));
let varNames = parseResult.rules
@dallonf
dallonf / gist:3f365373ae971d278706
Created May 1, 2015 17:26
React FloatingElement
var FloatingElement = React.createClass({
propTypes: {
children: React.PropTypes.element.isRequired,
floatingClassName: React.PropTypes.string
},
getDefaultProps() {
return {
floatingClassName: 'floating'
@dallonf
dallonf / gist:6178837
Created August 7, 2013 21:22
jQuery Monkey Testing
// Paste this into the Developer Console for any project that uses jQuery
function stopMonkey() {
clearInterval(monkey);
}
monkey = setInterval(function() {
var $els = $('body').find('*:visible');
var rand = Math.round(Math.random() * $els.length);
$els.eq(rand).click();