Skip to content

Instantly share code, notes, and snippets.

View JeremyIglehart's full-sized avatar

Jeremy Iglehart JeremyIglehart

  • Downingtown, PA
View GitHub Profile
@JeremyIglehart
JeremyIglehart / closure.js
Created January 31, 2016 06:31
Javascript Closure Fun
function buildFunctions() {
var arr = [];
for (i = 0; i < 3; i++) {
arr.push(
function(number) {
number = number || 0;
i = i + number;
@JeremyIglehart
JeremyIglehart / factory.js
Created January 31, 2016 06:36
Greeting Function Factory
function makeGreeting(language) {
return function(firstName, lastName) {
if (language === 'en') {
console.log('Hello ' + firstName + " " + lastName);
}
if (language === 'ua') {
console.log('Privit ' + firstName + " " + lastName);
@JeremyIglehart
JeremyIglehart / .profile
Created February 16, 2016 04:08
cdf command
# Add the below lines to your .profile
# cd to the path of the front Finder window
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
@JeremyIglehart
JeremyIglehart / README.md
Created May 25, 2016 17:26 — forked from chriswessels/README.md
A guide to setting up self-hosted infrastructure for Meteor applications on Ubuntu Server 13.04.

#Meteor and Self-hosted Infrastructure

Meteor is an eye-opening JavaScript framework that runs on both the client and the server, giving developers a revolutionary take on software engineering. If you are not familiar with Meteor, I urge you to visit their website.

##An overview

In this brief gist, I am going to discuss the process of setting up a server (in my case, a VPS) to host Meteor applications.

My experience with Meteor has been brief, however it has not taken much demonstration for me to realise the significance of this stellar framework. Let's jump right in!

@JeremyIglehart
JeremyIglehart / mupxlog.txt
Created May 28, 2016 02:23
mupx deploy error - strange nodejs error - not sure what to do yet.
$ mupx logs --tail=50
Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Configuration file : mup.json
Settings file : settings.json
[52.40.64.188] at Object.<anonymous> (/bundle/bundle/programs/server/node_modules/fibers/fibers.js:16:8)
[52.40.64.188] at Module._compile (module.js:456:26)
[52.40.64.188] at Object.Module._extensions..js (module.js:474:10)
@JeremyIglehart
JeremyIglehart / howToUpdateArrayMongoDbMeteor.md
Last active June 8, 2016 12:11
How to Update An Array of Subdocuments on a MongoDB Collection in MeteorJS

How to Update An Array of Subdocuments on a MongoDB Collection in MeteorJS

This is a gist created for a comment to an answer provided on stackoverflow.com.

@David Weldon: Thanks for your answer. Below I edited my input, but got the below output. Maybe this is the default behavior of db.ideas.find(). I'll do some looking around. I expected to also get the subdocuments also when I performed the db.ideas.find().

Code I ran:

Ideas.update("bKXXrpYmppFBfq9Kx", {
  $addToSet: {
@JeremyIglehart
JeremyIglehart / StackOverflowQuestionResponse.md
Last active June 8, 2016 21:51
This is output from a Meteor Project intended for a stackoverflow.com question

This is output from a Meteor Project intended for a stackoverflow.com question

@Michael Floyd: Here is the output from your suggestion.

".find() and .findOne() format slightly differently in the meteor mongo console, try the latter. Or try db.ideas.findOne(id).score" -

$ meteor mongo
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/meteor
@JeremyIglehart
JeremyIglehart / ResponseToCommentStackOverflow.md
Created June 8, 2016 22:01
Response to comment on a stackoverflow question

Response to comment on a stackoverflow question

@David Weldon: Thank you for your response. I reset the project, and this time instead of running that update from my browser, I ran it right within the fixtures.js (which is obviously run from the server on startup). I am happier with how things are going into mongo on this reset, but I still can't read my subdocument - it's as if I'm not updating them properly. I feel like they are not there at all.

Here is the relevant fixture.js content:

// The "elvesEpisodetwoId" is set above in the file, I didn't include it because we are not experiencing problems with that collection at all and I'm pretty sure my client would like me to keep some level of privacy as much as possible for the code.

// Add Filler Idea Posts for Elves of Our Lord
var elvesEpisodeTwoIdeaOneId = Ideas.insert({
@JeremyIglehart
JeremyIglehart / TestingUnderscoreSample.js
Created June 17, 2016 20:25
A function which tests the distribution of _.sample()
// Option 1
(function(arraySize = 10, timesToRun = 1000){
let myArray = Array.apply(null, {length: arraySize}).map(Number.call, Number);
let resultsArray = Array.apply(null, Array(arraySize)).map(Number.prototype.valueOf,0);
for (let i = 0; i < timesToRun; i++) {
var result = _.sample(myArray);
resultsArray[result]++;
}
return resultsArray;
})(/*10, 1000*/);
@JeremyIglehart
JeremyIglehart / findWithinRange.js
Created July 5, 2016 21:19
Finding Max Price Within Different Ranges Of "PriceObject"
var priceObject = [
{
min: "1",
max: "100",
price: "0.5"
},
{
min: "101",
max: "500",
price: "0.2"