Skip to content

Instantly share code, notes, and snippets.

View AlexFrazer's full-sized avatar
🦊
🦊🦊🦊

Frazer AlexFrazer

🦊
🦊🦊🦊
View GitHub Profile
import java.util.*;
import java.io.*;
public class Project {
public static void main(String[] args) {
// define the input for the user
Scanner userInput = new Scanner(System.in);
// the path to the file you want to load. This will have to change on your computer
String path = "/home/alex/code/java_examples/csv.txt";
// use that path to read the file at that path name. See the readFile method
'use strict';
angular.module('app')
.controller('CreateWorkflowCtrl', function($scope, $location, Workflow, Category) {
$scope.workflow = new Workflow();
$scope.page = 0;
$scope.create = function() {
$scope.workflow.$save(function(data) {
$location.path("/workflow/" + data.id);
@AlexFrazer
AlexFrazer / client.js
Created February 24, 2015 15:12
quick bug in my code using meteor
Template.imageboard.helpers({
posts: function() {
return Posts.find({}, { sort: { timestamp: -1} });
},
has_posts: function() {
return Posts.find({}).count() > 0;
}
});
Template.write.events({
@AlexFrazer
AlexFrazer / browser vs server
Created April 3, 2015 15:22
An example of publications and subscriptions
// browser
> Meteor.users.findOne()
{
_id: "1234"
}
// console
> Meteor.users.findOne()
{
_id: "1234",
/**
* Helpers applying to EVERY mongo collection in my db
*/
Mongo.Collection.prototype._utilities = function() {
var self = this;
/**
* return all the ids of the items in this collection
* @returns {Array} all the ids in this collection
*/
@AlexFrazer
AlexFrazer / childController.js
Created May 13, 2015 17:29
Extending data with iron:router controllers
ChildController = ParentController.extend({
showItem: function () {
/**
* Here is the problem.
* I want to implicitly pass the "group" to EVERY rendered route
* Is it possible to do this?
*/
var group = ChildController.__super__.data.call();
this.render('itemPage', {
data: {
{
// type as in the primitive type of the data
type: Match.Any,
// label on the form
label: Match.Optional(Match.OneOf(String, Function)),
// is it required to be submitted or not
optional: Match.Optional(Match.OneOf(Boolean, Function)),
// these four are self-explanatory.
min: Match.Optional(Match.OneOf(Number, Date, Function)),
max: Match.Optional(Match.OneOf(Number, Date, Function)),
Games = new Mongo.Collection("games");
if (Meteor.isClient) {
Template.leaderboard.helpers({
/**
* For user 'corvid', this should return both 'starcraft' and 'warcraft'
* because he is a player in the Roles.GLOBAL_GROUP
*/
games: function () {
return Games.find({
// my data structure
[{
forkedFrom: "1234",
days: [ 0, 1, 2, 3, 4, 5, 6 ],
timesOfDay: [ 0, 1 ]
}, {
forkedFrom: "5678",
days: [ 0, 1, 2, 3, 4, 5, 6 ],
timesOfDay: [ 0 ]
}]
/**
* After an order is updated, add that data to the feed
*/
Orders.after.update(function (userId, doc, modifier) {
// this is tedious
var user = Meteor.users.findOne(doc.userId);
// for payment status
if (_.has(modifier, ['$set', 'payment.status'])) {
var status = modifier.$set['payment.status'];