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 / exact_checked_rule
Created July 24, 2013 21:23
A Mesosphere rule to make sure a check box array has at least one field checked.
Mesosphere.registerRule("exactChecked", function(fieldValue, ruleValue, fieldName, formFieldsObject, fieldRequirements){
if(_(formFieldsObject[fieldName]).isArray() && formFieldsObject[fieldName].length == ruleValue){
return true;
}
return false;
});
@copleykj
copleykj / gist:7896726
Created December 10, 2013 19:35
Trigger meteor template events programmatically.
_(Template.templateName._tmpl_data.events["event selector"]).each(function(eventName){
eventName.call(self, event);
});
@copleykj
copleykj / gist:7922639
Created December 12, 2013 03:09
Basic example of publishing one server side collection to 2 different client side collections.
//Available on Client and Server and is a managed collection
Vehicles = new Meteor.Collection('vehicles');
if(Meteor.isServer){
Meteor.publish('cars', function () {
var cursor = Vehicles.find({type:"car"});
var subscription = this;
var handle = cursor.observe({
added: function (document) {
Template.gem_view.context = function() {
return {
contentTemplate: "gems"
};
};
Template.page.render_content = function() {
var context = this;
var html = Template.no_template_found;
if (context && context.contentTemplate) {
Meteor.publish('userData', function() {
if(!this.userId) return null;
return Meteor.users.find(this.userId, {fields: {
mmmelons: 1,
}});
});
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));
});
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;
//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;
@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
module.exports = {
entry: "./src/main.js",
output: {
filename: "./dist/bundle.js"
},
module: {
rules: [
{
test: [/\.js$/, /\.es6$/],
exclude: /node_modules/,