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 / 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();
class SessionsController < ApplicationController
layout 'basic'
def new
end
def create
puts params[:email]
puts params[:password]
@dallonf
dallonf / app.ts.js
Last active December 13, 2015 20:28
Using the Quintus Engine with TypeScript. This is just a proof-of-concept, it's WAY too early to actually use.
/// <reference path="quintus.d.ts" />
var Q = Quintus()
.include("Sprites, Scenes, Input");
// No need to call Q.Sprite.extend
class Player extends Q.Sprite {
init(p) {
super.init(p, {
asset: "somegraphic.png",
@dallonf
dallonf / await-script-compiled.js
Created November 13, 2012 19:39
AwaitScript compiler concept
// AwaitScript sample compiled to JavaScript
var async = require('async');
function recurse(path, fn) {
var files = [];
fs.readdir(path, function(err, dir) {
if (err) return fn(err);
async.forEach(dir, function(f, fn) {
fs.stat(f, function(err, stat) {
if (err) return fn(err);
@dallonf
dallonf / rewrite.js
Created November 5, 2012 15:35
Rewrite Resource
var Resource = require('deployd/lib/resource')
, util = require('util');
function Rewrite(name, options) {
Resource.apply(this, arguments);
this.rewriteUrl = this.config.rewriteUrl || '/index.html';
}
util.inherits(Rewrite, Resource);
module.exports = Rewrite;