Skip to content

Instantly share code, notes, and snippets.

View copleykj's full-sized avatar
😎
Totally Committed

Kelly Copley copleykj

😎
Totally Committed
View GitHub Profile
@copleykj
copleykj / useReactiveQuery.ts
Last active January 8, 2022 23:14
Grapher Hooks
import { useState, useEffect, useRef } from 'react';
import { useTracker } from 'meteor/react-meteor-data';
import { Grapher } from 'meteor/cultofcoders:grapher';
import { Meteor } from 'meteor/meteor';
interface QueryInfo<T> {
loading: boolean
ready: boolean
data: T[]
error: Meteor.Error | null
@copleykj
copleykj / makeTypes.ts
Created February 3, 2020 01:25
Dirty way to output types for an object such as a Mongo documents
// This isn't comprehensive and is a pretty dirty hack piece of code,
// but it gets you close when you have a ton of fields in mongo
// collection documents that you need to create interfaces for
function makeTypes(obj: { [key: string]: any }, depth: number = 0) {
if (obj) {
let types: string = '';
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (value) {
@copleykj
copleykj / FEM-download-bookmark.js
Created May 19, 2018 19:41
Bookmarklet to automatically download Front End Masters videos
javascript:(function(){
const vdo = document.getElementsByTagName("video")[0];
vdo.pause();
const vdoUrl = vdo.src
const link = document.createElement('a');
link.href = vdoUrl;
link.target= '_blank';
const paths = location.pathname.split('/');
const e = document.createEvent('MouseEvents');
@copleykj
copleykj / navigation.jsx
Created April 26, 2018 15:12
React Navigation - StackNavigator nested in DrawerNavigator
import React from 'react';
import { StackNavigator, DrawerNavigator } from 'react-navigation';
import ScreenOne from '../screens/ScreenOne';
import ScreenTwo from '../screens/ScreenTwo';
import SideBar from '../components/SideBar';
const AppNavigator = StackNavigator({
FirstScreen: {
module.exports = {
entry: "./src/main.js",
output: {
filename: "./dist/bundle.js"
},
module: {
rules: [
{
test: [/\.js$/, /\.es6$/],
exclude: /node_modules/,
@copleykj
copleykj / Sort
Last active September 19, 2016 01:24 — forked from lxr1017/Sort
/*This program is intended to help you refresh your memory with programming in C++ and consists only of concepts from 146.
Write a program that reads the appropriate number of integers into an array, and sorts these numbers in reverse order
(decreasing order). The data will consist of 3 sets of data (Please use a loop instead of running the program 3 times).
Each set of data begins with an integer that indicates the number of integers on the next newline that are to be read
and sorted. So, unnecessary (i.e., to be ignored-not sorted)numbers may exist in the data.
The 3rd and 5th will be set up like the 1st. Likewise, the 4th and 6th will be set up like the 2nd.
Requirements:
Function to print the array of numbers; pass be value must be used
//Join into single line and add to chrome or firefox as a bookmark and run on lynda video page with html5 video enabled
//will not work with lynda's flash video player
javascript:(function(){
var vdoUrl = $("video").attr("h264");
var link = document.createElement('a');
link.href = vdoUrl;
var fileName = vdoUrl.substring(vdoUrl.lastIndexOf('/') + 1, vdoUrl.length);
link.download = fileName;
var Fiber = Npm.require('fibers')
var Server = Meteor.npmRequire('bittorrent-tracker').Server;
Tracker = function () {
Server.prototype.constructor.call(this);
};
Tracker.prototype = Object.create(Server.prototype);
Tracker.prototype.constructor = Tracker;
Tracker.prototype.getSwarm = function (infoHash) {
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex');
var torrent;
UI.registerHelper('eachIndex', function () {
var withIndex = this.map(function(x, i) {
return {data: x, index: i}
});
return UI.Each(
function() {
return withIndex;
}, UI.block(null), UI.block(null));
});
Meteor.publish('userData', function() {
if(!this.userId) return null;
return Meteor.users.find(this.userId, {fields: {
mmmelons: 1,
}});
});