Skip to content

Instantly share code, notes, and snippets.

View paulmolluzzo's full-sized avatar

Paul Molluzzo paulmolluzzo

View GitHub Profile
@paulmolluzzo
paulmolluzzo / gist:9948278
Created April 3, 2014 04:28
Improving We Work Meteor RSS Feed

The current implementation of the RSS feed for We Work Meteor (blob used below is here) has an issue when actually used with an RSS reader. Every time a new document is added to a collection, the entire feed is re-published with the whole collection. The reader winds up showing duplicate posts from the last publishing effort.

The solutions I've considered are:

  1. Using amplify to store a the pubDate on the client and then using that to define the earliest post to publish in the feed. Not sure if it's even possible with feed readers.
  2. Add a new property to the collections called published and set it to true once that particular document is published in a feed. Every time the feed is published it would only find published:false documents. An example is below, but the schemas need to be updated too.
  3. Limiting the .find() to just the posts after the last build
I20140626-21:11:11.391(-4)? { statusCode: 200,
I20140626-21:11:11.412(-4)? content: '{"name": "Yo All", "description": "", "renders": ["application/json", "text/html"], "parses": ["application/json", "application/x-www-form-urlencoded", "multipart/form-data"]}',
I20140626-21:11:11.414(-4)? headers:
I20140626-21:11:11.415(-4)? { connection: 'keep-alive',
I20140626-21:11:11.415(-4)? 'x-frame-options': 'SAMEORIGIN',
I20140626-21:11:11.416(-4)? 'content-type': 'application/json',
I20140626-21:11:11.416(-4)? vary: 'Accept, Cookie',
I20140626-21:11:11.433(-4)? allow: 'POST, OPTIONS',
I20140626-21:11:11.437(-4)? 'transfer-encoding': 'chunked',
I20140626-21:11:11.437(-4)? date: 'Fri, 27 Jun 2014 01:11:10 GMT',
@paulmolluzzo
paulmolluzzo / translate.rb
Created July 8, 2014 01:36
Easy Translate
#!/usr/bin/ruby
require 'easy_translate'
EasyTranslate.api_key = '' #Get from google
target_path = '' # path to translate
Dir.glob(target_path) do |item|
next if item == '.' or item == '..' or item == '.svn'
@paulmolluzzo
paulmolluzzo / Gruntfile.js
Created July 8, 2014 01:37
Translate Grunt
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
'prettify': {
options: {
indent: 4,
indent_char: ' ',
wrap_line_length: 0,
@paulmolluzzo
paulmolluzzo / helper.js
Created August 7, 2014 01:14
URL Encoding Helper for Meteor
UI.registerHelper('escapeURL', function(route, id) {
var path = Meteor.absoluteUrl() + Router.routes[route].path({_id: id}).substring(1);
return encodeURIComponent(path);
});
@paulmolluzzo
paulmolluzzo / routes.js
Created August 7, 2014 14:19
Subscribing via argument from Route
this.route('report', {
path: '/reports/:_id',
template: 'report',
data: function () {
return {
reports:Reports.findOne({_id:this.params._id})
};
},
waitOn: function(){
return subscriptionHandles.singlereport(this.params._id);
@paulmolluzzo
paulmolluzzo / gist:cef3bac129cac10de909
Created August 20, 2014 16:45
Cancelling a form and resetting it
'click .cancel-edit-section': function(e) {
var parent = $(e.currentTarget).closest('.section');
$(parent).find('#section-title input').val(this.title);
$(parent).find('#section-content textarea').val(this.content);
$(parent).toggleClass('editing');
return false;
},
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
#!/bin/bash
# checkout a pull request by ID into a new branch like: gcopr 123 new-branch-name
gcopr() {
numRegex='^[0-9]+$'
if ! [[ $1 =~ $numRegex ]]; then
echo "No ID for PR given"
else
branchname=${2-pr-$1}
git fetch origin pull/$1/head:$branchname
#!/usr/bin/env bash
# power cycle wifi because Apple laptops crap out when waking from sleep
# might need to replace 'airport' with 'en0' - the first attempt will stdout the one that worked
alias wtf='networksetup -setairportpower airport off; networksetup -setairportpower airport on'